Behavior-Preserving KV Cache Compression

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

TL;DR

Behavior-Preserving KV Cache Compression moves beyond simple heuristics like "attention mass" to decide which tokens to keep in an LLM's memory. By estimating the actual impact of token eviction on the model's output distribution (using KL divergence), this training-free method maintains high task performance even when discarding up to 90% of the KV cache, significantly outperforming existing attention-based methods.

What Problem Does This Paper Address?

As Large Language Models (LLMs) tackle longer sequences, the Key-Value (KV) cache—which stores past activations to avoid redundant computation—becomes a massive bottleneck. It grows linearly with sequence length, eventually exhausting GPU memory and slowing down attention calculations.

To manage this, researchers use "eviction policies" to prune the cache. Most current training-free methods rely on proxy signals, such as retaining tokens that receive the most "attention mass." However, the authors argue that attention is a poor proxy for predictive importance. A token might be heavily attended to but ultimately have little impact on the model's final output distribution. The challenge is to find a way to prune the cache that preserves the model's original behavior without the prohibitive cost of running a new forward pass for every potential pruning candidate.

Methods

The authors propose a framework that scores cache entries by their estimated effect on model predictions. The goal is to minimize the KL divergence between the full-cache next-token distribution ($p$) and the compressed-cache distribution ($q$).

To make this computationally feasible during inference, they introduce several clever approximations:

  1. Residual-Path Approximation: Instead of re-running the model, they estimate how removing a token at a specific layer perturbs the "residual stream" (the main highway of data in a Transformer). They sum these perturbations across layers to estimate the total change at the final layer.
  2. Logit Perturbation Estimation: They use a first-order Taylor expansion (specifically, the Jacobian of the final normalization layer) to map the residual stream perturbation to a change in the final vocabulary logits.
  3. Two-Stage Selection:
    • Singleton Scoring: They first calculate the impact of removing each token individually to create a candidate pool.
  4. Greedy Refinement: They then iteratively select tokens to evict from this pool, accounting for how the removal of one token changes the renormalization of attention for the remaining ones.

This entire process is forward-only and training-free, meaning it can be plugged into off-the-shelf models like LLaMA or Qwen without any fine-tuning.

Datasets

The method was evaluated across diverse architectures and tasks:

  • Models: Qwen3-8B, LLaMA3.1-8B, Gemma3-12B, and DeepSeek-R1-Distill-Qwen-7B.
  • Benchmarks:
    • LongBench: 21 tasks covering QA, summarization, and few-shot learning.
  • RULER: A benchmark for testing long-context retrieval and aggregation at 4K, 8K, and 16K lengths.
  • MATH500 & AIME25: Used specifically to test "generation-time" compression in reasoning-heavy tasks.

Key Insights and Ideas

  • Proxies vs. Behavior: The core "aha moment" is that preserving the output distribution is a much more reliable signal than following attention weights. As shown in Figure 1, the authors' behavior-preserving score has a much stronger correlation (Spearman $r_s \approx 0.90$) with future model behavior than SnapKV ($r_s \approx 0.22$) or Expected Attention ($r_s \approx 0.35$).
Figure 1: Relationship between method-specific proxy scores and KL over future positions on LongBench, MATH500, and AIME25 using LLaMA3.1-8B. For each scoring rule, we group candidate eviction masks by the percentile of the method’s own score and sample perturbed KV caches from each score bin. We then measure the mean KL over future positions along the same reference continuation. The x-axis reports the score percentile. Higher percentiles should correspond to larger KL over future positions if a score captures the predictive effect of eviction. The behavior-preserving score exhibits the clearest association, while the association is less pronounced for proxy-based scores.
  • The Residual Stream is a Good Proxy: Despite the non-linearities in a Transformer (like MLPs between layers), simply summing the direct perturbations in the residual stream provides a surprisingly accurate ranking signal for which tokens are "safe" to delete.
  • Robustness to Aggressive Compression: While most methods perform similarly when keeping 75% of the cache, the gap widens dramatically at 90% eviction. The behavior-preserving approach is much more resilient to these "aggressive" memory budgets.

Key Results

The authors tested the method in two scenarios: prefill-time (compressing the prompt once) and generation-time (repeatedly pruning during long decodes).

  • Prefill Compression: On the RULER 16K benchmark with LLaMA3.1-8B, at a 90% eviction rate ($\rho=0.90$), the proposed method achieved a score of 52.5, compared to just 28.8 for SnapKV and 36.2 for Expected Attention.
Prefill-time compression results across models
  • Generation-time Compression: In reasoning tasks using DeepSeek-R1, the method maintained high accuracy even at 12x compression. For a maximum generation length of 8192, the method scored 80.4 on MATH500, whereas SnapKV dropped to 58.8.
Generation-time compression results on reasoning tasks
  • Efficiency: While the scoring mechanism adds some overhead (e.g., ~1.68s per example for LLaMA3.1-8B at 8K context), the resulting inference is still significantly faster than using a full, uncompressed cache and requires 2.5–3x fewer KV entries than SnapKV to reach the same quality level.

Limitations and Future Work

  • Future Query Blindness: The method scores tokens based on the current available query positions. It cannot perfectly predict which tokens might become important for a query that hasn't been generated yet.
  • Computational Overhead: Although it's faster than full-cache inference, it is more computationally intensive than simple attention-based heuristics.
  • Approximation Limits: The first-order Taylor expansion and residual-path sum are approximations; exploring higher-order terms or more complex propagation could potentially improve accuracy further, albeit at a higher cost.

Summary updated

BibTeX
@misc{hwang2026behavior,
  author = {Doo Hwan Hwang and Junyoung Jang and Junho Na and Hosung Lim and Kee-Eung Kim},
  title = {{Behavior-Preserving KV Cache Compression}},
  year = {2026},
  eprint = {2610.06479},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.06479},
}
Figure