TL;DR
Existing query-agnostic KV cache eviction methods suffer from severe performance drops under aggressive compression because they rely purely on selecting a subset of original KV pairs. RestoreKV solves this by introducing a learned restoration mechanism that generates a compact "restore cache" to complement the retained pairs within the exact same memory budget. It recovers near full-cache performance with negligible computational overhead (<0.5% compression time) and requires no task-specific tuning.
What Problem Does This Paper Address?
Large Language Models (LLMs) are increasingly used for long-context tasks, but their Key-Value (KV) caches grow linearly with sequence length, creating massive memory bottlenecks. To mitigate this, researchers use query-agnostic KV cache eviction, which compresses the context once during the prefill stage so the compressed cache can be reused across arbitrary future queries.
However, existing methods operate under a strict selection-based paradigm: they try to figure out which original KV pairs are the most important to keep and discard the rest. When memory budgets get tight (e.g., compressing the cache down to 5% of its original size), selection alone fails. Crucial context-specific information is inevitably lost, causing model performance to collapse.
The authors of RestoreKV ask a complementary question: Instead of just picking a better subset of original pairs, can we generate a tiny, context-conditioned complement before eviction to restore the behavior that would otherwise be lost?
Methods
RestoreKV introduces a budget-matched, single-pass plug-in that works on top of any existing selection-based eviction method (like KVzip, SnapKV, or H2O).
The process unfolds in three main steps:
- Restore-Cache Generation: After the initial context prefill, a small number of learnable "restore tokens" ($n=8$ by default) are appended to the sequence. In a single forward pass, these tokens utilize causal attention to look at the full KV cache before any eviction happens. This pass is modulated by lightweight LoRA adapters to generate a highly compact, context-conditioned "restore cache."
- Budget Matching: To ensure a fair memory footprint, RestoreKV subtracts the size of this new restore cache from the total allowed KV budget. The base eviction method then fills the remaining slots with the best-retained original context pairs.
- Frozen Inference: Once the final budget-matched cache is constructed, the LoRA adapters are completely disabled. All subsequent query processing and token decoding use the original, unmodified, frozen LLM backbone.
Training via Self-Distillation: The restore token embeddings and LoRA adapters (amounting to just 0.4% of the model's parameters) are trained offline. The model minimizes a symmetric KL-divergence loss to match the token-distribution outputs of a frozen, full-cache "teacher" model. Crucially, the budget ratio is randomized during training so that a single set of weights can support multiple compression tiers at runtime.
Datasets
The authors trained and evaluated RestoreKV across diverse long-context benchmarks:
- Training Data: A mixture of 6,248 context-query pairs derived from LongAlpaca, PG-19, and Tulu-3 Flan.
- Evaluation Benchmarks:
- RULER-4K: A synthetic suite testing retrieval, aggregation, and tracking.
- QASPER: Free-form question answering over scientific papers (~5K tokens).
- QuALITY: Multiple-choice reading comprehension over long articles (~6K tokens).
- LongHealth: Multiple-choice QA over clinical patient records (~11K tokens).
- SCBench & LongBench (Appendix): Evaluated for extreme context lengths up to 104K tokens.
Key Insights and Ideas
- Shared Mechanism for Context-Specific Loss: While the specific information lost during eviction varies wildly from one document to another, the mechanism required to synthesize a compact summary of that lost information can be shared and learned across contexts.
- Attention-Side Adaptation is King: Through ablation studies, the authors discovered that simply optimizing the restore token embeddings yields minimal improvement. The heavy lifting is done by the LoRA adapters modifying the attention projections ($q/k/v$). This proves that RestoreKV succeeds by dynamically transforming full-context attention rather than just memorizing static, generic information.
- Pre-Eviction Conditioning Matters: Generating the restore cache from the full KV cache before eviction provides an 8.8-point accuracy boost compared to trying to generate it from an already-evicted cache. Access to the complete context is vital for capturing vulnerable information.
Key Results
RestoreKV consistently mitigates performance degradation across four model backbones (Qwen3-0.6B/4B/8B and Llama-3.1-8B-Instruct) and five different base eviction algorithms.
- Massive Accuracy Recovery: On Qwen3-4B at a tight 5% KV budget ($20\times$ compression), RestoreKV boosts the baseline KVzip score on RULER-4K from a collapsed 38.2 to 73.2.
- State-of-the-Art Compression: Applied to KVzip+, RestoreKV achieves 86.4 accuracy at 16× compression on the KVPress Benchmark.
- Negligible Overhead: In a 32K-context evaluation, the 8-token restore pass adds a mere 0.03 to 0.04 seconds of latency (<0.5% of total compression time) and only 84 MB (0.4%) of peak memory, while introducing zero additional cost during the actual query decoding phase.
Limitations and Future Work
- Cross-Evictor Mismatch: RestoreKV checkpoints adapt to the specific compression behavior of the evictor they were trained with. If a RestoreKV module is trained using SnapKV but deployed using KVzip at extreme compression ratios (e.g., 5%), its performance drops significantly compared to a matched setup.
- Offline Training Requirement: Although parameter-efficient, RestoreKV still requires an offline self-distillation training phase for each specific model architecture and base eviction method.
- Transformer-Specific Design: The current formulation relies strictly on standard multi-head/grouped-query attention mechanisms in decoder-only transformers and hasn't been tested on alternative architectures like linear attention or state-space models (SSMs).
Summary updated