agentsclimarketplace

Inference serving optimization

Skill Amey-Thakur/AI-SKILLS/skills/gpu-ai-infrastructure/inference-serving-optimization

Plug-and-play skills and prompts for every AI coding agent

Install
npx -y skills add Amey-Thakur/AI-SKILLS --skill inference-serving-optimization

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 21 days oldThe repository was created 21 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Tune LLM serving to hold latency SLOs while raising GPU throughput, working the batch scheduler, KV cache, and paged attention together. Use when a serving replica misses its latency target or leaves memory and utilization on the table.

SKILL.md

3.4 KB, 740 tokens by cl100k_base, as published. Nobody here has run it

Inference serving optimization

A serving replica has two failure modes that trace back to the same place: the GPU sits half idle, or tail latency blows past budget. Both come from how the loop forms batches and how it spends memory on the key-value (KV) cache. The work is to trade throughput against tail latency on purpose, one dial at a time, instead of guessing and breaking a second target while fixing the first.

Method

  1. Pin the SLO to two numbered percentiles. State a time-to-first-token (TTFT) target and an inter-token latency target, each at a percentile: for example TTFT p99 under 500 ms, inter-token p99 under 40 ms. Throughput is the quantity you maximize under those two constraints, never a target on its own.
  2. Profile prefill and decode as separate phases. Prefill is compute-bound and grows with prompt length; decode is memory-bandwidth-bound and grows with KV cache size. A change that helps one often hurts the other, so measure them apart. Chunked prefill caps how much a long prompt preempts live decodes.
  3. Budget the KV cache in bytes. Per token, KV bytes are 2 x layers x kv_heads x head_dim x dtype_bytes. Multiply by max sequence length and by concurrent sequences: at long context that product, not the weights, is what fills an 80 GB H100 and sets how many requests fit.
  4. Enable paged attention so uneven sequences share the pool. Allocating the KV cache in fixed blocks (vLLM PagedAttention, commonly 16 tokens per block) removes the per-slot worst-case reservation that fragments memory. That is what lets a large continuous batch actually reside on the card.
  5. Run continuous batching, not static batches. Admit and retire sequences every decode step rather than waiting for a fixed batch to drain. When output lengths vary widely, which is the normal case for chat, this keeps the GPU fed instead of stalling on the one request still generating.
  6. Quantize the cache only after you have profiled. An FP8 or INT8 KV cache roughly halves decode memory and lifts the concurrency ceiling; AWQ or GPTQ weights free more room for KV. Confirm quality on your eval set first, since each trades a little accuracy for headroom.
  7. Ramp concurrency until p99 bends, then back off one step. Plot latency percentiles against in-flight requests. Throughput climbs then flattens while p99 rises: the largest concurrency that still meets both SLOs is your operating point, and it came from the curve, not intuition.

Litmus tests

  • Can you name your TTFT and inter-token targets with a percentile attached?
  • Do you know how many concurrent sequences the KV cache holds at max context?
  • Under load, does GPU utilization clear 80 percent while p99 stays in budget?
  • Did a percentile-versus-concurrency curve, not a hunch, set the batch size?

Boundaries

This is scheduler-level and memory-level tuning of one serving replica. Picking and configuring a specific runtime is vllm-serving; graph compilation and kernel precision on the model itself is tensorrt-optimization. Autoscaling replicas and routing traffic across them is a cluster concern this skill does not cover.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 327,069. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.