Summary (Overview)
- RestoreKV introduces a novel complementary restoration perspective to query-agnostic KV cache eviction: instead of only learning which original KV pairs to retain, it learns a shared mechanism that generates a compact, context-conditioned restore cache to complement the retained context cache under the same total KV budget.
- The method uses 8 learnable restore tokens that attend to the full KV cache in a single LoRA-adapted pass after context prefill, generating context-conditioned KV pairs that are combined with the base evictor's retained states.
- RestoreKV is trained via self-distillation from a frozen full-cache teacher, optimizing only 0.4% of parameters (restore-token embeddings + LoRA adapters) with no task-specific tuning.
- Across 4 backbones, 4 benchmarks, and 5 base eviction methods, RestoreKV substantially reduces compression-induced degradation. On Qwen3-4B at a 5% budget, it improves KVzip from 38.2 to 73.2 on RULER-4K; applied to KVzip+, it reaches 86.4 RULER accuracy at 16× compression on the KVPress Benchmark.
- The method adds less than 0.5% one-time cache-construction overhead (0.03–0.04 s and 84 MB) in a 32K-context evaluation, with no query-time KV-memory or decoding cost.
Introduction and Theoretical Foundation
Background
Large language models increasingly rely on long contexts, but their key–value (KV) caches grow linearly with sequence length. KV cache eviction reduces this cost by retaining only a subset of cached KV pairs. Query-agnostic eviction methods compress a context once before future queries are known and reuse the resulting cache across arbitrary subsequent requests.
The Selection-Based Formulation
Recent query-agnostic methods (KVzip, KVzip+, ContrastKV) largely follow the same formulation: select a better subset of the original KV pairs. The resulting cache remains composed only of retained original states. The central question has been which KV pairs should survive under a fixed budget.
Key Insight
Although the information lost through eviction is context-specific, the mechanism for generating its compact complement can be shared across contexts.
This motivates a complementary question: rather than relying only on a better subset, can we generate a small context-conditioned complement before eviction to preserve behavior that would otherwise be lost?
Theoretical Foundation
Consider a decoder-only Transformer with L layers and H KV heads. Given a context , the prefill stage produces a full KV cache containing KV pairs. At KV budget ratio , the total KV budget is:
The retained context cache is:
where and Evict follows the layer- and head-wise allocation rule of the underlying method.
Methodology
3.1 Restore-Cache Generation with LoRA
RestoreKV introduces learnable restore-token embeddings:
where is the hidden dimension. After context prefill, the restore tokens are processed at positions with causal access to the full KV cache . A single LoRA-adapted restore pass generates the context-conditioned restore cache:
where denotes the frozen backbone parameters and denotes the LoRA parameters.
For each adapted linear projection W, LoRA applies:
where is the LoRA rank, is the scaling factor, and , are trainable low-rank matrices.
3.2 Budget Matching
To preserve the query-time KV budget, RestoreKV reserves of the cache slots for and lets the base evictor fill the remaining slots:
Retained context KV pairs preserve their original RoPE phases, while restore tokens occupy positions and future queries begin at position .
3.3 Self-Distillation Training Objective
Given a training context and query , the full-cache teacher first generates an answer . The teacher and student then evaluate the same answer:
The loss is the token-averaged symmetric KL divergence:
KV budget ratios are uniformly sampled:
Training Configuration
- 8 restore tokens (), LoRA rank , scaling factor (0.4% of Qwen3-4B parameters)
- Training set: 6.2k context–query pairs from 2.5k unique contexts (LongAlpaca, PG-19, Tulu-3 Flan)
- Budget ratios sampled from
- Full training run for Qwen3-4B: ~2 hours on a single NVIDIA RTX PRO 6000 GPU
Empirical Validation / Results
Main Results (Qwen3-4B, RULER-4K)
| Method | r=0.2 | r=0.1 | r=0.05 |
|---|---|---|---|
| KVzip | 91.4 | 80.1 | 38.2 |
| KVzip + Ours | 93.5 (+2.1) | 88.8 (+8.7) | 73.2 (+35.0) |
| KVzip+ | 91.3 | 84.8 | 51.6 |
| KVzip+ + Ours | 93.3 (+2.0) | 89.7 (+4.9) | 70.7 (+19.1) |
| ContrastKV | 91.6 | 80.7 | 38.0 |
| ContrastKV + Ours | 92.3 (+0.7) | 84.3 (+3.6) | 40.2 (+2.2) |
Generalization Across Five Eviction Methods
RestoreKV improves SnapKV and H₂O (query-agnostic adaptations) as well:
| Method | RULER-4K (r=0.05) | QASPER (r=0.05) | QuALITY (r=0.05) | LongHealth (r=0.05) |
|---|---|---|---|---|
| SnapKV | 12.7 | 14.3 | 42.5 | 36.2 |
| SnapKV + Ours | 14.3 (+1.6) | 20.7 (+6.4) | 49.9 (+7.4) | 38.5 (+2.3) |
| H₂O | 3.2 | 14.4 | 41.5 | 37.0 |
| H₂O + Ours | 5.7 (+2.5) | 21.3 (+6.9) | 47.7 (+6.2) | 46.8 (+9.8) |
Comparison with Synthesized-Cache Baseline
At r=0.05, RestoreKV+ achieves 70.7 vs 52.8 on RULER-4K compared to AM-fast, and constructs a 4K-context cache in 0.74 s vs 9.68 s (~13× faster).
Component Ablations (RULER-4K, Qwen3-4B, r=0.05)
| Restore emb. | LoRA target | #Params | r=0.2 | r=0.1 | r=0.05 |
|---|---|---|---|---|---|
| - (KVzip) | - | - | 91.4 | 80.1 | 38.2 |
| Learned only | - | 0.02M | 92.7 | 82.6 | 42.1 |
| Learned | q/k/v | 4.0M | 93.4 | 88.2 | 72.4 |
| Learned (full) | q/k/v/o+MLP | 16.5M | 93.5 | 88.8 | 73.2 |
Key finding: Attention-side adaptation (LoRA on q/k/v) is the primary source of recovery, contributing 72.4/73.2 points versus only 42.1 from learned embeddings alone.
Effects of Full-Context Conditioning
| Method | r=0.2 | r=0.1 | r=0.05 |
|---|---|---|---|
| KVzip (n=0) | 91.4 | 80.1 | 38.2 |
| Generated from evicted cache | 93.7 | 87.6 | 64.4 |
| Generated from full KV cache | 93.5 | 88.8 | 73.2 |
Full-context conditioning adds +8.8 points at r=0.05 over evicted-cache generation.
Number of Restore Tokens
| n | r=0.2 | r=0.1 | r=0.05 |
|---|---|---|---|
| 0 (KVzip) | 91.4 | 80.1 | 38.2 |
| 1 | 93.0 | 85.3 | 65.3 |
| 2 | 93.4 | 87.6 | 70.4 |
| 8 (default) | 93.5 | 88.8 | 73.2 |
| 16 | 93.3 | 87.8 | 69.1 |
Efficiency Analysis (Llama-3.1-8B-Instruct, 32K context)
- Compression overhead: +0.03–0.04 s (<0.5% of total compression time), +84 MB peak memory (0.4%)
- Inference: Attention latency nearly identical to KVzip (0.457–0.253 ms); KV-cache memory exactly matched (4.20 → 0.20 GB for both methods)
Context-Attention Recovery
RestoreKV recovers lost context attention:
- Average attention mass: 0.56% → 1.30% (full cache: 2.73%)
- KL divergence from full-cache model: 0.198 → 0.167
- Predictive distribution divergence: 7.3 → 3.8
Theoretical and Practical Implications
Theoretical Implications
-
Beyond selection-based caching: RestoreKV demonstrates that the selection-based formulation of KV eviction is not the only viable endpoint. A hybrid approach—combining selection with a small, learned, context-conditioned complement—can substantially outperform pure selection under aggressive budgets.
-
Shared restoration mechanism: The finding that a single, shared mechanism (LoRA adapters + restore tokens) can generate context-specific complements across diverse contexts validates the premise that "the mechanism for generating compact complements can be shared across contexts."
-
Attention-side adaptation is key: The ablations reveal that the recovery primarily stems from adapting attention projections (q/k/v), not from memorized information in embeddings—suggesting that the model learns a generalizable transformation of full-cache information into compact form.
Practical Implications
-
Drop-in compatibility: RestoreKV works as a plug-in for any query-agnostic eviction method without modifying the importance scorer or eviction rule, making it easy to integrate into existing pipelines.
-
Negligible overhead: With <0.5% one-time compression overhead and zero query-time cost, RestoreKV is practical for real-world deployment.
-
Budget-matched: The method preserves the exact query-time KV memory budget and decoding cost of the base method, which is critical for deployment with hard memory constraints.
-
Broad applicability: Improvements across model scales (0.6B–8B), architectures (Qwen3, Llama-3.1), and eviction strategies suggest wide applicability.
Conclusion
RestoreKV revisits query-agnostic KV cache eviction from a complementary restoration perspective. It uses a shared, LoRA-adapted restoration mechanism to generate a compact, context-conditioned restore cache before eviction and combines it with retained original KV pairs under the same total budget.
Key takeaways:
- Preserves the base importance scorer and eviction rule while disabling adapters after cache construction
- Adds negligible one-time overhead and no query-time KV-memory or decoding cost
- Consistently reduces compression-induced degradation across four backbones, four benchmarks, and five base eviction methods
- Largest gains appear under aggressive budgets (e.g., +35.0 points on RULER-4K at r=0.05 for KVzip)
- Attention-side adaptation is the primary source of recovery; full-context conditioning provides additional complementary benefit
Future directions suggested by the work include: exploring more sophisticated restore-cache architectures, extending the approach to query-aware settings, and investigating whether larger restore-cache budgets could further close the gap to full-cache performance.
Related papers
- Priming: Hybrid State Space Models From Pre-trained Transformers
Priming initializes hybrid state-space models from pre-trained Transformers using less than 0.5% of the token budget, yielding faster, lighter models that outperform source Transformers on reasoning benchmarks.
- More Convincing, Not More Correct: Self-Play Reward Hacking of Reference-Free LLM Judges
Self-play training against reference-free LLM judges inflates pass rates without improving true accuracy, creating a 0.74 judge–truth gap; forcing judges to commit their own answer first collapses false positives from 0.719 to 0.012.
- Does RoPE Prevent or Degrade Retrieval Heads? A Mechanistic Analysis Across Model Families
RoPE's frequency axis, not dimension utility, is causally load-bearing for retrieval heads, with zeroing low-frequency dimensions collapsing recall across all model families tested.