Manuscript Offprint

arXiv:2611.07605

The Gating Mechanism of KV Cache Eviction

Hao Gu, Xintong Yang, Zhiwei Li, Lei Zhu, Jian Yang, Qiyuan Zhu, Dezhi Li, Jingyuan Zhang, Zhizhuo Kou, Hao Wang, Bei Liu, Jiacheng Liu, Sirui Han

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

Hao Gu¹*, Xintong Yang²*, Zhiwei Li³, Lei Zhu⁴, Jian Yang¹, Qiyuan Zhu¹, Dezhi Li¹, Jingyuan Zhang⁵, Zhizhuo KOU¹, Hao Wang⁶, Bei Liu¹, Jiacheng Liu⁷ and Sirui Han¹,†

¹The Hong Kong University of Science and Technology, ²New York University, ³The Hong Kong University of Science and Technology (Guangzhou), ⁴Tencent HunYuan, ⁵Georgia Institute of Technology, ⁶City University of Hong Kong, ⁷Shanghai Jiaotong University

Code: IndexMem++ Checkpoints: Hugging Face

Abstract: KV cache eviction must decide which entries carry information that the rest of the cache can no longer supply. A natural way to estimate this is a learnable gate: give each cached entry a gate on its attention weight and train the gate on the model's own objective. The gate belongs inside the normalizing softmax, where suppressing one entry hands its mass to the others rather than discarding it. That same normalizer absorbs any per-query constant, so a constant gate cancels and reproduces the frozen model exactly. Trained on the language-modeling loss the gate stays near a constant score while its loss falls throughout: optimization succeeds, but a frozen backbone was fit for dense attention, so its loss prefers the no-op, and a near-constant score ranks nothing. The no-op is not a floor the gate improves from but what its objective asks for. A second obstacle survives once the gate moves, since the same gradient charges the gate for errors the frozen model already makes, which no reweighting of positions separates out. Much of the machinery in learnable eviction, from sparsity penalties to relaxations of the discrete decision, works around the first obstacle rather than removing it; both are removed by putting dense attention beyond the gate's reach and making the dense model's predictions its target. Under these two conditions capacity is never the missing ingredient: neither a larger scorer, nor explicit access to the past, nor a trainable backbone helps. The same holds for what eviction unavoidably discards, which is recovered by parameter-free centroids read inside the same softmax far better than by any memory read outside it, since the mass they must return is a share of that normalizer and available nowhere else. At 75% KV cache compression, this gate reaches 90.14 on RULER at 8K and 46.03 on LongBench with Qwen3-8B, 3.72 and 1.36 points below full-cache inference.

1. Introduction

Large language models are evolving from chatbot assistants (Touvron et al., 2023) into long-horizon agents (Yao et al., 2023). These agentic workloads naturally induce long interaction histories, making efficient long-context inference essential. During autoregressive decoding, the KV cache is increasingly the main bottleneck. As the cache grows linearly with sequence length, KV-cache storage and data movement become the dominant systems bottlenecks (Kwon et al., 2023). Reducing this footprint has therefore become a central objective in efficient LLM inference. Existing approaches compress KV cache along several axes: quantization reduces precision (Liu et al., 2024), cross-layer sharing reduces number of layer-specific KV (Sun et al., 2024b), and latent representations reduce KV dimension (DeepSeek-AI, 2024). These approaches are complementary and can be combined. In this work, we focus on KV eviction because it not only reduces memory consumption but also shortens the effective sequence length of attention, thereby reducing attention computation. KV eviction is possible because information becomes redundant across the cache. Through causal self-attention, each hidden state aggregates preceding context, allowing later KV entries to carry information originally introduced by earlier tokens. This layer-wise propagation explains why sliding-window attention can access information beyond its explicit window (Fu et al., 2025).

However, this propagation is incomplete: isolated facts such as passwords or retrieval keys may remain unique to their original entries. Effective eviction must therefore distinguish two kinds of entries: those whose information can be recovered from the rest of the cache, and those that carry the only copy of what they contribute. Sparse attention and KV eviction appear similar because both select a subset of KV entries, but their objectives differ. Sparse attention selects entries relevant to the current query; eviction must identify entries that are redundant regardless of future queries. Existing eviction methods however often treat relevance as redundancy. H₂O and SnapKV use attention from previously observed queries (Zhang et al., 2023; Li et al.,

*Equal contribution. †Corresponding author: Sirui Han. Contact: marcusguhao@gmail.com.

2024). Relevance can serve as a partial proxy for redundancy, but does not measure it directly.

We instead define redundancy relative to the retained cache: an entry is redundant if its information can be recovered from the other KV entries that remain. Hand-crafted measures such as cosine similarity (Park et al., 2026; Cai et al., 2025) capture only limited aspects of this relationship. We therefore learn a lightweight, query-independent gate that maps each contextualized hidden state to a retention score for each KV head. And where that gate is attached is not a free choice. Attention weights are shares of one softmax normalizer, so only a gate inside that normalizer hands a suppressed entry's mass to the remaining entries, which is what removal means.

Naively training this gate does not work: it learns nearly identical retention scores for all tokens, reproducing dense attention without learning which entries can be evicted. The reason is structural and it comes from the same normalizer that gives the gate its meaning. Because a softmax absorbs any per-query constant, a constant score cancels inside it and is a no-op, and a frozen backbone's loss prefers exactly that. The gate must therefore be denied dense attention and asked to match the dense model's predictions instead of the next token. The same invariance also bounds what a score can say: it ranks entries within a head but cannot compare heads, so the division of budget among them must be settled outside the score.

Even accurate retention scores cannot make hard eviction lossless: retained entries may preserve part of an evicted entry's information, but not all of it. We find that discarded entries still receive substantial attention mass, motivating a compact mechanism for recovering their residual contribution. Our key finding is that the readout of this compressed information matters more than the capacity of the memory that stores it, and the reason is the normalizer again. Recovering the missing contribution requires both its direction and the fraction of attention mass it holds, and that fraction is a ratio of softmax denominators: it is available exactly where the gate was, and only estimable indirectly anywhere else. A memory read outside attention must learn that calibration in output space and does not improve as it grows, whereas parameter-free centroids of the evicted keys and values, inserted into the cache and weighted by the same softmax as the retained entries, recover it far more closely. Removal and restoration are thus the same statement about where the normalizer applies. We instantiate these findings in IndexMem++, which follows a two-branch design (Yang et al., 2026), summarized in Figure 1: a selection branch evicts redundant KV entries, and a recovery branch summarizes what was evicted, both reading through one softmax. Experiments on Qwen3-4B and Qwen3-8B show consistent gains across long-context understanding and mathematical reasoning. At 75% compression, IndexMem++ reaches 90.14 on RULER with Qwen3-8B and 46.03 on LongBench, within 1.36 points of Full-KV, and it retains 0.807 pass@1 on Math500 with a 512-entry cache. Section 4 reports the full comparison.

Figure

Figure 1: The two branches of IndexMem++: evict and recovery both inside one softmax.

References (59)