Budgeted KV-Cache Repair for Evolving Contexts
Organizations: LinkedIn · Clemson University · Arizona State University · Rice University
Abstract
Language-model agents revise their working context as information becomes obsolete, but deleting text does not erase its influence on cached computation. Later key-value (KV) states remain conditioned on the deleted content, while recomputing the entire retained suffix can be costly. We introduce budgeted KV-cache repair: recovering task performance by recomputing a user-chosen fraction of the retained suffix. Comparing repair allocations under identical relevance scores and token budgets, we find that refreshing coherent regions can substantially outperform refreshing isolated tokens. This finding motivates Semantic-Unit Refresh (SUR), which allocates the budget to query-relevant text regions using inexpensive embedding scores, without training or an auxiliary transformer forward. To execute these repairs efficiently, a layer-packed executor processes selected states together at each layer while preserving full causal cache access. Across five models, SUR achieves strong recovery in controlled deletion tasks while recomputing only 2-5% of the suffix. On four natural multi-hop QA datasets, it achieves near-full-recompute exact match at a 5% budget with lower post-edit latency. The executor accelerates fragmented refresh by up to 16.1x over interval-wise execution.
Figures & tables
| 1 | . |
|---|---|
| 2 | If : return full suffix Replay from the valid prefix. |
| 3 | ; if : return . |
| 4 | Compute token scores using Equation 1 . |
| 5 | Partition suffix into units; rank by their top-four-mean scores. |
| 6 | ; visit units in ranked order until : |
| 7 | ; if , add all positions of to . |
| Allocator | Implementation in this comparison |
|---|---|
| ProphetKV-Adapted ( Wang et al., 2026 ) | Query-only forward against the Shift cache; suffix score is attention averaged uniformly over query tokens, heads, and layers. |
| InfoFlow-Motivated ( Teng et al., 2026 ) | norm of the same query-to-suffix attention tensor over query tokens, heads, and all layers. This differs from the original attention-mass formula, selected-layer scope, and chunk-reordering procedure. |
| Cache-Craft-Adapted ( Agarwal et al., 2025 ) | Replay the dirty suffix in 64-token chunks with deleted keys still visible. Score each retained token by its attention mass on deleted keys, averaged over heads and layers. |
| CacheBlend-Adapted ( Yao et al., 2025 ) | Fresh two-layer edited prefill; score layer-1 KV deviation from Shift by . One selected support is reused across layers. |
| A 3 -Adapted ( Zhou et al., 2025 ) | Fresh two-layer edited prefill followed by a shallow query forward; sum layer-1 query-to-context attention over heads and query positions. |
| LegoLink-Adapted ( Hu et al., 2025 ) | Treat the valid prefix as the first chunk and split the suffix into 512-token chunks. Rank positions by depth from their chunk boundary, then chunk index. Depths beyond the native 32-token limit are extensions required by the common budget grid. |
| Method | Reference | 2% | 5% | 10% | 20% | 40% | 80% |
|---|---|---|---|---|---|---|---|
| Dirty | 0.00 | – | – | – | – | – | – |
| Shift | 0.00 | – | – | – | – | – | – |
| Replay | 98.96 | – | – | – | – | – | – |
| Re-prefill | 98.96 | – | – | – | – | – | – |
| SUR (ours) | – | 89.58 | 98.96 | 98.96 | 98.96 | 98.96 | 98.96 |
| Dense tokens (same score) | – | 7.29 | 14.58 | 28.13 | 58.33 | 91.67 | 97.92 |
| Method | Reference | 2% | 5% | 10% | 20% | 40% | 80% |
|---|---|---|---|---|---|---|---|
| Dirty | 1.04 | – | – | – | – | – | – |
| Shift | 13.54 | – | – | – | – | – | – |
| Replay | 95.83 | – | – | – | – | – | – |
| Re-prefill | 98.96 | – | – | – | – | – | – |
| SUR (ours) | – | 95.83 | 96.88 | 95.83 | 96.88 | 95.83 | 96.88 |
| Dense tokens (same score) | – | 89.58 | 91.67 | 92.71 | 94.79 | 92.71 | 97.92 |
| Method | Reference | 2% | 5% | 10% | 20% | 40% | 80% |
|---|---|---|---|---|---|---|---|
| Dirty | 0.00 | – | – | – | – | – | – |
| Shift | 1.04 | – | – | – | – | – | – |
| Replay | 100.00 | – | – | – | – | – | – |
| Re-prefill | 100.00 | – | – | – | – | – | – |
| SUR (ours) | – | 90.63 | 98.96 | 100.00 | 100.00 | 100.00 | 100.00 |
| Dense tokens (same score) | – | 7.29 | 8.33 | 7.29 | 16.67 | 29.17 | 89.58 |
| Method | Reference | 2% | 5% | 10% | 20% | 40% | 80% |
|---|---|---|---|---|---|---|---|
| Dirty | 0.00 | – | – | – | – | – | – |
| Shift | 11.46 | – | – | – | – | – | – |
| Replay | 100.00 | – | – | – | – | – | – |
| Re-prefill | 100.00 | – | – | – | – | – | – |
| SUR (ours) | – | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
| Dense tokens (same score) | – | 43.75 | 57.29 | 67.71 | 85.42 | 91.67 | 100.00 |
| Method | Reference | 2% | 5% | 10% | 20% | 40% | 80% |
|---|---|---|---|---|---|---|---|
| Dirty | 0.00 | – | – | – | – | – | – |
| Shift | 68.75 | – | – | – | – | – | – |
| Replay | 97.92 | – | – | – | – | – | – |
| Re-prefill | 100.00 | – | – | – | – | – | – |
| SUR (ours) | – | 97.92 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
| Dense tokens (same score) | – | 83.33 | 91.67 | 96.88 | 95.83 | 97.92 | 97.92 |
| Method | Budget | EM (%) | Mean latency (s) |
|---|---|---|---|
| SUR (ours) | 2% | 42.58 | 1.663 |
| SUR (ours) | 5% | 43.42 | 2.039 |
| BM25 (same units) | 2% | 41.08 | 1.688 |
| BM25 (same units) | 5% | 41.50 | 2.130 |
| CacheBlend-Adapted | 2% | 41.42 | 3.486 |
| CacheBlend-Adapted | 5% | 41.75 | 6.306 |
| Method | Budget | EM (%) | Mean latency (s) |
|---|---|---|---|
| SUR (ours) | 2% | 56.67 | 0.500 |
| SUR (ours) | 5% | 56.92 | 0.535 |
| BM25 (same units) | 2% | 54.75 | 0.490 |
| BM25 (same units) | 5% | 55.08 | 0.552 |
| CacheBlend-Adapted | 2% | 54.67 | 1.572 |
| CacheBlend-Adapted | 5% | 55.17 | 2.759 |
| Budget | Reference | EM | 95% CI |
| Qwen3-30B-A3B | |||
| 2% | Shift | ||
| 2% | Replay | ||
| 2% | Re-prefill | ||
| 5% | Shift | ||
| 5% | Replay | ||
| Method | Budget | 2Wiki | HotpotQA | IIRC | MuSiQue | Pooled |
|---|---|---|---|---|---|---|
| SUR (ours) | 2% | 52.33 | 47.33 | 36.67 | 34.00 | 42.58 |
| SUR (ours) | 5% | 53.00 | 48.33 | 37.67 | 34.67 | 43.42 |
| BM25 (same units) | 2% | 52.00 | 46.33 | 35.00 | 31.00 | 41.08 |
| BM25 (same units) | 5% | 52.33 | 46.33 | 35.67 | 31.67 | 41.50 |
| CacheBlend-Adapted | 2% | 52.67 | 46.33 | 35.33 | 31.33 | 41.42 |
| CacheBlend-Adapted | 5% | 52.67 | 47.00 | 35.67 | 31.67 | 41.75 |
| Method | Budget | 2Wiki | HotpotQA | IIRC | MuSiQue | Pooled |
|---|---|---|---|---|---|---|
| SUR (ours) | 2% | 65.00 | 59.33 | 53.33 | 49.00 | 56.67 |
| SUR (ours) | 5% | 65.00 | 59.67 | 53.67 | 49.33 | 56.92 |
| BM25 (same units) | 2% | 61.00 | 58.00 | 51.33 | 48.67 | 54.75 |
| BM25 (same units) | 5% | 61.67 | 58.67 | 51.33 | 48.67 | 55.08 |
| CacheBlend-Adapted | 2% | 61.33 | 58.33 | 51.00 | 48.00 | 54.67 |
| CacheBlend-Adapted | 5% | 62.00 | 58.67 | 51.33 | 48.67 | 55.17 |
| Qwen3-8B | Qwen3-30B | Llama-70B | GLM-Air | Qwen3-235B | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Allocation rule | 2% | 5% | 2% | 5% | 2% | 5% | 2% | 5% | 2% | 5% |
| SUR | 89.6 | 99.0 | 95.8 | 96.9 | 90.6 | 99.0 | 100.0 | 100.0 | 97.9 | 100.0 |
| Same-score tokens | 7.3 | 14.6 | 89.6 | 91.7 | 7.3 | 8.3 | 43.8 | 57.3 | 83.3 | 91.7 |
| Single relevance window | 75.0 | 86.5 | 84.4 | 79.2 | 65.6 | 72.9 | 89.6 | 88.5 | 72.9 | 77.1 |
| Same-unit BM25 | 82.3 | 94.8 | 90.6 | 94.8 | 75.0 | 94.8 | 94.8 | 100.0 | 99.0 | 100.0 |
| Random units | 2.1 | 5.2 | 16.7 | 17.7 | 2.1 | 5.2 | 18.8 | 19.8 | 78.1 | 83.3 |
| Qwen3-8B | Qwen3-30B | Llama-70B | GLM-Air | Qwen3-235B | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Allocation rule | 2% | 5% | 2% | 5% | 2% | 5% | 2% | 5% | 2% | 5% |
| SUR | 89.6 | 99.0 | 95.8 | 96.9 | 90.6 | 99.0 | 100.0 | 100.0 | 97.9 | 100.0 |
| ProphetKV-Adapted | 77.1 | 97.9 | 91.7 | 94.8 | 85.4 | 99.0 | 93.8 | 100.0 | 92.7 | 95.8 |
| InfoFlow-Motivated | 82.3 | 97.9 | 91.7 | 96.9 | 92.7 | 100.0 | 95.8 | 99.0 | 95.8 | 96.9 |
| Cache-Craft-Adapted | 77.1 | 93.8 | 92.7 | 95.8 | 52.1 | 82.3 | 91.7 | 97.9 | 85.4 | 96.9 |
| CacheBlend-Adapted | 0.0 | 4.2 | 71.9 | 79.2 | 1.0 | 1.0 | 21.9 | 28.1 | 78.1 | 83.3 |
| Mean selected tokens | SUR V1 | Query |
|---|---|---|
| 144.6 | 97.5 | 87.6 |
| 359.2 | 99.7 | 97.8 |
| Endpoint | Contrast | Estimate | 95% CI | Holm |
|---|---|---|---|---|
| NLL | Evidence side | [ , 0.021] | — | |
| Neutral tail | [ , 0.004] | 0.308 | ||
| Interaction | [ , 0.068] | 1.000 | ||
| EM | Evidence side | 5.99 | [2.87, 9.26] | 0.002 |
| Neutral tail | 0.49 | [ , 2.6] | 1.000 | |
| Interaction | [ , 2.2] | 1.000 |
| Endpoint | Complete replay | Fixed-slot refresh |
|---|---|---|
| First-token TV | .0696 [.0560, .0832] | .0709 [.0571, .0849] |
| First-token JSD | .0311 [.0238, .0385] | .0315 [.0240, .0391] |
| Argmax agreement (pp) | 8.37 [6.27, 10.49] | 8.17 [5.96, 10.42] |
| Sequence agreement (pp) | 11.77 [9.27, 14.25] | 11.45 [8.81, 14.16] |
| Model | Output | Shared (%) | Re-prefill (%) | Cross-path (%) | Excess (pp) |
|---|---|---|---|---|---|
| Qwen3-8B | Sequence | 0.42 | 0.83 | 2.29 | 1.46 |
| Exact logits | 0.00 | 0.00 | 100.00 | 100.00 | |
| Argmax | 0.00 | 0.00 | 1.88 | 1.88 | |
| Llama-3.1-8B | Sequence | 2.29 | 1.67 | 3.68 | 2.01 |
| Exact logits | 0.00 | 0.00 | 100.00 | 100.00 | |
| Argmax | 0.00 | 0.00 | 0.62 | 0.62 |
| Sequential | Direct seq. | One-shot | SDPA | Custom | + fused | Flex | ||
|---|---|---|---|---|---|---|---|---|
| 2048 | 1 | 33.051 | 31.465 | 34.593 | 32.485 | 32.389 | 34.169 | 53.008 |
| 2048 | 4 | 131.290 | 121.456 | 34.624 | 32.672 | 32.470 | 34.063 | 56.661 |
| 2048 | 16 | 530.068 | 485.378 | 34.942 | 32.952 | 32.775 | 34.588 | 56.858 |
| 8192 | 1 | 38.848 | 32.571 | 42.126 | 34.860 | 33.372 | 35.228 | 95.613 |
| 8192 | 4 | 142.898 | 120.679 | 41.198 | 34.733 | 32.235 | 34.051 | 144.759 |
| 8192 | 16 | 552.498 | 494.826 | 42.186 | 34.757 | 33.375 | 35.161 | 144.376 |
| HF SDPA | Direct SDPA+GQA | Compiled Flex | Custom | ||
|---|---|---|---|---|---|
| 2048 | 1 | 167.3 | 124.9 | 1019.2 | 135.1 |
| 2048 | 4 | 167.6 | 121.8 | 1106.8 | 148.3 |
| 2048 | 16 | 164.8 | 122.2 | 1108.3 | 147.6 |
| 8192 | 1 | 411.1 | 273.9 | 2145.7 | 232.5 |
| 8192 | 4 | 401.8 | 266.6 | 3477.7 | 293.7 |
| 8192 | 16 | 402.8 | 277.9 | 3468.8 | 295.7 |
| Method | Refresh/operator | Recovery |
|---|---|---|
| 2%, interval-wise | 32.87 | 51.39 |
| 2%, packed | 31.98 | 50.43 |
| 5%, interval-wise | 48.99 | 67.25 |
| 5%, packed | 31.98 | 50.71 |
| Full suffix Replay | 48.57 | 48.57 |
| Clean Re-prefill | 60.25 | 60.25 |
KV-Cache Management
Key-value (KV) cache management reduces and coordinates Transformer attention state to make long-context inference faster and more memory-efficient.
See all 201 papers