arXiv(opens in a new tab)cs.CLOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.06479

Behavior-Preserving KV Cache Compression

Doo Hwan Hwang, Junyoung Jang, Junho Na, Hosung Lim, Kee-Eung Kim

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

KV caches are a major bottleneck in long-context inference and long-form generation with large language models. Existing training-free eviction policies largely rely on proxy importance signals, such as attention mass, to decide which past tokens to retain. We argue that cache compression should instead preserve the predictive behavior of the full-cache model, retaining entries whose removal would substantially change the model's output distribution. We propose Behavior-Preserving KV Cache Compression, a training-free framework that scores candidate evictions by estimating the compressed-cache logits induced by their removal and evaluating the resulting KL to the full-cache next-token distribution. Using pre-eviction forward statistics, the method avoids running separate masked forward passes for each candidate. Across diverse architectures and both prefill-time and generation-time compression, our method delivers substantial gains in downstream task quality over lightweight attention-based heuristics at matched retained-KV budgets, with the largest gains under aggressive compression. It achieves these gains with additional compression-time computation while retaining an end-to-end speedup over full-cache inference in our evaluated settings.

1 Introduction

Large language models (LLMs) rely on key-value (KV) caches during autoregressive decoding to avoid recomputing past activations (Zhang et al., 2023; Devoto et al., 2025). As sequence lengths grow, these caches scale linearly with the number of processed tokens and become a major bottleneck for memory usage and attention computation (Liu et al., 2023; Li et al., 2024; Zhang et al., 2023). KV cache compression reduces this cost by retaining only a subset of cached key-value entries. We focus on training-free cache management, where the eviction rule is computed from inference-time statistics rather than learned from task-specific traces or optimized through additional cache-policy training. This setting is attractive for deployment because it can be applied to off-the-shelf LLMs across different budgets, context lengths, and tasks without training an auxiliary eviction policy.

In this setting, the natural reference is the behavior of the same model before eviction. A compressed cache should therefore not merely satisfy a memory budget; it should preserve the predictive behavior of the pre-eviction computation. Since future decoding states are unavailable when compression decisions are made, we use the next-token distribution at available query positions as an observable reference behavior.

Existing training-free methods approximate this goal through indirect proxy signals. Attention-based methods retain entries that receive high attention in the current context (Liu et al., 2023; Li et al., 2024; Zhang et al., 2023) or are expected to receive high attention during future decoding (Devoto et al., 2025). Other methods favor entries that help reconstruct the original context from the compressed cache (Kim et al., 2025). These proxy objectives need not match the predictive effect of eviction: attention can overvalue redundant entries, while reconstruction utility can favor context recovery rather than preserving the next-token distribution. This mismatch motivates scoring cache entries by their estimated effect on model predictions.

We propose a behavior-preserving framework for KV cache compression. Our method scores candidate evictions by estimating their effect on the full-cache next-token distribution. It estimates the compressed-cache logits induced by eviction from pre-eviction forward statistics using a residual-path approximation, and plugs the estimated logits into a KL objective against the full-cache prediction. This avoids candidate-specific masked forward passes while ranking entries by their predicted behavioral effect.

We evaluate the method in two inference settings. In prefill-time compression, the prompt cache is compressed after long-context encoding. In generation-time compression, generated-token caches are compressed online during autoregressive decoding. Across models, datasets, and cache budgets, our method delivers substantially higher downstream task quality than lightweight attention-based eviction methods at matched retained-KV budgets, particularly under aggressive compression. Its behavior-preserving scoring incurs additional compression-time computation, while the resulting compressed inference remains faster than full-cache inference in our evaluated settings.

Our contributions are as follows:

• We recast training-free KV cache compression as behavior-preserving eviction, evaluating cached entries by their predicted effect on the full-cache next-token distribution rather than by proxy signals such as attention mass or reconstruction utility.

