Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox

METAL MEDIA

RestoreKV: Recovering Full-Cache Behavior Under Aggressive Query-Agnostic KV Cache Eviction

arXiv:2608.012472026-08-01

Adding 8 learned 'restore tokens' brings heavily compressed KV caches back close to full-cache quality

Long-context LLMs shrink their KV cache (stored key-value computations from past tokens) to save memory, but aggressive compression can badly hurt answer quality. RestoreKV keeps existing selection methods for which KV pairs to keep, and additionally runs a single pass where a handful of learned tokens attend to the full cache before eviction to generate a compact 'restore cache' that fills part of the same fixed budget. On Qwen3-4B, this raised KVzip's RULER-4K accuracy from 38.2 to 73.2 at a tight budget, adding less than 0.5% extra time to the compression process.

METAL MEDIA explanatory visual

How RestoreKV builds its budget-matched cache

Evidence statusMeasured results reported

  1. 1. Context prefillThe model processes the long input once to produce the full KV cache of stored key-value pairs.
  2. 2. Restore pass8 trained restore tokens, with LoRA temporarily enabled, attend to the entire full KV cache to generate a compact restore cache before eviction.
  3. 3. Base eviction unchangedThe existing scorer (e.g., KVzip) picks which original KV pairs to retain, leaving room for the restore cache within the same total budget.
  4. 4. Budget-matched combinationRetained original KV pairs and the generated restore cache are combined into one final cache of the same total size as before.
  5. 5. Query and decodingLoRA is turned off; the frozen original model answers arbitrary future queries using the combined cache.
An explanatory diagram made by METAL MEDIA, not a figure supplied by the paper's authors.

What they did

  1. Query-agnostic KV eviction compresses a context once for reuse across future queries, but performance collapses under aggressive compression budgets.
  2. RestoreKV keeps existing selection-based methods (like KVzip) unchanged for choosing which original KV pairs to keep, and adds a LoRA-adapted single pass where 8 learnable restore tokens attend to the full KV cache to generate a compact, context-conditioned 'restore cache'.
  3. This restore cache occupies part of the same fixed KV budget (it replaces some retained slots), so total memory cost stays the same; LoRA is active only during this one-time restore pass, while all later query processing and decoding use the original frozen model.
  4. Training uses self-distillation: only the restore-token embeddings and LoRA adapters (0.4% of parameters) are optimized so the compressed-cache model's answer distribution matches a frozen full-cache teacher's distribution.
  5. Tested across four backbones (Qwen3-0.6B/4B/8B, Llama-3.1-8B) and four benchmarks (RULER-4K, QASPER, QuALITY, LongHealth) with five base eviction methods (KVzip, KVzip+, ContrastKV, SnapKV, H2O), improving nearly all paired settings.
