Skip to content
Skills Library
AI & agents · Analysis

inference-serving-optimization

/inference-serving-optimization

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.

Repository
AI-SKILLS ↗
Licence
MIT
Last repository change
05.09.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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.

Original author description

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.

How it works

  1. Method
  2. Litmus tests
  3. Boundaries
Original SKILL.md headings · 54 lines, 517 words
SKILL.md preview
---
name: inference-serving-optimization
description: 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.
---

# 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.

Versions

The database has no other skills named inference-serving-optimization.

Database snapshot: 13.11.2026 · package version 66ce993a9c87 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100paged-attention
    Use this skill when the user says 'pagedattention', 'paged attention', 'kv cache', 'kv cache memory', 'vllm memory', 'block table', 'prefix caching', 'continuous batching', 'gpu-memory-utilization', 'preemption'. Explains PagedAttention KV-cache management (fixed-size blocks,…
  • 95llm-kv-cache-paged-attention
    Use this skill when the user says 'KV cache', 'PagedAttention', 'vLLM memory', 'gpu_memory_utilization', 'prefix caching', 'max concurrent sequences', 'KV cache size', 'context length OOM'. Explains KV cache memory math and how paged allocation, prefix caching, KV quantization,…
  • 100tune-model-serving-aks
    Tune Model Serving AKS — optimize GPU utilization, quantization level, batch size, spot node pools, auto-scaling rules, cost per inference. Use when: tune, optimize, reduce cost.
  • 95inference-engineering
    Make architecture, performance, and production decisions for serving generative AI models. Use when selecting models or hardware, diagnosing latency or throughput, optimizing LLM or multimodal inference, benchmarking, scaling GPU services, or estimating serving cost.
  • 100model-serving
    Tunes deployed LLM inference servers (vLLM, SGLang, TensorRT-LLM) for latency and throughput. Use when TTFT or p99 latency regresses, a benchmark disagrees with production, sizing GPUs or replicas for an SLO, tuning KV cache, max-model-len, batching or prefix caching, or…
  • 90model-inference-optimize
    优化实际模型推理链路,将正确性对齐、分段 profiling、显存与数据搬运、TensorRT/ONNX/PyTorch 后端、attention/kernel、FP8/compile、缓存与少步采样、质量回归、GPU 成本和服务验收串成同一实验闭环。当用户要求推理提速、降低显存或 GPU 成本、复现模型效果、定位 GPU 利用率低、优化图像/视频/扩散模型或自托管 LLM 时使用,提供 model inference performance optimization 的脱敏案例。纯 API 调用、提示词或 token 用量优化,以及电脑卡顿,不进入本技能的模型推理实验流程。

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.