OBCache: Optimal Brain KV Cache Pruning for Efficient Long-Context LLM Inference

Yuzhe Gu, Xiyu Liang, Jiaojiao Zhao, Enmao Diao

Large Language Models (LLMs) are increasingly capable of processing massive context windows, but they face a severe "memory wall." To generate text autoregressively, LLMs must store the Key-Value (KV) states of every previous token. This cache grows linearly with sequence length and batch size. For instance, a LLaMA-3.1-8B model processing a 1M-token context requires over 120GB of VRAM—far exceeding the capacity of a single high-end GPU.

To mitigate this, researchers employ KV cache eviction, discarding "unimportant" tokens to maintain a manageable cache size. However, current methods (such as H2O or SnapKV) rely on simple heuristics, typically accumulating attention weights. These heuristics are fundamentally "output-blind": they fail to account for the actual information contained in the Value states or how significantly the final attention output changes when a token is removed.

The OBCache Solution: Output-Aware Saliency

To address the limitations of heuristic eviction, the authors introduce OBCache (Optimal Brain Cache). OBCache formalizes cache eviction as a layer-wise structured pruning problem, drawing inspiration from the classic Optimal Brain Damage (OBD) neural network pruning theory.

Instead of relying solely on attention weights, OBCache asks a fundamental question: "If this token is deleted, how much will the attention output ($O = AV$) actually change?"

Using a second-order Taylor expansion, the framework derives three specific, closed-form saliency scores:

  1. Value-Pruning Score ($S^{value}$): Measures the impact of removing a value vector by scaling attention weights against the norm of the value state.
  2. Key-Pruning Score ($S^{key}$): Measures the impact of removing a key. This is inherently more complex, as altering a key shifts the entire attention distribution (the softmax).
  3. Joint-Pruning Score ($S^{joint}$): Accounts for the interactive, simultaneous effects of removing both the key and the value.

Crucially, these scores are output-aware. By incorporating attention logits, value norms, and the current attention output, they provide a mathematically grounded estimate of a token's importance, far surpassing raw attention weights.

Experimental Validation

The researchers evaluated OBCache by integrating it into four popular baseline methods (H2O, TOVA, SnapKV, and AdaKV). Testing spanned rigorous benchmarks, including RULER (synthetic long-context retrieval/reasoning), LongBench (real-world tasks like QA and summarization), and PG19 (language modeling for perplexity measurement).

Key Insights and Results

  • Heuristics as Special Cases: The paper mathematically proves that existing methods like H2O and TOVA are essentially simplified, "output-blind" variants of the broader OBCache framework.
  • Keys Dictate Sensitivity: Pruning keys generally causes more disruption than pruning values, as keys define the relational mapping between tokens. OBCache’s key-aware scores proved highly effective at preserving accuracy, particularly in retrieval-heavy tasks.
  • Superior Query-Agnostic Performance: OBCache excels in "query-agnostic" settings—where the cache must be compressed before the user's prompt is fully known (e.g., multi-turn chats). When paired with AdaKV, OBCache delivered up to a 15% accuracy boost over baselines.
  • State-of-the-Art Trade-offs: Across LLaMA-3.1 and Qwen-2.5 models, replacing heuristic scores with OBCache consistently improved performance. On LLaMA-3.1-8B (RULER-4K), OBCache maintained high accuracy even when discarding 70-90% of the KV cache.
  • Negligible Overhead: Despite the rigorous math, the closed-form solutions are highly optimized. The value-pruning variant adds less than 2ms of latency, and the key-pruning variant adds less than 15ms—both significantly faster than computing full-context attention.

Limitations and Future Work

While OBCache sets a new standard for KV cache eviction, it shares a common limitation with other methods: a structural bias toward earlier tokens (attention sinks). Although recent-window heuristics mitigate this, dynamic handling of this bias remains an open challenge. Additionally, tuning the "perturbation window" (the number of recent queries evaluated for saliency) requires careful hyperparameter selection.

Looking forward, the authors suggest extending this pruning framework to channel-wise pruning (removing specific dimensions of the KV vectors) or cache merging, where discarded token information is compressed into remaining tokens rather than being entirely deleted.

Summary updated

BibTeX
@inproceedings{gu2026obcache,
  author = {Yuzhe Gu and Xiyu Liang and Jiaojiao Zhao and Enmao Diao},
  title = {{OBCache: Optimal Brain KV Cache Pruning for Efficient Long-Context LLM Inference}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=f58VZpG6ls},
}
Figure