KVFocus: A Perturbation-Theoretic Token-Risk Score for Selective KV Cache Reuse in RAG

Shizhuo Zhang, Nuowen Kan, Chenglin Li, Ruixiao Zhang, Yifan Zhao, Yuanpeng He, Huixin Zhang, Fan He, Hang Xu, Hao Zhang, Wenrui Dai, Junni Zou, Hongkai XiongNeurIPS 2026

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.

Figure 1: (a) Only tokens that are both deviated (large mi) and heavily attended by the suffix (large Ui) substantially perturb the answer. Deviation-only methods (CacheBlend-like) rank tokens along the x-axis only; attention-aware methods (ProphetKV-like) rank along the y-axis only; KVFocus ranks by the product si = mi · Ui, with the dashed curves marking equal-score level sets. (b) Qualitative illustration of the quality-TTFT trade-off observed in our experiments (Section 4.1).

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:

  1. 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.
  2. Score every reused token ($i$): At check layer $\ell^\star = 1$, compute the token-risk score $s_i = m_i \cdot U_i$:
  3. Value Deviation ($m_i$): The $L_2$ distance between the newly computed Value vector at layer 1 and the saved offline Value vector.
  4. 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.
  5. 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.
Figure 2: System overview. (Left) K/V tensors of retrieved document chunks are computed during prior requests and persisted to disk. On a new request, cached chunks are loaded from disk and inserted between the online prefix and online suffix. (Right) At the check layer, the per-token value deviation mi and the suffix-probe attention mass Ui (downstream-side) are read out. Their product si = mi · Ui ranks tokens, and the top-r% are recomputed in the subsequent layers of the same prefill pass, while the rest continue to reuse the loaded cache.

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

Abstract

In retrieval-augmented generation (RAG) scenarios, the prefill delay of long inputs to large language models (LLMs) is the dominant component of the time-to-first-token (TTFT). Reusing KV caches across different LLM inputs reduces this cost, but the resulting cross-context mismatch on reused chunks significantly degrades answer quality as it propagates through prefill attention into decode-time logits. Existing selective-recomputation methods mitigate this issue by recomputing tokens chosen by empirical importance heuristics, which overlook the propagation of cache mismatches into answer-side errors, thereby failing to effectively strike the quality-TTFT trade-off. To address this issue, we propose a perturbation-theoretic KV cache reuse framework, KVFocus, which selects the reused tokens to recompute through a token-risk score during the prefill process. Specifically, we first develop a first-order perturbation analysis that traces reuse error in three stages: source mismatch on the reused region, suffix drift during prefill, and decode-time logit stability. This analysis reveals that the contribution of each reused token to the suffix-side drift is the product of its source-side cache deviation and the attention mass it receives from the suffix. Guided by this multiplicative structure, we define a token-risk score that can be computed at a single check layer. A plug-and-play selector is designed for existing RAG-based LLM serving systems to select the top-r% tokens ranked by this score for recomputation in subsequent layers of the same prefill pass. Empirical results across three 7B or 8B instruction-tuned LLMs (Mistral, Qwen2.5, Qwen3) and seven datasets demonstrate that KVFocus achieves a favorable trade-off between answer quality and TTFT compared with state-of-the-art baselines. Compared to full recomputation, KVFocus achieves an average 2.22× TTFT speedup at the cost of an 18% quality degradation.
BibTeX
@inproceedings{zhang2026kvfocus,
  author = {Shizhuo Zhang and Nuowen Kan and Chenglin Li and Ruixiao Zhang and Yifan Zhao and Yuanpeng He and Huixin Zhang and Fan He and Hang Xu and Hao Zhang and Wenrui Dai and Junni Zou and Hongkai Xiong},
  title = {{KVFocus: A Perturbation-Theoretic Token-Risk Score for Selective KV Cache Reuse in RAG}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=tTROr3ucO0},
}

Loading related content...

Figure