The KV Cache Working Set: Online Capacity Planning for LLM Inference Systems
Luchang Li, Shuaishuai Wang, Zhao Ruan, Dongfang Li, Bozhao Gong
Abstract
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.
Create a lesson
Metadata
- Comments
- 9 pages, 4 figures
Related papers
ModelLess: A Serverless System for Multi-Tier LLM Inference on Shared GPUs
Shared title terminologycs.DCDing Shi, Wei Wu, Jiayuan Chen et al.
Norn: Context-Length-Aware Optimization of Weight and KV Cache Placement for Offloaded LLM Inference
Shared title terminologycs.DCNaoto Sugiura, Hiroki Matsutani
CCAMoE: Cache-Conditioned Adaptive Inference for Offloaded MoE
Shared title terminologycs.DCXuan Zhang, Haisheng Tan, Han Tian et al.
EfficientAgent: What Makes KV Cache Offloading Work for Concurrent Agents?
Shared title terminologycs.DCKunming Shao, Jierun Chen, Jiangnan Yu et al.
Who Pays for the KV Cache? Attributing Shared AI Inference Spend Across Kubernetes and LLM Provider Bills
Shared title terminologycs.DCTimothy Urista
Shared KV Caching for Replicated 27B Inference: Correctness Failures and Performance Boundaries
Shared title terminologycs.DCFrank Li