arXiv(opens in a new tab)cs.AIOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.03198

KV2^2: A Self-Refining KV Cache

Johannes Wesch, Danni Liu, Jan Niehues

Abstract

The memory footprint of the key-value (KV) cache constrains the practical use of long-context models, and it dominates cost when one prefilled context must later serve many different queries. In this reusable setting, query-agnostic compression trades cost against quality: lightweight estimators are cheap but less accurate, whereas full-context reconstruction scoring is more accurate yet reprocesses the entire prompt. We introduce KV 2^{2}, a query-agnostic KV-cache compression method based on selective reconstruction. KV 2^{2} first uses a lightweight proxy scorer to identify informative in-context tokens, then reprocesses only this subset to compute final eviction scores. On RULER, Needle-in-a-Haystack, and LongBench, KV 2^{2}'s margin over baselines widens as the budget tightens: on RULER 16K at a 2% KV-cache budget it improves the average score over the next-best baseline by more than 40 percentage points, and on LongBench it attains the highest average across 2%–10% budgets at lower compression-stage runtime and peak memory than full-context reconstruction. Reusable KV-cache compression thus does not require reprocessing the full context. Our code is available at https://anonymous.4open.science/r/KVsqared-0B97/.

1 Introduction

Long-context large language models have considerably broadened the range of LLM applications, including analyzing long documents (Bai et al., 2024; ?), reasoning over larger code bases (Bai et al., 2024; ?), and maintaining extended conversational histories (?). However, their practical use remains constrained by inference cost. A central reason is the key-value (KV) cache: once a context has been processed, the model must keep the resulting cached state available so that later tokens can attend to it without reprocessing. This cache grows linearly with context length, and increasingly dominates memory use during deployment.

Autoregressive inference separates into prefill and decode (Kim et al., 2025; Feng et al., 2025) stages. During prefill, the model processes the full prompt and computes keys and values for every layer, head, and token. For an L-layer Transformer decoder model with H key-value heads and a context of ncn_c tokens, this results in a cache KVcKV_c, consisting of L⋅H⋅ncL \cdot H \cdot n_c KV pairs. During decode, new tokens are generated one at a time, and each query attends to KVcKV_c instead of reprocessing all previous tokens. Because KVcKV_c stores the exact keys and values produced by prefill, decoding from it yields the same output distribution as re-running prefill on the full context at every step (Kim et al., 2025).

Maintaining this equivalence is what makes the cache expensive. Every context token contributes L⋅HL \cdot H new KV pairs to KVcKV_c, and the resident footprint grows accordingly. A 100K-token prompt on Qwen-2.5-32B already requires about 26 GB of KV memory (Chari and Van Durme, 2025), and a one-million-token cache for a 70B-scale model would require roughly 320 GB of GPU memory (Devoto et al., 2025a). Decoding is typically memory-bandwidth-bound, since each generation step rereads the cache from memory (Chari and Van Durme, 2025; Shazeer, 2019; Yang et al., 2024). Architectural choices such as Multi-Query Attention (MQA) (Shazeer, 2019) and Grouped Query Attention (GQA) (Ainslie et al., 2023a) reduce the baseline cache, but they do not remove the underlying KV-cache bottleneck. KV-cache compression is therefore essential for long-context deployment, where the goal is to replace KVcKV_c with a smaller cache KVc,evictedKV_{c,evicted} that approximately preserves the equivalence above.

Beyond these architectural reductions, prior work falls into two broad categories. The first improves attention kernels and serving systems, e.g., FlashAttention or PagedAttention (Dao, 2024;

Figure

Figure 1: Overview of KV 2^{2}. After prefilling the context cache KV c_{c}, the method computes proxy scores as a lightweight estimate of which in-context tokens are most informative. KV 2^{2} then selects the query tokens KV c_{c}, selected query tokens, runs Selective Reconstruction (SR) on these selected queries to obtain cache scores, and then evicts low-scoring KV entries before later decoding reuses the compressed cache.

Kwon et al., 2023), reducing realized memory and compute without altering what the cache stores. The second compresses the cache itself by evicting low-importance tokens (Xiao et al., 2024; Zhang et al., 2023), retaining evicted states in low precision (Yang et al., 2024), or pruning cache channels (Xu et al., 2025). Many recent eviction methods are query-aware: they keep entries based on a known downstream question or on a proxy for the next generation step (Li et al., 2024; Wang et al., 2025; Liu et al., 2026). This is effective when the next use of the cache is known, but less so when one compressed cache must remain useful across many later queries, e.g., for long-context question-answering or persistent agent contexts. Another line of work targets query-agnostic compression (Devoto et al., 2025a; Kim et al., 2025; Chari and Van Durme, 2025; Kim et al., 2026), which scores entries without reference to any specific downstream query, and is the focus of this work.

We introduce KV2KV^{2}, a query-agnostic KV-cache compression method aimed at the reusable setting described above 1^{1}: a single prefilled cache co-resides with other requests on the same device and must serve many later queries. This requirement easily pushes per-context budgets well below 10% of the original cache size, lower than the budgets typically studied in prior work (Gao et al., 2024; Srivatsa et al., 2024; Abhyankar et al., 2024; Devoto et al., 2025b). KV2KV^{2} is motivated by a simple observation: long-context models do not use all positions equally, and adding context can dilute the model's access to the tokens that genuinely impact downstream behavior (Liu et al., 2023). At such tight budgets, most positions are either trivial to retain (e.g., attention sinks) or trivial to evict (e.g., filler words and punctuation). The eviction decision therefore depends on a sparse set of informative anchors (Ainslie et al., 2023b; Xiao et al., 2024; Zhang et al., 2023). Yet, existing reconstruction-based methods score every cached entry uniformly, by recomputing attention output over the full context and measuring each position's contribution, which in turn pays the same cost for both trivial and informative tokens. Instead, we show that scoring a small, well-chosen set of in-context tokens often suffices to identify the cached entries that preserve the model's behavior on the original context.

KV2KV^{2} turns this intuition into a two-stage selective-reconstruction pipeline (Figure 1). A lightweight proxy scorer first identifies a small set of informative context tokens. These tokens are then used as reconstruction queries against the full cache to compute the final eviction scores. This concentrates the expensive scoring pass on the dependencies most likely to matter under severe compression, which both stabilizes the ranking and lowers compression-time cost. This two-stage design has two convenient properties: it is modular in the choice of the proxy scorer ( §5.2§5.2), and supports iterative self-refinement when additional compression-time compute is available ( §5.4§5.4).

Our main contributions are threefold:

• Selective reconstruction for reusable KV-cache compression. We introduce KV2KV^{2}, a query-agnostic two-stage method that uses a lightweight proxy to select a small set of in-context tokens and reprocesses only this subset to compute final eviction scores ( §3\S3).

• Strong performance under extreme compression. We evaluate down to 1–2% KV-cache bud-

1^{1}The superscript in KV2KV^{2} reflects the method’s two consecutive KV-based stages: proxy-based token selection followed by reconstruction-based final scoring.

gets, a highly deployment-relevant scenario imposed by the reusable setting and rarely studied in prior work, and find increasing gains of KV2KV^{2} over baselines as the budget tightens ( §4§4).

• Favorable efficiency profile. Compression-stage runtime and peak-memory measurements show that KV2KV^{2} offers a better quality–efficiency trade-off than applying full-context reconstruction scoring over every token ( §5.1§5.1).

References (15)