LLM Inference Degradation in Production: KV-cache, OOM, and the p99 Tail
vLLM
Meta
NVIDIA
Hugging Face
Anyscale
Ray Serve
Text Generation Inference (TGI)
FasterTransformer
Production LLM inference often degrades gradually due to KV-cache fragmentation, OOM on long contexts, head-of-line blocking, and p99 latency spikes. VK Cloud evangelist Stas Pogorzhelsky explains four mechanisms causing performance decay and offers reproduction scripts and metrics to catch issues before incidents.
VK Cloud technology evangelist Stas Pogorzhelsky explains that production LLM inference usually degrades gradually rather than failing immediately. He identifies four key mechanisms: KV-cache fragmentation causing 60-80% memory loss, OOM on long contexts, head-of-line blocking in batches, and p50/p99 metric divergence. The article provides reproduction scripts and metrics to catch issues before incidents. It highlights that KV-cache often exceeds model weights in production. PagedAttention reduces fragmentation to less than 4% and boosts throughput 2-4x, but external fragmentation and eviction still cause issues over time. Continuous batching can cause head-of-line blocking when a long prefill request delays shorter ones; chunked prefill mitigates this. FP8 quantization of KV-cache nearly doubles effective memory capacity compared to FP16. Monitoring trends in cache usage and peak KV rather than waiting for OOM is advised.
- Abbreviations
- KV = Key-Value — ключ-значение
- OOM = Out of Memory — нехватка памяти
- p99 = 99th Percentile — 99-й перцентиль
- TTFT = Time to First Token — время до первого токена
- A100 = NVIDIA A100 GPU — графический процессор NVIDIA A100
- GPU = Graphics Processing Unit — графический процессор
- MHA = Multi-Head Attention — многоголовое внимание
- GQA = Grouped Query Attention — групповое внимание по запросам
- FP8 = 8-bit Floating Point — 8-битная плавающая точка
- FP16 = 16-bit Floating Point — 16-битная плавающая точка
Source: Habr — хаб ИИ —
original
