Paper commentary
The Gating Mechanism of KV Cache Eviction
IndexMem++ trains a softmax gate to decide which KV cache entries to evict
- Problem A gate trained on the language-modeling loss collapses to near-constant scores that rank no cache entries. The frozen model was fit for dense attention, so the loss favors this no-op.
- Method IndexMem++ puts a learned per-key gate inside the softmax, unlike gates placed after it. It trains the gate to match the dense model's next-token distribution instead of the one-hot token.
- Results On RULER at 8K with Qwen3-8B at 75% compression, IndexMem++ scores 90.14 against 93.86 for Full-KV.
Why a learned gate stalls
Eviction has to work out which cached entries hold information that nobody else in the cache can provide. A natural estimator is a learnable gate that scales each cached entry's attention weight and is trained on the model's own loss. The catch is where that gate sits, because attention weights are shares of one softmax normalizer. Placed outside the softmax, a gate only scales a value and leaves the key in the normalizer, so the weights don't sum to one.
Adding the same constant to every logit of a query cancels inside the softmax, so a constant gate changes nothing. The loss still fell during training, so the optimizer worked while the scores ranked nothing. Near-constant scores are useless for eviction, because the top-B cut falls among near-ties and the retained set is arbitrary.
A second obstacle appears once the gate does move. The cross-entropy gradient splits into a term caused by eviction and a term from the frozen-backbone error. The gate can reduce only the eviction term, and the frozen-backbone error can dominate at hard, high-entropy positions. Token reweighting can't separate the two, because LongCE still scales both terms together.
Distillation against the dense distribution removes the second term, so the frozen-backbone error never enters the gradient.
The paper's own fix therefore starts by removing the no-op solution, and it's the reason the next steps look the way they do. Holding the always-attended sinks and window at one fixes the scale, so the remaining gates are no longer free. Distillation then lifts the same setup from 44.86 to 58.86.
The idea: a gate inside the softmax, trained against the dense model
An additive per-key logit bias log g_j is the form the authors use, since g_j going to 0 recovers the hard mask. The gate's output is a retention score s_j = f_θ(h_j), and the backbone stays frozen while gradients through the gated attention update θ. The authors keep four attention sinks and a 128-token local window always attended, and these entries fix the scale of the remaining gates.
Under this constraint the gate gives g_ij equal to β times a softmax over the evictable scores, so the scorer has to rank the entries. Because the evictable gates always sum to β, the sparsity is built into training and no sparsity penalty or schedule is needed. This mechanism raises pilot RULER from 4.33 to 44.86 on Qwen3-0.6B. The second change concerns the training target: the gate matches the dense next-token distribution rather than the one-hot token.
The gradient splits into a term caused by eviction and a frozen-backbone error term, and distillation removes the second term. The reverse KL direction the authors adopt lifts the pilot score from 44.86 to 58.86, a gain of 14.00. The gate itself is a two-layer MLP of width 256 on the hidden state, trained on long documents from LongMino.
Experiments on Qwen3-4B and Qwen3-8B confirm that the gate works at full scale. On RULER with Qwen3-8B at 8K and 75% compression, IndexMem++ reaches 90.14 against 93.86 for Full-KV. TrimKV reaches 80.26 in the same setting, and SnapKV falls to 35.13. Among the baselines, the authors contrast relevance-based scoring with redundancy-based scoring on the retrieval tasks.
A single needle is easy to separate from filler, but MultiKey-2 and MultiKey-3 hold 425 and 125 similar distractor records at 8K. The authors also say that the question is unseen during prefill, so no distractor can be ruled out in advance.
How one gated attention step is computed
Attention gives each cached entry a weight that is its share of one shared normalizer. Writing the gated weights as a(g) with a gate g on each key makes the renormalization explicit. With a binary gate and at least one retained entry, this equals attention over the retained set. A gate placed after the softmax scales a value and leaves the other weights alone, so the key still counts in the normalizer.
IndexMem++ uses a per-key additive bias on the logits, because adding log g_j multiplies the unnormalized weight by g_j. The paradigm is a softmax over the scaled query-key logits plus log g, with s_j = f_theta(h_j) and log g_j = s_j. The function f_theta maps each contextualized hidden state to a per-KV-head retention score. During training the backbone is frozen, and only theta receives gradients through the gated attention.
At inference the scores only decide which entries stay, and the soft gates aren't applied to attention over the retained entries.
The evictable set E_i shares a fixed mass beta with beta much smaller than |E_i|, while the protected set P_i keeps gate one. Because the evictable gates sum to beta at every step, beta is the sparsity used in training. So no sparsity penalty or schedule is needed, and this step raised pilot RULER from 4.33 to 44.86.
The retention rate adds a learned lifetime to each score, as m_j plus log beta_j times (i minus j) over tau, with log beta_j at most zero. The gate's effect still depends only on the hidden state, so it stays independent of future query content. Because the ranking shifts with the current position i, an entry that gets evicted is never revisited.
Turning the retention rate off reached 69.27, compared to 67.60 with it on.
What each pilot step contributes to the score
The pilot starts from a token-local scorer trained on the language-modeling loss, and that setup collapses to nearly constant scores. The authors argue the constant score is a no-op that the objective prefers, since the frozen backbone was fit for dense attention. Always attending the sinks and a local window fixes the scale of the remaining gates, and the evictable entries must share a fixed total mass beta.
This change raises the pilot RULER 8K average from 4.33 to 44.86, as shown in Table 1.
Replacing the language-modeling loss with reverse-KL distillation against the dense model adds 14.00 points, from 44.86 to 58.86. The cross-entropy loss mixes the eviction error with the frozen-backbone error, so the distillation target removes the second term. In the loss ablation, the LM loss (CE) gives an average of 51.50 and LongCE gives 53.01, while reverse KL reaches 67.60.
Forward KL reaches 66.84 and reverse KL with 0.1 CE reaches 67.33, so the reverse KL reference sits slightly above both alternatives.
Head budgets then move the average from 58.86 under a uniform split to 67.60 under the retained-mass allocation. The allocator reads the retained attention mass, because adding a constant to one head's scores does not change that quantity. An offline budget table reaches 62.33, so the online allocation beats a fixed table in this pilot.
They measure the design choices under this short training, so they don't show how the gaps behave at longer training.
Head budgets and scorer design
Retention scores can't be compared across heads, because adding a constant to one head's scores only shifts that head's normalizer. The paper therefore reads the budget off the attention mass each head keeps, since that quantity doesn't move under the shift. For each head, the allocator orders the evictable entries by retention score and sums the attention mass of its top k entries, including sinks and window.
It then gives every head the smallest k_h that reaches a shared mass target rho star, adjusting rho star and any integer remainder so the total equals the uniform baseline's budget. The allocation runs online from the final prefill query, so it follows the current context, which an offline table can't do. On the pilot, this raises the average from 58.86 under a uniform split to 67.60.
The authors conclude that the hidden state already holds the history needed to estimate redundancy. The scorer uses a two-layer MLP applied directly to the hidden state, and a per-key retention rate ties the score scale to entry age, as in TrimKV.
Training the backbone jointly with the gate lowers eviction performance, which the authors trace to decalibration rather than to backbone damage. The authors attribute the drop to changed representations decalibrating the scorer, which is why the backbone stays frozen.
Recovering what eviction discards
Eviction isn't lossless, because the retained entries can't carry all of an evicted entry's information. Dense attention gives o as (1−ρ)o_S + ρo_E, while eviction returns o_S alone, so the error is ρ(o_E−o_S). The authors measured ρ≈0.2, so the missing share isn't negligible.
Recovery needs two quantities, and they aren't equally accessible to the model. The mass ρ is a ratio of softmax normalizers, so it's available where the gate sits and only indirectly elsewhere. Because o_E pools many entries, a fixed-size memory looks like the natural summary. Both are read afterwards as α(q)o_S + β(q)m_E(q), which is the readout outside attention.
The memory's storage isn't the bottleneck, because the problem is where it is read. A memory that recovers o_E exactly would still need α = 1−ρ and β = ρ. A fusion placed after the softmax can't get either value from Z_S and Z_E, so it must learn the calibration indirectly in output space. The key, then, is to read the summary through attention's softmax.
Centroid KV clusters the evicted entries and averages each cluster into a centroid key and value. The R centroids are appended to the retained cache, and the logit q_i k_c/√d + log n_r sets each centroid's weight.
The authors link the larger Math500 gain to preserving information built up over a long chain of thought. NIAH, in contrast, depends on keeping the correct evidence entry, which an average can't replace.
Long-context results on RULER and LongBench
The main long-context comparison runs Qwen3-4B and Qwen3-8B on RULER at 8K and 16K, with 50% and 75% compression. At 75% compression on Qwen3-8B at 8K, IndexMem++ scored 90.14, compared to 93.86 for Full-KV. In that column TrimKV scored 80.26 and SnapKV scored 35.13, so the gap to Full-KV for IndexMem++ is 3.72 points. The baselines get the same average per-KV-head budget, which counts attention sinks, the local window and any auxiliary slots.
The authors used greedy decoding for these runs, so the comparison doesn't depend on sampling.
SnapKV drops because it scores relevance from attention to queries it has already seen, and recent attention says little about what a future query needs. On MultiKey-2 and MultiKey-3, the distractors share the target's template and key-value type, so similarity criteria degrade sharply. IndexMem++ stays robust on those tasks, while DMA also falls off sharply at high compression.
DMA's score is query-independent like the gate's, but it is trained with the language-modeling loss instead of distilled from Full-KV, so its ranking transfers poorly to hard eviction.
TrimKV reaches 45.41 at the same ratio, so the gate stays ahead of the strongest trained baseline on the average. On multi-document QA at 75%, IndexMem++ scores 61.57 on HotpotQA, 44.82 on 2WikiMQA and 35.89 on MuSiQue. TrimKV scores 59.53, 42.40 and 31.81 on those same three tasks, so the gap is consistent across the three. The authors read this as the method keeping evidence that is old or geometrically unremarkable, rather than evidence that merely looks recent or distinctive.
Reasoning traces and retained context under a small cache
Reasoning traces are a hard test for eviction, because the cache has to keep the states a long chain of thought still needs. On Math500 at 512 entries, IndexMem++ scored 0.794 against 0.784 for Random Attention, and generated 5,423 tokens against 9,714. On AIME25 at 2048 entries IndexMem++ scored 0.600, compared to 0.388 for Random Attention.
The introduction gives 0.807 for Math500 at a 512-entry cache, while Table 8 reports 0.794 for that setting, and this section uses the table value.
The authors test whether the gate keeps early context or reduces to a recency window. Both run with physical eviction on Qwen3-8B at K = 2,048, on AIME25 reasoning traces and on SWE trajectories. The recency policy had already dropped the original entries of 37 of them.
Decoding speed is the other side of the budget, and the authors measure it on a single H20 GPU. Full-KV must read a cache that keeps growing, which is why its points are missing where it runs out of memory. At batch size 32, raising the input length from 8K to 256K reduces IndexMem++ throughput by about 28% on both models.
Where the evidence stops
The main long-context tables cover Qwen3-4B on RULER only, while Qwen3-8B also appears on LongBench and the math tasks. The math baselines are scored on a 125-problem Math500 subset for some rows, marked with a dagger in Table 8.
The backbone stays frozen, because joint training degraded eviction: unfreezing the attention projections and norms lowered performance from 67.60 to 62.83. The authors didn't test on-policy prefixes generated under hard eviction, which they leave for future work.
The authors warn that a compressed model can lose evidence the uncompressed model would have used, and those errors aren't always visible to the user. The reported ratios shouldn't be assumed to transfer to other settings.
Paper info
- Authors
- 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
- Venue
- arXiv · Preprint
- First published
- 2026-11-5
- Added
- 2026-11-6
- Updated
- 2026-11-5
- Version
- v1
- arXiv
- 2611.07605
- Category
- cs.CL
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
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.
Quote from the paper
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 (2026). The Gating Mechanism of KV Cache Eviction. arXiv:2611.07605v1. https://arxiv.org/abs/2611.07605v1
BibTeX
@misc{gu2026gating,
title = {{The Gating Mechanism of KV Cache Eviction}},
author = {Hao Gu and Xintong Yang and Zhiwei Li and Lei Zhu and Jian Yang and Qiyuan Zhu and Dezhi Li and Jingyuan Zhang and Zhizhuo Kou and Hao Wang and Bei Liu and Jiacheng Liu and Sirui Han},
year = {2026},
eprint = {2611.07605},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.07605v1}
}