Figure 1: RestoreKV narrows the gap to full-cache behavior under aggressive compression at negligible one-time cost. Applied to KVzip+, RestoreKV reaches 86.4 RULER accuracy at 16× compression on the KVPress Benchmark while adding negligible compression-time overhead.
Figure 1: RestoreKV narrows the gap to full-cache behavior under aggressive compression at negligible one-time cost. Applied to KVzip+, RestoreKV reaches 86.4 RULER accuracy at 16× compression on the KVPress Benchmark while adding negligible compression-time overhead.
Table 1: Generalization across KV cache eviction methods. RestoreKV improves five different base methods on Qwen3-4B under matched KV budgets, with larger gains typically observed at tighter budgets. Colored subscripts indicate absolute changes from the corresponding baseline.
MethodRULER-4KQASPERQuALITYLongHealth
r=0.2r=0.1r=0.05r=0.2r=0.1r=0.05r=0.2r=0.1r=0.05r=0.2r=0.1r=0.05
KVzip91.480.138.238.233.918.066.058.546.371.570.061.0
KVzip + Ours93.5 +2.188.8 +8.773.2 +35.039.0 +0.837.7 +3.828.7 +10.767.0 +1.063.3 +4.852.4 +6.175.8 +4.373.8 +3.867.5 +6.5
KVzip+91.384.851.638.132.423.366.560.051.973.267.863.2
KVzip+ + Ours93.3 +2.089.7 +4.970.7 +19.140.9 +2.838.5 +6.131.6 +8.366.8 +0.362.9 +2.957.9 +6.074.2 +1.073.0 +5.271.5 +8.3
ContrastKV91.680.738.040.131.917.866.262.250.774.269.049.0
ContrastKV + Ours92.3 +0.784.3 +3.640.2 +2.240.9 +0.836.0 +4.121.6 +3.867.6 +1.463.3 +1.151.9 +1.275.2 +1.070.5 +1.554.0 +5.0
SnapKV33.820.612.722.419.014.353.953.042.541.036.836.2
SnapKV + Ours37.7 +3.926.3 +5.714.3 +1.629.9 +7.524.0 +5.020.7 +6.459.4 +5.551.8 −1.249.9 +7.451.8 +10.841.8 +5.038.5 +2.3
H2O8.03.53.222.013.814.459.250.441.560.248.837.0
H2O + Ours17.3 +9.311.6 +8.15.7 +2.530.4 +8.424.7 +10.921.3 +6.960.9 +1.754.9 +4.547.7 +6.264.8 +4.659.0 +10.246.8 +9.8
Figure 2: Overview of RestoreKV. After context prefill, a single LoRA-adapted restore pass processes n restore tokens (n=8 by default) with causal access to the full KV cache, generating n​L​H context-conditioned KV pairs. These restore states are combined with the retained context states under the same total KV budget. LoRA is active only during restore-cache generation; subsequent query processing and decoding use the original frozen backbone. Training (offline): The restore-token embeddings and LoRA adapters (0.4% of the 4B backbone) are optimized by self-distillation from the frozen full-cache teacher, Inference: The trained restore tokens and LoRA adapters generate the restore cache once for each new context.
Figure 2: Overview of RestoreKV. After context prefill, a single LoRA-adapted restore pass processes n restore tokens (n=8 by default) with causal access to the full KV cache, generating n​L​H context-conditioned KV pairs. These restore states are combined with the retained context states under the same total KV budget. LoRA is active only during restore-cache generation; subsequent query processing and decoding use the original frozen backbone. Training (offline): The restore-token embeddings and LoRA adapters (0.4% of the 4B backbone) are optimized by self-distillation from the frozen full-cache teacher, Inference: The trained restore tokens and LoRA adapters generate the restore cache once for each new context.
Table 2: Component and LoRA-target ablations on RULER-4K (Qwen3-4B). The first row is KVzip without a restore cache; the last row is the full RestoreKV configuration. “Fixed” replaces all eight learned restore-token embeddings with the embedding of the line-break token \n.
KV budget ratio r
Restore emb.LoRA target#Params0.20.10.05
91.480.138.2
Learned0.02M (0.0005%)92.782.642.1
Learnedq/k/v4.0M (0.1%)93.488.272.4
Learnedq/k/v/o5.9M (0.15%)93.588.472.0
Fixedq/k/v/o+MLP16.5M (0.4%)93.588.071.9
Learnedq/k/v/o+MLP16.5M (0.4%)93.588.873.2
Figure 3: Performance across four model backbones and four benchmarks. RestoreKV and RestoreKV+ are applied to KVzip and KVzip+, respectively, under the same KV budget. Both methods reduce compression-induced performance loss, with larger gains under tighter cache budgets.
Figure 3: Performance across four model backbones and four benchmarks. RestoreKV and RestoreKV+ are applied to KVzip and KVzip+, respectively, under the same KV budget. Both methods reduce compression-induced performance loss, with larger gains under tighter cache budgets.
Table 3: Effect of full-context conditioning on RULER-4K with Qwen3-4B. Generating the restore cache from the full cache before eviction adds 8.8 points at r=0.05 over generating it from the already evicted cache.
KV budget ratio r
Method0.20.10.05
KVzip (n=0)91.480.138.2
Generated from evicted cache93.787.664.4
Generated from full KV cache93.588.873.2
Figure 4: Comparison with a Synthesized-Cache Baseline on Qwen3-4B. RestoreKV+ consistently improves token-eviction baselines and remains competitive with AM-fast, a strong synthesized-cache method, at ∼13× lower compression time on 4K-token contexts.
Figure 4: Comparison with a Synthesized-Cache Baseline on Qwen3-4B. RestoreKV+ consistently improves token-eviction baselines and remains competitive with AM-fast, a strong synthesized-cache method, at ∼13× lower compression time on 4K-token contexts.
Table 4: Ablation on the number of restore tokens (RULER-4K, Qwen3-4B). All variants share the same training recipe and total KV budget.
KV budget ratio r
Method0.20.10.05
n=0 (KVzip)91.480.138.2
n=193.085.365.3
n=293.487.670.4
n=493.487.068.5
n=8 (default)93.588.873.2
n=1693.387.869.1
Figure 5: Layer-wise context-attention recovery on RULER-4K (Qwen3-4B, r=0.05). KVzip substantially suppresses attention from the final query token to non-sink context KV pairs. RestoreKV recovers part of the lost attention (shaded), increasing the average context-attention mass from 0.56% to 1.30% and reducing KL divergence from the full-cache model by 16% (→0.167).
Figure 5: Layer-wise context-attention recovery on RULER-4K (Qwen3-4B, r=0.05). KVzip substantially suppresses attention from the final query token to non-sink context KV pairs. RestoreKV recovers part of the lost attention (shaded), increasing the average context-attention mass from 0.56% to 1.30% and reducing KL divergence from the full-cache model by 16% (→0.167).
Table A: Ablation on the training ratio range (RULER-4K, Qwen3-4B). RestoreKV is trained by sampling the retention ratio from 𝒰⁡(rmin,rmax). The first row reports the KVzip baseline without restoration.
Training ratio rangeKV budget ratio r
rminrmax0.40.20.10.05
--93.591.480.138.2
0.0250.2594.393.588.873.2
0.0250.5094.193.186.163.5
0.0500.2594.393.286.565.6
0.0500.5094.092.884.551.5
Figure 6: Efficiency analysis (Llama-3.1-8B-Instruct, 32K context). (a) Restore-cache generation adds only ∼0.04 s (0.5%) and 84 MB (0.4%) on top of any base scorer. (b) Attention latency and KV memory are nearly identical to the base method.
Figure 6: Efficiency analysis (Llama-3.1-8B-Instruct, 32K context). (a) Restore-cache generation adds only ∼0.04 s (0.5%) and 84 MB (0.4%) on top of any base scorer. (b) Attention latency and KV memory are nearly identical to the base method.
Table B: Effect of the query-position offset (RULER-4K, Qwen3-4B). Offset-only KVzip applies the same +8 query offset as RestoreKV without adding restore states. Its performance remains close to standard KVzip, suggesting that the positional offset alone is unlikely to account for RestoreKV’s improvement.
VariantRestore statesQuery offsetKV budget ratio r
0.20.10.05
KVzipNo091.480.138.2
Offset-only KVzipNo+890.580.836.9
RestoreKVYes+893.588.873.2
Figure A: RestoreKV composes with Fast KVzip, a learning-based scorer (RULER-4K, Qwen3-8B). At 16×, Fast KVzip drops to 46.7, RestoreKV restores it to 79.3, above plain KVzip (59.0).
Figure A: RestoreKV composes with Fast KVzip, a learning-based scorer (RULER-4K, Qwen3-8B). At 16×, Fast KVzip drops to 46.7, RestoreKV restores it to 79.3, above plain KVzip (59.0).
Table C: Effect of training–inference evictor mismatch (RULER-4K, Qwen3-4B). The inference evictor is fixed to KVzip, while RestoreKV is trained using the evictor in the first column.
Training evictorInference evictorKV budget ratio r
0.200.100.05
-KVzip91.480.138.2
SnapKVKVzip93.581.642.0
KVzipKVzip93.588.873.2
Figure B: SCBench results on long-context tasks (Qwen3-4B).
Figure B: SCBench results on long-context tasks (Qwen3-4B).
Table D: LongBench results over 16 tasks under aggressive KV compression. Categories are single-document QA (S-QA), multi-document QA (M-QA), summarization (Summ), few-shot learning (Fewshot), synthetic tasks (Synth), and code tasks (Code). Rel. denotes the average score relative to the full KV cache.
MethodS-QAM-QASummFewshotSynthCodeAvgRel.
Full KV cache
Llama-3.1-8B-Instruct44.647.629.254.055.148.146.4100.0%
KV budget ratio = 0.125
KVzip42.743.927.761.944.047.744.796.3%
KVzip + Ours43.643.028.563.945.949.345.798.4%
KV budget ratio = 0.0625
KVzip33.332.424.049.120.641.633.572.1%
KVzip + Ours38.235.427.059.322.843.237.781.2%
Table E: RestoreKV training data statistics (context length in tokens).
SourceSamplesCtx (mean)Ctx range
LongAlpaca2,4887,3064,961–15,237
PG-192,2603,0713,071–3,072
Tulu-3 FLAN1,500898512–9,283
Total6,2484,236512–15,237
Table F: Experimental environment. Hardware and software configurations used for all experiments.
Hardware
GPUNVIDIA RTX PRO 6000 Blackwell (96 GB)
CPUIntel Xeon Gold 6530
Memory503 GiB
Software
OSUbuntu 22.04.5 LTS
FrameworkPyTorch 2.8.0 (CUDA 12.8)
Table G: Sensitivity to Training Seeds. RULER-4K accuracy on Qwen3-4B, reported as mean±std over three training seeds.
KV budget ratio
0.400.200.100.05
KVzip93.4691.3880.0838.23
RestoreKV94.25±0.0493.37±0.1188.21±0.5172.81±0.57
Table H: Evaluation metrics used for each benchmark.
BenchmarkEvaluation metric
RULER-4KOfficial string-matching score
QASPERMaximum token-F1 over reference annotations
QuALITYAnswer-letter accuracy
LongHealthAnswer-letter accuracy
LongBenchOfficial per-task metric (F1, ROUGE-L, or accuracy)
SCBenchOfficial task-specific evaluator

