KVFocus: A Perturbation-Theoretic Token-Risk Score for Selective KV Cache Reuse in RAG
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.