TL;DR
When Large Language Models (LLMs) read long retrieved documents, reusing precomputed memory states (KV caches) speeds up response times, though stitching together caches built in isolation degrades answer quality. KVFocus uses perturbation math to prove that a reused token only derails the final answer if its cached memory is both inaccurate and heavily scrutinized by the user's question. By selectively recomputing just the top fraction of these high-risk tokens on the fly, it cuts wait times more than in half while preserving most of the model's accuracy.
What Problem Does This Paper Address?
In Retrieval-Augmented Generation (RAG), we paste external documents into an LLM's prompt so it can answer questions with fresh facts. Because these retrieved chunks are long, reading them—the "prefill" stage—creates a massive bottleneck in Time-To-First-Token (TTFT), that awkward pause before the model starts typing.
To skip this bottleneck, systems precompute and save the LLM's internal Key and Value (KV) memory tensors for documents offline, loading them directly when needed. There is a catch, however: causal attention means tokens depend on what came before them. When you drop a pre-cached document chunk into a new prompt alongside different preceding chunks, its cached KV tensors miss that cross-document context. This "cached-chunk mismatch" ripples forward into the user's question (the suffix) and corrupts the generated answer.
Recent "selective recomputation" methods fix this by recalculating a small budget (say, 5%) of cached tokens online while reusing the rest. Yet existing methods pick tokens using single-signal rules of thumb—either looking only at how much a token's cache has drifted, or only at how much attention the query pays to it. Spend budget on a drifted token the question ignores, or an attended token whose cache is already fine, and you waste precious compute.
Methods
Instead of guessing which tokens matter, the authors trace how errors mathematically propagate through a transformer using a first-order perturbation analysis—tracking the mismatch from the cached chunk, into the suffix during prefill, and finally to the output logits.
The math reveals a clean multiplicative rule: a reused token's contribution to downstream error is proportional to the product of two local quantities. KVFocus turns this directly into a training-free, single-pass selector:
- Run a shallow check: Run layers 0 and 1 normally across the whole prompt. Because positional alignment makes layer 0 identical to offline caching, layer 1 is the earliest place where context mismatches surface.
- Score every reused token ($i$): At check layer $\ell^\star = 1$, compute the token-risk score $s_i = m_i \cdot U_i$:
- Value Deviation ($m_i$): The $L_2$ distance between the newly computed Value vector at layer 1 and the saved offline Value vector.
- Suffix Attention Mass ($U_i$): How strongly the end of the prompt (specifically, a probe of the last 5 suffix tokens) attends to token $i$, averaged across attention heads.
- Recompute the risky few: Rank all cached tokens globally across all chunks by $s_i$. For layers 2 through the end of the network, recompute only the top-$r\%$ tokens online, letting the remaining $(1-r)\%$ reuse their loaded disk caches and skip attention/MLP math.
Datasets
KVFocus is training-free and introduces no new benchmarks. The authors evaluate it across seven existing public datasets spanning three task types:
- Multi-hop RAG QA: 2WikiMQA, HotpotQA, MuSiQue, and MultiHop-RAG.
- Position-sensitive retrieval: Needle-in-a-Haystack.
- Summarization / Generation: SAMSum and Multi-News.
Key Insights and Ideas
- Multiplication beats addition: Ablation tests show that combining deviation ($m_i$) and attention ($U_i$) via addition ($m_i + U_i$) performs nearly identically to random token selection! Why? Because zeroing out either factor neutralizes a token's first-order harm; multiplication ($m_i \cdot U_i$) captures this physical reality, beating additive fusion by up to +0.327 F1.
- Deviation-only heuristics can do worse than doing nothing: On Needle-in-a-Haystack with Mistral-7B, ranking purely by cache deviation drops F1 to 0.195—worse than Naive Full Reuse (0.264). High-deviation tokens soak up the entire recompute budget even though the query barely looks at them, whereas KVFocus jumps to 0.588 F1.
- No extra forward pass needed: Attention-driven baselines like ProphetKV require a separate mask-scoring pass before prefill, hurting latency. Reading out both signals at layer 1 inside a single forward pass keeps overhead minimal.
Key Results
Tested on SGLang with an NVIDIA H200 GPU across Mistral-7B, Qwen2.5-7B, and Qwen3-8B:
- Speedup vs. Full Recomputation: At a $r=1\%$ recomputation rate, KVFocus achieves an average 2.22$\times$ TTFT speedup (peaking at 4.37$\times$ on long multi-hop QA) while retaining 82% of full-recomputation F1 quality (an 18% degradation).
- Beating fast baselines: At matched recomputation rates, KVFocus improves F1 by +0.081 over CacheBlend and +0.044 over EPIC. Under semantic LLM-as-a-judge evaluation, those margins roughly double (+0.162 and +0.095).
- Winning under real latency budgets: While ProphetKV edges out KVFocus by 0.016 F1 at fixed token rates, ProphetKV takes 1.71$\times$ longer. Under strict speedup targets ($\ge 1.5\times$ faster than full prefill), ProphetKV becomes completely infeasible due to its extra pass, while KVFocus remains feasible and consistently accurate.
Limitations and Future Work
- Not lossless: At small budgets ($r=1\%$), an 18% quality drop makes KVFocus unsuitable as a drop-in replacement for accuracy-critical deployments. Even an "oracle" selector peeking at exact final-layer errors cannot recover 100% of quality at small budgets, showing that closing the gap will require both better online proxies and higher recompute budgets.
- Short prompts don't benefit: Loading caches and running probe checks adds fixed overhead. On short inputs (below ~800 to 1,500 tokens, such as Multi-News), KVFocus is actually 1.27–1.56$\times$ slower than just running standard full prefill from scratch. It shines specifically on long-context RAG workloads.
Summary updated