Findings

  • On Qwen3-4B at a 5% KV budget, RestoreKV raised KVzip's RULER-4K accuracy from 38.2 to 73.2, and RestoreKV+ raised KVzip+'s from 51.6 to 70.7 under the same total budget.
  • Applied to KVzip+, RestoreKV reached 86.4 RULER accuracy at 16x compression on the KVPress Benchmark, with under 0.5% extra construction time and 84MB (0.4%) extra memory at a 32K-token context.
  • Applied to the learned scorer Fast KVzip, RestoreKV raised RULER-4K accuracy from 46.7 to 79.3 at 16x compression, exceeding plain KVzip's 59.0.
  • Against the synthesized-cache baseline AM-fast at r=0.05, RestoreKV+ scored 70.7 vs. 52.8 on RULER-4K while building a 4K-context cache in 0.74s versus 9.68s, about 13x faster.
  • Layer-wise analysis showed average context attention mass dropped to 0.56% under KVzip eviction, which RestoreKV recovered to 1.30%, and reduced KL divergence from the full-cache model from 0.198 to 0.167.

Where it can be used

  • Document QA or summarization services that compress a long context once and answer many subsequent questions from that cached representation, aiming to reduce quality loss from tight memory budgets.
  • Adding on top of existing KV eviction pipelines (KVzip, KVzip+, SnapKV, H2O) without retraining the underlying selection method itself.
  • Combining with lightweight learned scorers such as Fast KVzip to retain their speed advantage while reducing accuracy loss from aggressive compression.

