- The paper introduces a training-free, role-conditional KV cache allocator that combines SnapKV’s windowed max-pooling with structural-role budgets, closing 63–98% of the H2O accuracy gap at 5–20% cache budgets on schema-dense contexts.
- The paper finds that attention-based eviction over-retains structural tokens such as delimiters and keys while discarding answer-bearing values, causing nested-JSON exact-match accuracy to fall from 88% to 0% at a 5% H2O budget.
- The paper shows that suppressing keys is generally effective across four model families, but deployment requires tokenizer-aware safeguards and block-level role detection because parser-free probes can reduce downstream accuracy by 18–32 points.
Motivation and problem setting
KV cache eviction is the primary lever for memory and latency in long-context LLM inference, and the dominant family of methods—H2O and its descendants—ranks tokens by accumulated attention mass and retains the heaviest. This paper studies a regime where that scoring assumption fails: schema-dense contexts such as deeply nested JSON, XML, and markdown tables. In these inputs, attention mass behaves as signal energy concentrated on structural noise rather than answer-relevant content, so heavy-hitter eviction optimizes the wrong criterion. The empirical consequence is stark: exact-match (EM) accuracy on leaf-value QA over nested JSON collapses from 88% at full cache to 0% at a 5% budget under H2O on Llama-3.1-8B-Instruct.
The paper's framing treats the cache as a memory-constrained representation of a streaming signal and eviction as an adaptive filter; the diagnosis is then a signal-to-noise ratio (SNR) failure of the retained state. The contribution is a retraining-free, role-conditional budget allocator layered on SnapKV, plus a diagnostic and counterfactual analysis establishing which structural roles must be retained or evicted.
Diagnosis: a structural-routing bias
Profiling per-(layer, head) attention across 604 prompts at 8k/16k/32k context lengths, with tokens labeled by structural role (KEY, VALUE, DELIM, HEADER, PROSE, WS), the paper finds an order-of-magnitude attention sink distributed over delimiters: mean per-token mass on DELIM is 13.64 versus 0.336 for VALUE—roughly 40× the per-token energy of the answer-carrying role. This sink is not StreamingLLM's BOS slot: it spans approximately 674 distinct DELIM positions per prompt at text-inferable locations, so a single fixed sink slot cannot capture it.
Retention rates confirm the bias propagates into eviction decisions. KEY tokens are retained at 1.94/1.79/1.65× the rate of VALUE tokens at budgets of 5/10/20%, and HEADER retention on wikitable reaches 47% at a 5% budget while VALUE sits near the random baseline. Mass-quartile bucketing locates the mechanism: VALUE tokens concentrate in the lowest-mass quartile—the first to be evicted. The bias is layer-pervasive but not uniform (layer 0 inverts it), and crucially it predates instruction tuning: the Llama-3.1-8B base model reproduces the DELIM sink at near-identical magnitude (13.54) and a 1.91× KEY-over-VALUE ratio, indicating a property of the pretrained transformer rather than an alignment artifact.
The paper also derives a directional SNR estimate for the retained state: the raw VALUE-to-DELIM energy ratio is approximately 0.025 (−16 dB), and H2O's retention pattern pushes this ratio further down as the budget tightens, tracking EM collapse. This is offered explicitly as a coarse estimator, not a formal control.
Counterfactual eviction
Correlation between mass and role does not establish causation, so the authors run counterfactual experiments banning each role from retention entirely. On indented JSON at ctx 8k, No-KEY recovers EM to 0.82 at B=0.5 and reaches the 0.88 full-cache ceiling at B=0.75, using strictly less candidate budget than H2O. Conversely, No-DELIM and No-VALUE collapse to 0% at every sub-full budget: delimiters and values are both required scaffold. The resulting retention ordering—DELIM ≈ VALUE ≫ KEY—inverts the naive "keys index, values are content" reading, and establishes KEY suppression as the best deployable filter.
A decomposition of SnapKV follows from the same lens: windowed mass alone closes 81% of the H2O gap at B=0.5, but adding the 1-D max-pool over the KV axis closes 100% at ctx 16k. The pool down-weights isolated high-mass sinks and up-weights content clusters, so SnapKV's benefit is largely implicit sink suppression rather than recency. Disabling the pool collapses low-budget EM to 0.16, and EM rises monotonically in kernel size up to the swept range, making the default k=7 conservative.
The combined method
The two findings address orthogonal failure modes—position bias (the sink) and content bias (KEY over-retention)—and compose into a single allocator: score by windowed mass, smooth with the max-pool, then keep top-×0 tokens within each role bucket per (layer, head), redistributing slack from saturated buckets. Hyperparameter discipline is explicit: ×1 and ×2 are SnapKV defaults, the content-role weights ×3 are read off the counterfactual ordering rather than swept, and only ×4 is tuned. A sensitivity sweep shows EM moves by at most 4 points under ×5 perturbations of fixed weights—except at exactly zero, where zeroing PROSE collapses EM to 0 because the parser labels question text as PROSE and eviction removes the model's only retrieval cue.
The composition is super-additive. At ctx 16k, ×6, SnapKV alone closes 21% of the H2O gap and the allocator alone 0%, yet the combination closes 63%—a factor-of-three interaction—rising to 86% and 98% closure at ×7. The combined method dominates H2O, SnapKV-only, and allocator-only at every budget. Two baselines contextualize this: fair eviction (equal per-role retention, following prior work at instruction-block granularity) is worse than vanilla SnapKV by 18–70 EM points on JSON, showing the same partition-and-allocate container admits opposite optima on opposite workloads; and a one-shot Quest analogue trails all methods, though the comparison omits Quest's per-step re-selection and is acknowledged as a lower bound rather than a head-to-head result.
The over-baseline claim is qualified carefully. At seed 0, the combined method exceeds full-cache accuracy by 10 and 8 EM points at ×8, suggesting eviction as a quality lever via denoising. Over four prompt draws, however, the ×9 margin shrinks to ×0 with a 95% CI straddling zero (McNemar ×1); only the ×2 effect survives as small and borderline significant (×3 EM, ×4). The defensible claim is that the method matches or modestly exceeds full-cache accuracy at higher budgets—not that eviction reliably improves quality below ×5.
The ×6 optimum is bimodal: zero wins on cleanly separable indented JSON, while ×7 is the safe default elsewhere. On compact JSON and XML, BPE merges delimiter and key characters into single tokens, so hard KEY eviction deletes merged delimiters and fails catastrophically (0/50 EM); the soft floor preserves them. A precedence-flip ablation shows only the compact-JSON collapse is a labeling artifact; the XML one is not.
Cross-model generalization
Replication on Mistral-7B-Instruct-v0.3, Phi-3-mini, and Qwen2.5-7B-Instruct splits the claims into a universal core and a model-coupled residual:
| Claim |
Llama |
Mistral |
Phi-3 |
Qwen |
| Over-retains KEY vs. VALUE |
✓ |
✓ |
✓ |
✓ |
| Ban-KEY recovers accuracy |
✓ |
✓ |
✓ |
✓ |
| Max-pool load-bearing |
✓ |
✓ |
✓ |
✓ |
| Super-additive composition |
✓ |
✓ |
✗ |
✗ |
| Over-baseline lever |
✓ |
✓ |
✗ |
✗ |
The universal core holds with tight ratios (KEY-over-VALUE at ×8: 1.94/1.82/1.98/1.75×9), and No-KEY lifts EM above each model's own full-cache baseline. Notably, the sink's identity is tokenizer-coupled—it lands on DELIM for Llama, whitespace for Mistral, no dominant role for Phi-3, PROSE for Qwen—but its eviction behavior is not. Phi-3 serves as the decisive control against a tokenizer-divergence explanation: sharing Mistral's tokenizer with identical char-span counts, it nonetheless patterns with Qwen. The surviving mechanism is that SnapKV's max-pool already cancels the KEY bias completely on Phi-3 and Qwen, leaving no residual for the correction to exploit; the low-budget combined-vs-SnapKV gain quantifies this (−160 Llama, −161 Mistral, −162 Qwen at −163).
A role-density boundary bounds the policy gain: on wikitable the over-attended HEADER role comprises only 1.6% of tokens (versus ~42% for JSON keys), so excluding it frees too little budget to matter—all −164 curves bunch within a band indistinguishable from SnapKV. The diagnosis replicates there; only the policy gain is density-bounded.
Deployment: a linear role probe
Toward parser-free deployment, a multinomial logistic regression over a 5-token window of token IDs (~15 MB fp32) trains in 8.6 s and labels roles near-perfectly in isolation (held-out accuracy 0.9952, KEY F1 0.9991). Yet it is not a drop-in replacement: swapping probe for parser labels drops downstream EM by 18–32 points at ctx 16k. The failure is identifiable—as a purely local classifier, the probe has no block-level scope, so it labels free-form path references inside the question as KEY on token shape; under −165 these mislabeled retrieval cues are evicted. Near-perfect isolated F1 therefore does not imply deployment readiness, and adding a block/segment feature is left open.
On systems cost, probe inference is negligible (0.04 s/prompt vs. 1.94 s for the parser). The paper is candid that it claims no measured memory or latency savings: the harness masks attention to evicted keys rather than compacting KV tensors, so peak memory is flat across budgets and decode is no faster. The mechanical −166 reduction would hold in a compacting implementation but is not demonstrated here.
Limitations and open questions
The paper concedes several boundaries at the points where they bear on results. The over-baseline accuracy effect is seed-sensitive even on Llama and absent on two of four model families, and is accordingly framed as a qualified secondary observation. The role-density floor limits applicability to corpora whose over-attended roles are sparse. The masking-based harness isolates accuracy effects without realizing memory or latency benefits. The Quest baseline omits incremental re-selection. All runs are fp16-only (ctx-16k numbers reproduce on fp32, ruling out a decode-path artifact, but broader precision coverage is untested). Open questions include whether a block-aware probe can match parser-level downstream accuracy, whether the method transfers to real schema-dense corpora beyond synthetic ones, and how it interacts with aggressive KV quantization.
Conclusion
This paper reframes attention-mass KV eviction as a filter matched to the wrong criterion on schema-dense inputs, and supports the reframing with a diagnosis (a distributed delimiter sink carrying order-of-magnitude excess energy), a causal counterfactual (KEY suppression recovers full-cache accuracy; delimiters and values are load-bearing scaffold), and a mechanism decomposition (SnapKV's max-pool, not its recency floor, does the work). The resulting role-conditional allocator is training-free, exposes a single tuned hyperparameter, closes 63–98% of the H2O gap at sub-20% budgets, and composes super-additively—though the composition gain itself is model-coupled, and the over-baseline effect is small and seed-sensitive. The cross-family replication, with its explicit partition of claims into a universal core and a residual, is a methodological strength: it scopes precisely what any adopter should expect the method to deliver.