• We introduce a forward-only scoring method that estimates compressed-cache logits from pre-eviction forward statistics and evaluates their KL to the full-cache prediction, without candidate-specific masked forward passes.

• We provide a broad evaluation in both prefill-time and generation-time compression settings, showing that behavior-preserving scoring yields stronger compression-performance trade-offs, especially under aggressive cache budgets.

References (33)

  • Zefan Cai, Yichi Zhang, Bofei Gao, Yuliang Liu, Yucheng Li, Tianyu Liu, Keming Lu, Wayne Xiong, Yue Dong, Junjie Hu, and Wen Xiao. 2025b. Pyramidkv: Dynamic kv cache compression based on pyramidal information funneling. Preprint, arXiv:2406.02069. (opens arXiv in a new tab)
  • Alessio Devoto, Maximilian Jeblick, and Simon Jégou. 2025. Expected attention: KV cache compression by estimating attention from future queries distribution. CoRR, abs/2510.00636. (opens arXiv in a new tab)
  • Gemma 3 Technical Report
  • The Llama 3 Herd of Models
  • Qwen3 Technical Report
  • Let $\mathcal{I}_t \subseteq \{1, \ldots, S\}$ denote the cache positions visible to query $t$ under the causal mask
  • The full-cache projected head output is
  • The removed attention mass and removed projected contribution are
  • Removing masked entries deletes their attention terms and renormalizes the retained attention weights by the retained mass $1 - A_{\ell rt}(d_{\ell})$
  • Responses of later attention, MLP, and normalization layers are treated as approximation error in the main residual-path surrogate
  • We keep this directly written component as a tractable proxy for the candidate-induced final-state perturbation
  • We then form the estimated compressed-cache logits
  • It differs from the true masked-cache KL only in replacing the exact compressed-cache logits with residual-path estimated logits
  • All validation scores are evaluated on the same layer-token eviction masks
  • These comparisons isolate the effect of moving from attention scores to attention-output errors, from local errors to predictive-distribution scoring, and from additive singleton evaluation to mask-level evaluation
  • We rank masks by each score, divide them into quantiles, and report the mean exact masked-cache KL $\mathcal{J}_{\text{true}}(d)$ in each quantile, together with Spearman rank correlation
  • The LM-head bias, if present, does not appear in the perturbation because it cancels when taking logit differences
  • $K$ is the top-$K$ support size used for KL evaluation
  • For $n \times$ generation-time compression, the eligible generated-token cache is kept approximately $n$ times smaller than the uncompressed eligible cache
  • Unless otherwise stated, baseline hyperparameters follow the settings recommended in the original papers and their corresponding KVPress implementations
  • For head-wise methods, this set may differ across KV heads
  • SnapKV and PyramidKV use their observation windows for attention-based scoring and retain the observation-window entries according to their KVPress implementations
  • Here, $\rho$ denotes the fraction of evicted KV entries, and Full denotes the uncompressed KV cache
  • We therefore evaluate on RULER 8K and report Decode Mem., the peak allocated GPU memory during answer generation after the compressed prompt cache has been materialized
  • At matched retained-KV budgets, our method preserves substantially more task quality at a higher compression-time cost
  • $\Delta$ Score is relative to full-cache decoding
  • Peak allocated memory includes model parameters and runtime buffers, whereas retained prompt-KV memory isolates the materialized cache after compression
  • ><tr><td rowspan=
  • RULER uses LLaMA3.1-8B at $\rho = 0.75$; MATH500 uses DeepSeek-R1-Distill-Qwen-7B under $12\times$ compression
  • Unless otherwise specified, all other hyperparameters are fixed to the prefill-time defaults in Table 3
  • Unless otherwise specified, all other hyperparameters are fixed to the generation-time defaults in Table 3
  • Our use is consistent with their intended research and evaluation purposes
  • We used ChatGPT, an AI language model developed by OpenAI, solely as a writing aid to enhance the clarity and readability of our manuscript