agentleFS
ufukyuksel-devufukyuksel-dev/SUPER_COMPUTER_AI/skills/ai-engineering/inference-optimization/SKILL.md

inference-optimization

Skill0 starsChanged 47 days agoMITView on GitHub

Use when tuning inference efficiency on given hardware — GPU/VRAM sizing, quantization (GGUF/AWQ/GPTQ/FP8), KV-cache, batching, speculative decoding, attention optimizations (e.g. FlashAttention), latency/throughput trade-offs. Do NOT use for choosing a serving stack or topology (see skill model-serving) or the model itself (see skill model-selection-hf).

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat estimates as capacity hypotheses and measurements as evidence.

    line 13
  2. Very specific:

    Read the quantization decision tree.

    line 24
  3. Very specific:

    Test speculative decoding only after verifying draft/target/runtime compatibility.

    line 32
  4. Distinctive:

    Test attention optimizations only after verifying model shape, dtype, accelerator, runtime, and kernel support.

    line 33
  5. Distinctive:

    When two benchmarks conflict, compare workload, hardware, precision, versions, concurrency, warmup, quality gate, and measurement method.

    line 35
  6. Very specific:

    If runtime or hardware inspection is unavailable, provide ranges and formulas labeled ESTIMATE.

    line 45
  7. Distinctive:

    If benchmarking is unavailable, return an experiment plan and conditional ranking only.

    line 46
  8. Very specific:

    If quality evaluation is unavailable, do not approve quantization or decoding changes for production.

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Inference Optimization

Boundaries

  • Optimize an already identified model and workload on specified hardware and runtime constraints.
  • For concrete model selection and license verification, see skill model-selection-hf.
  • For serving engine, endpoint topology, scaling, and multi-region design, see skill model-serving; return measured runtime requirements as inputs.
  • Treat estimates as capacity hypotheses and measurements as evidence. Never claim that a model fits or an optimization helps until the complete envelope is accounted for and tested.

Decision Workflow

  1. Pin the model revision and architecture, parameter count, precision/artifact, runtime version, accelerator and memory, prompt/output length distributions, context ceiling, concurrency, quality floor, and latency/throughput objectives.
  2. For current hardware, kernel, runtime, format, speculative-decoding, and attention-feature compatibility, see skill ai-research. Mark unsupported or unverified combinations before ranking them.
  3. Build a memory envelope:
    • estimate weights from the exact artifact or parameters × effective bytes, including quantization metadata;
    • calculate KV cache from the model architecture, cache dtype, sequence length, batch/concurrency, and runtime layout;
    • include activations, temporary workspaces, graph/kernel buffers, allocator fragmentation, runtime/process overhead, and a safety margin;
    • show every assumption, unit, and range. Never use weights alone as a fit test.
  4. Read the quantization decision tree. Eliminate formats without verified hardware/runtime/model support, then compare memory, quality, conversion, portability, and kernel implications.
  5. Locate the bottleneck with separate prefill and decode measurements. Treat batching, cache policy, speculative decoding, prefix reuse, attention kernels, and compilation as independent hypotheses with interactions to test.
  6. Define a reproducible benchmark gate: pin versions and settings; use representative prompt/output buckets and concurrency; warm up; repeat runs; capture raw results; and compare against the same quality set.
  7. Measure time to first token, inter-token/decode latency, end-to-end p50/p95/p99 latency, tokens per second, request throughput, peak and steady memory, queueing, error rate, and task quality.
  8. Select only a configuration that meets the predeclared memory, quality, latency, and throughput gates. Report uncertainty, conflicting benchmarks, and rollback conditions.

Speculative and attention decision notes

  • Test speculative decoding only after verifying draft/target/runtime compatibility. Measure acceptance rate, draft cost, tail latency, memory, and quality; do not assume a universal speedup.
  • Test attention optimizations only after verifying model shape, dtype, accelerator, runtime, and kernel support. Compare full workload behavior, not a microbenchmark alone.
  • Separate improvements to prefill from improvements to decode. Do not attribute queueing or batching changes to a kernel without controlled evidence.
  • When two benchmarks conflict, compare workload, hardware, precision, versions, concurrency, warmup, quality gate, and measurement method. Run a workload-matched reproduction instead of choosing the more favorable result.

Required Output

Return the pinned input contract, transparent memory worksheet, supported candidate configurations, benchmark protocol, raw-result locations, comparison table, selected configuration, confidence, and remaining UNVERIFIED claims.

Tool Requirements & Degradation

  • Require artifact/config inspection, hardware and runtime inventory, memory telemetry, a repeatable load/benchmark runner, and a workload quality check.
  • For current format, kernel, runtime, hardware, and feature support, see skill ai-research. Do not infer compatibility from a format name.
  • If runtime or hardware inspection is unavailable, provide ranges and formulas labeled ESTIMATE; do not state that the model fits.
  • If benchmarking is unavailable, return an experiment plan and conditional ranking only. Do not convert published benchmarks into local measurements.
  • If quality evaluation is unavailable, do not approve quantization or decoding changes for production; label the quality effect UNVERIFIED.

Failure Modes

  • Calculating only weight memory and omitting KV cache, concurrency, workspaces, overhead, fragmentation, or margin.
  • Assuming GGUF, AWQ, GPTQ, and FP8 are interchangeable or supported by every runtime and accelerator.
  • Reporting estimates as observed measurements or promising universal latency gains.
  • Comparing benchmarks with mismatched workload, version, hardware, precision, or quality gates.
  • Optimizing average latency while ignoring time to first token, tail latency, queueing, memory, or output quality.
  • Choosing a different model, serving engine, or deployment topology to make the tuning result look successful.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.