Best practices for managing KV-cache memory overhead in open-source LLM inference toolchains

Hi everyone,

I’m currently working on benchmarking and optimizing open-source inference pipelines using vLLM alongside hardware-accelerated backends, and I wanted to see how other developers approach memory management under heavy concurrent request loads.

When handling mixed workloads—specifically balancing prefill phases for new prompts with continuous batching and decode phases for active sequences—the KV-cache memory footprint can scale rapidly, occasionally introducing bottlenecks during extended generation windows.

For teams deploying large open-weight models on modern accelerator stacks, what configuration strategies or paging adjustments do you rely on to maximize token throughput without sacrificing latency?

Would love to hear any architectural insights or profiling tips from your experience!

1 Like

Hello,

The biggest lever is more about the model and not the paging. DeepSeek-V4.1-Flash stores about 890 bytes of KV per token, so a full 1M context fits in under 1GB. Within vLLM, --kv-cache-dtype fp8 roughly halves whatever cache you have, and --max-num-batched-tokens sets the prefill chunk size: lower values smooth decode latency under load, while higher ones favour prefill throughput but take memory from the KV pool. Hope this helps, and wish you the best of luck :smiley:

One diagnostic step before more scheduler tuning: watch KV-cache usage, the preemption rate, and the waiting queue under a fixed workload. In vLLM V1, cache pressure can trigger preemption and recomputation, worsening latency. If that is frequent, I would test a lower --max-num-seqs while keeping the offered load and prompt/output lengths unchanged. Optimization guide

With few preemptions, rising latency alone would not establish a KV-capacity problem. I would compare throughput against p95 time to first token, p95 inter-token latency, and queue time while changing one setting at a time. The /metrics endpoint exposes cache usage, waiting requests, preemptions, and latency histograms. Production metrics

What model, prompt/output length distribution, and concurrent-request level are you targeting?

One thing I’d check before changing more scheduler settings is how many tokens are actually sitting in the cache.

For conventional full attention with GQA on one GPU, without tensor parallelism or shared prefix blocks, the rough K/V payload is:

2 × layers × KV heads × head dimension × bytes per value × total live tokens

That last number includes the prompt and generated tokens still held across active sequences. With 32 layers, 8 KV heads, a head dimension of 128 and BF16 storage, it works out to 128 KiB per token. Eight sequences holding 8,192 tokens each would need about 8 GiB for K/V alone. Weights, workspaces, block rounding and other overhead are additional. MLA, sliding-window attention and hybrid models need different calculations.

If your vLLM version supports it, --kv-cache-memory-bytes lets you set the per-GPU cache budget explicitly. It overrides the cache budget inferred from gpu_memory_utilization, so it isn’t extra memory on top of that budget. Leave room for the other allocations and check the actual cache capacity reported at startup. vLLM documentation

Which vLLM version and cache dtype are you using, and what GPU cache capacity does the startup log report?