Limits and open work

  • Performance recovery drops substantially when the eviction method used at inference differs from the one used during training, suggesting retraining may be needed if the base compression method changes.
  • Experiments cover Qwen3 models (0.6B-8B) and Llama-3.1-8B-Instruct with context lengths mostly up to about 15K-32K tokens plus one ~104K-token SCBench evaluation; larger models or other architectures were not tested.
  • Training data is limited to about 6.2k context-query pairs drawn from LongAlpaca, PG-19, and Tulu-3 Flan, so generalization to other document domains is not separately verified.
  • The default configuration (8 restore tokens, specific LoRA rank) was fixed for most experiments, so optimality of these settings in other contexts is not fully explored.

Why it matters

Services that cache long documents once and reuse them for many future questions face a direct tradeoff between memory savings and answer quality under aggressive compression, and this method reduces that loss without redesigning the compression pipeline itself. Because it plugs into existing eviction methods with a small trained add-on, it lowers the practical barrier to adopting tighter KV budgets in production systems.

Terms in this paper

  • KV cache · The stored key-value computations from previous tokens that let a transformer avoid recomputing them for later tokens
  • query-agnostic eviction · Compressing a context once before knowing future questions, then reusing that compressed cache for any of them
  • LoRA · A technique that adapts a frozen model by training only small low-rank matrices added to it, keeping cost low
  • self-distillation · Training a compressed-cache model (student) to match the outputs of the same model using the full, uncompressed cache (teacher)
  • RULER-4K · A synthetic benchmark of 13 tasks testing retrieval, tracing, and aggregation within a 4K-token context

Original abstract (English)

Query-agnostic KV cache eviction compresses a context once and reuses the resulting cache for arbitrary future queries, but performance can collapse under tight budgets. Existing methods primarily improve which original KV pairs are retained. We introduce RestoreKV, which complements this selection-based formulation with learned restoration under the same total KV budget. Our key insight is that, although the information lost through eviction is context-specific, the mechanism for generating its

Authors · Changwoo Baek

Read on arXiv

Latest papers

All papers →

Latest from METAL MEDIA

Figures: Changwoo Baek et al., arXiv:2608.01247, arxiv-nonexclusive