Seedlabs
Source research

The KV Cache Working Set: Online Capacity Planning for LLM Inference Systems

Luchang Li, Shuaishuai Wang, Zhao Ruan, Dongfang Li, Bozhao Gong · 2026 · 2 citationsRead the paper

Prefix caching is critical for efficient large language model (LLM) serving, particularly for agentic workloads that repeatedly invoke the model with a growing conversation and tool-use history. By reusing the key-value (KV) states of previously processed prefixes, prefix caching avoids redundant prefill computation. Its effectiveness, however, depends on retaining a sufficiently large set of KV cache states. Provisioning enough cache to preserve all historical KV states is prohibitively expensive and often unnecessary, whereas insufficient capacity can substantially degrade the cache hit rate. Determining the KV cache working set, defined as the minimum cache capacity required to achieve a target hit rate, is therefore essential for efficient cache provisioning and system design. We present KVSET, an online analyzer that estimates the KV cache working set of LLM serving workloads. KVSET uses the Mattson stack algorithm to efficiently estimate cache hit rates across a wide range of cache capacities. For each KV cache page, KVSET computes its LRU stack distance and compares it with the page number of each candidate capacity. This comparison determines whether the page would be a hit at each capacity without independently simulating every capacity configuration. KVSET therefore substantially reduces the computational and memory overhead of conventional capacity-by-capacity simulation and makes online working-set analysis practical. KVSET further determines the minimum cache capacity based on the maximum LRU depth among the prefix pages required to achieve the target hit rate. We validate KVSET using traces collected from production LLM workloads and show that its estimates closely match measurements from real cache deployments. The open-source implementation supports both online request processing and offline trace replay.

What the full text shows

Working prototype
  • Required KV cache capacity for 95% request coverage — approximately 1 TiB (Production coding-agent workload trace)
  • Required KV cache capacity for 99% request coverage — approximately 5 TiB (Production coding-agent workload trace)
  • Required capacity for 99.9% coverage — did not converge (Observed trace of 24,000 requests)
  • KV cache storage per token — approximately 60 KB (SGLang, GLM-5.2 model, FP8 quantization)
Setup
Evaluated using traces of 10,000 and 24,000 requests from a production coding-agent workload on NVIDIA H20 GPUs using GLM-5.2 (W4A8 quantization, FP8 KV cache).
How
KVSET uses the Mattson stack algorithm combined with a Fenwick tree to compute LRU stack distances for KV cache pages. This allows the system to estimate hit rates across multiple cache capacities from a single trace replay without simulating each capacity independently.
Limitations
Only supports caches using LRU eviction policies · Currently estimates capacity only for the full-attention component of models · Does not natively account for linear attention or sliding-window attention (SWA) states

Summarized by Gemma 4 from the open-access full text · 22 Nov 2026. Read it