alphaFeedback

WorksComputer Science

The KV-Surgeon: Compensation-Aware Offline KV-Cache Compaction

AI contributions
Not recorded for this paper
View details
Ancillary data
1 code link
View

Abstract

Offline compaction of the key–value cache (KV-cache) reduces the cost of repeatedly querying a fixed context by constructing a smaller cache once and reusing it subsequently. The central challenge of compaction is deciding which cache entries to delete and which to retain. Existing methods score each candidate for deletion on its own, with the rest of the cache being held fixed. However, softmax renormalization of the attention operation couples these decisions in a nonlinear manner: removing one entry changes the attention weights of every remaining one. In this work, we introduce KV-Surgeon, which uses calibration data to take interactions into account in a tractable way. We derive a quadratic surrogate that admits closed-form expressions for jointly making the optimal greedy removal decision as well as compensation within the remaining entries. On QuALITY, LongHealth, and Long Code Arena, and at every evaluated compaction ratio, KV-Surgeon substantially advances the cost–accuracy Pareto frontier of dense and mixture-of-experts models from 4B to 30B parameters. At 50×50\times compaction, KV-Surgeon improves question-answering accuracy by up to four points over attention matching (Zweiger et al., 2026), the state of the art, at comparable cost. Lastly, we introduce an even faster variant, which also exceeds the state of the art while requiring only two fifths of its cost.

Introduction

Many large language model (LLM) applications repeatedly query a fixed context such as a document, patient record, or codebase. The key–value cache (KV-cache) for such a context grows linearly with its length and occupies a large fraction of the memory used during long-context inference. Every attention layer reads this cache for every generated token, so every request pays for its size in both memory and latency. Offline compaction reduces this cost by processing the context once and compressing the resulting cache, which is then used to serve all later requests ([6, 17, 34]).

Unlike serving-time eviction, which discards cache entries within the forward pass of a request ([33, 19]), offline compaction can spend a larger one-time budget that is amortized over future requests. In particular, it can use calibration queries, i.e., query vectors the model produces while re-reading or discussing the context, to decide which entries to retain. Eyuboglu et al. [6] introduce this regime with Cartridges, which trains a new latent cache per context. More recent work makes offline compaction much cheaper by replacing end-to-end training with eviction-inspired selection and efficient optimization of the remaining cache (Zweiger et al. [34]).

The central problem in cache compaction is deciding which cache entries can be removed while preserving the resulting attention outputs. For one attention head, a cache of TT entries contains a key kj∈Rdkk_j \in\mathbb{R}^{d_k} and a value vj∈Rdvv_j \in\mathbb{R}^{d_v} at each position j=1,…,Tj = 1,\ldots,T. A query q∈Rdkq \in\mathbb{R}^{d_k} produces

P≜softmax⁡((qTkℓdk)ℓ=1T)∈RT,o≜∑j=1TPjvj∈Rdv,P \triangleq\operatorname{softmax}\left(\left(\frac{q^\mathsf{T} k_\ell}{\sqrt{d_k}}\right)_{\ell=1}^{T}\right) \in\mathbb{R}^{T}, \qquad o \triangleq\sum_{j=1}^{T} P_j v_j \in\mathbb{R}^{d_v},

where PjP_j is the attention weight of entry jj and oo is the resulting output. Removing cache entry jj does not simply subtract PjvjP_jv_j, since softmax renormalization changes the attention weights of all remaining entries. The effect of one deletion therefore depends on which other entries remain, making selection a combinatorial problem rather than a ranking problem. Scores based only on received attention, as in attention matching Zweiger et al., [34], additionally overlook value redundancy: if an entry’s value is close to the output the head already produces, i.e., ∥vj−o∥2\lVert v_j-o\rVert_2 is small, removing it might change the output little, even when its attention weight is large. Good selection must therefore account not only for the contribution of each entry, but also for how deletions interact.

Recent output-aware methods instead estimate the output error caused by deleting a single entry [10, 2, 13, 7]. CAOTE Goel et al., [10] derives the exact change caused by deleting one entry for a single calibration query, and OBCache Gu et al., [13] uses a Taylor approximation of the attention output error aggregated across queries. These methods nevertheless evaluate the deletion of one entry while the rest of the cache is held fixed. Attention matching Zweiger et al., [34] refits the retained cache to minimize the error of the compacted output, but only after the retained set has been chosen. What is missing is compensation-aware selection: each candidate deletion should be scored by the error remaining after the surviving entries have been adjusted to compensate for it, so that selection and refitting are optimized jointly rather than in sequence. This is difficult under softmax attention because deletion changes the normalization itself, so the error after both deletion and compensation has no obvious closed form.

In this work, we substantially advance the cost–accuracy Pareto frontier for offline KV-cache compaction. We derive a quadratic surrogate that makes compensation-aware selection tractable. We introduce KV-SURGEON, which uses this surrogate for greedy, compensation-aware elimination. For each candidate deletion, the surrogate admits closed-form expressions for both the optimal compensating update and the resulting increase in surrogate loss. Each candidate entry is assigned a score after the remaining entries have been adjusted to compensate for its removal, and the update is then applied to the cache, so the next deletion is chosen against the compensated entries, as Optimal Brain Surgeon (OBS) Hassibi & Stork, [15] does for network weights.

We evaluate KV-SURGEON on QuALITY, LongHealth, and Long Code Arena, using dense and mixture-of-experts models from 4B to 30B parameters and compaction ratios from 5× to 100×. Across these settings, KV-SURGEON improves the cost–accuracy frontier at every ratio, achieving higher mean accuracy at comparable cost. Mean question-answering accuracy across our experiments exceeds the state of the art by 4.3 percentage points at 100× compaction and 3.0 percentage points at 50×. The gains are less pronounced at 5× and 10×, where the strongest methods already suffer almost no deterioration relative to the uncompacted cache. At 50×50 \times compaction the state of the art, attention matching with its AM-HAK selection rule [34], reaches 62.0% accuracy in 138 seconds2 per context. KV-SURGEON reaches 65.1% in 145 seconds, and KV-SURGEON-fast reaches 63.9% in 54 seconds. Figure 1 shows the resulting frontier at 50×50 \times compaction on the largest model we evaluate.

Cost–accuracy frontier plot

Figure 1. Cost–accuracy frontier at 50× KV-cache compaction on QuALITY with Qwen3-30B-A3B. KV-SURGEON reaches 72.5% accuracy in 159 seconds and KV-SURGEON-fast reaches 71.4% in 54 seconds. Pipeline time per context includes calibration-query generation and compaction. OBCache, KVMerger, and KVzip are adapted to our pipeline (Appendix § 13). Points are five-seed means. The solid and dash-dotted curves are the Pareto frontiers with and without our methods.

Our contributions are the following.

  1. _Quadratic surrogate._ We derive a quadratic surrogate to the exact attention-output error, which allows us to design efficient methods for approximately solving the compaction problem.

  1. _Compensation-aware selection._ Based on this surrogate, we introduce KV-SURGEON, which iteratively removes entries while adjusting the remaining entries in closed form after each deletion, then jointly refits the retained cache. Unlike prior output-aware scores or post-selection refitting, compensation directly influences which entries are retained.

  1. _A new cost–accuracy Pareto frontier._ Across QuALITY, LongHealth, and Long Code Arena, dense and mixture-of-experts models from 4B to 30B parameters, and 5×5 \times to 100×100 \times compaction, KV-SURGEON substantially advances the frontier, with gains at every evaluated ratio and the largest improvements at 50×50 \times and 100×100 \times. We show empirically that accounting for compensation during selection substantially improves accuracy over exact single-deletion scoring.

Related work

Other forms of KV-cache compression. KV-caches can be compressed along several axes. Quantization lowers the precision of stored keys and values [22, 16], and low-rank methods reduce the feature dimension [26, 4]. Both are complementary to reducing the number of entries. A different route, _LLM summarization_, shortens the text input itself by prompting an LLM to summarize it. This approach transfers across models, but gives no direct control over cache size. We study compaction along the sequence dimension, where a fixed budget of entries is retained from an already computed cache.

Offline compaction. Offline methods exploit contexts that are processed once and queried repeatedly. Cartridges [6] trains a new latent cache per context from self-generated data. KVzip [17] removes cache entries based on the attention they receive while the model repeats the context verbatim. Attention matching [34] also keeps a subset of the original keys, then fits a scalar logit bias per retained key and refits the stored values to reproduce the original attention outputs on reference queries. Its AM-HAK variant selects entries by root-mean-square attention, and AM-OMP, based on orthogonal matching pursuit (OMP), greedily selects keys so that their reweighted attention reproduces the attention mass of the full cache. In both, the support is chosen from attention statistics before the values are refit, so the ability of the retained entries to reproduce the output does not influence selection.

Eviction by proxy scores. Serving-time eviction discards entries within a single request, ranking each one by a score that ignores the rest of the cache: accumulated attention, as in H2O [33] and related methods [24, 19, 21], or a query-free proxy such as position [30], key norm [5], alignment with a principal query direction [9], deviation from neighboring keys [20], or value norm [14]. Merging methods soften the same decision by folding evicted entries into retained ones. KVMerger [29] merges similar entries into attention-weighted pivots, and Zhang et al. [32]; Wan et al. [28]; Nawrot et al. [23] use related rules. In all of these, the score of an entry is fixed before any other entry is removed.

Output-aware eviction. More recent methods score entries directly through the attention-output error induced by their removal [10, 2, 13, 7]. CAOTE [10] and ReST-KV [2] derive the exact effect of deleting one entry for one query. OBCache [13] derives a second-order approximation in the style of Optimal Brain Damage LeCun et al., [18]. CriticalKV Feng et al., [7] considers deletion of an arbitrary set for one query and derives an additive upper bound on the resulting output error for selection. These methods differ in how they estimate deletion error, but share a common restriction: candidates are evaluated with the retained cache held fixed.

Our work starts from the same output-reconstruction objective as CAOTE, ReST-KV, and OBCache but changes how it is used for selection. Instead of scoring one deletion against a fixed cache, we derive a quadratic surrogate of the output error over arbitrary deletions and reweightings of the retained entries, aggregated over many calibration queries, and let the retained entries compensate during greedy deletion of cache entries.

KV-Surgeon

In this section, we present our method for offline KV-cache compaction, KV-Surgeon. It compacts each attention head independently by selecting which original cache entries to delete, accounting for how the remaining entries can compensate for deleted ones, and then refits the retained entries to preserve the behavior of the original cache.

Problem formulation

We consider one layer and one attention head with TT cache entries. Cache entry jj consists of a key kj∈Rdkk_j \in\mathbb{R}^{d_k} and a value vj∈Rdvv_j \in\mathbb{R}^{d_v}. We describe the behavior of the head on NN calibration queries q1,…,qN∈Rdkq_1,\ldots,q_N \in\mathbb{R}^{d_k} recorded from the model itself as described in § 4.1. For query ii and cache entry jj, the corresponding logit is Zij≜qiTkj/dkZ_{ij} \triangleq q_i^{\mathsf{T}}k_j/\sqrt{d_k}. The attention weight and output are

Pij≜eZij∑ℓ=1TeZiℓ,oi≜∑j=1TPijvj.(1)P_{ij} \triangleq\frac{e^{Z_{ij}}}{\sum_{\ell=1}^{T}e^{Z_{i\ell}}}, \qquad o_i \triangleq\sum_{j=1}^{T}P_{ij}v_j. \tag*{(1)}

Let V∈RT×dvV \in\mathbb{R}^{T \times d_v} collect the values as rows and P∈RN×TP \in\mathbb{R}^{N \times T} the attention weights. The corresponding output matrix is then O=PV∈RN×dvO = PV \in\mathbb{R}^{N \times d_v}.

Compacted cache. Given a budget t<Tt < T, which is allocated per head, we retain tt cache entries corresponding to some index set S⊂{1,…,T}S \subset\{1,\ldots,T\} with ∣S∣=t|S| = t, which we call the support. Each retained entry j∈Sj \in S keeps its original key kjk_j and is assigned an adapted value v^j∈Rdv\widehat{v}_j \in\mathbb{R}^{d_v} and a positive attention multiplier wj>0w_j > 0, which rescales the contribution of its entry before the softmax normalization. Together, the remaining keys kjk_j, adapted values v^j\widehat{v}_j, and attention multipliers wjw_j form the compacted cache. For query ii and entry jj, the attention weights and output of the compacted cache are given by

P^ij≜wjeZij∑ℓ∈SwℓeZiℓ=wjPij∑ℓ∈SwℓPiℓ=wjPijμi,o^i≜∑j∈SP^ijv^j=1μi∑j∈SPijwjv^j.(2)\widehat{P}_{ij} \triangleq\frac{w_j e^{Z_{ij}}}{\sum_{\ell\in S}w_\ell e^{Z_{i\ell}}} = \frac{w_jP_{ij}}{\sum_{\ell\in S}w_\ell P_{i\ell}} = \frac{w_jP_{ij}}{\mu_i}, \qquad\widehat{o}_i \triangleq\sum_{j \in S}\widehat{P}_{ij}\widehat{v}_j = \frac{1}{\mu_i}\sum_{j \in S}P_{ij}w_j\widehat{v}_j. \tag*{(2)}

Here,

μi≜∑j∈SPijwj=∑j∈SwjeZij∑ℓ=1TeZiℓ(3)\mu_i \triangleq\sum_{j \in S}P_{ij}w_j = \frac{\sum_{j \in S}w_j e^{Z_{ij}}}{\sum_{\ell=1}^{T}e^{Z_{i\ell}}} \tag*{(3)}

is the ratio between the compacted and original attention normalization terms. Let PS∈RN×∣S∣P_S \in\mathbb{R}^{N \times|S|} contain the columns of PP indexed by SS, let w∈R∣S∣w \in\mathbb{R}^{|S|} collect the multipliers, and let V^∈R∣S∣×dv\widehat{V} \in\mathbb{R}^{|S| \times d_v} collect the new values as rows. The vector of the normalization ratios is then μ≜(μ1,…,μN)T=PSw\mu\triangleq(\mu_1,\ldots,\mu_N)^{\mathsf{T}} = P_Sw and the output of the compacted cache is O^=diag⁡(PSw)−1PSdiag⁡(w)V^\widehat{O} = \operatorname{diag}(P_Sw)^{-1}P_S\operatorname{diag}(w)\widehat{V}.

Compaction objective. Our goal is for the compacted cache to preserve two properties of the original cache. First, its attention outputs O^\widehat{O} should be close to the outputs OO of the original, uncompacted cache. We measure the output error by

L(S,w,V^)≜∥O^−O∥F2.(4)\mathcal{L}(S,w,\widehat{V}) \triangleq\lVert\widehat{O} - O \rVert_F^2. \tag*{(4)}

Second, when combined with other context, such as a question, a system prompt, or other compacted chunks, its entries should collectively receive approximately the same share of attention as the original cache entries, i.e., ∑j∈SwjeZij≈∑j=1TeZij\sum_{j\in S} w_j e^{Z_{ij}} \approx\sum_{j=1}^{T} e^{Z_{ij}}. Output preservation alone does not ensure this: scaling all wjw_j by the same constant leaves O^\hat{O} unchanged but changes this sum. For a more detailed discussion, see Appendix § 14.

On the calibration queries, we express these two goals as follows, using the ratio μ\mu of the compacted and original normalization terms defined in (3)

O^≈O,μ=PSw≈1.(5)\hat{O} \approx O,\qquad\mu= P_S w \approx1. \tag*{(5)}

Tractable surrogate

Choosing the optimal support SS is difficult even if we consider only output preservation. For a fixed support SS, the output error L(S,w,V^)\mathcal{L}(S,w,\hat{V}) depends on how well the multipliers ww and values V^\hat{V} can be adjusted, so evaluating all (Tt)\binom{T}{t} possible supports is infeasible. In order to approximate this objective, we start from a larger support and sequentially delete entries. However, even assessing the cost of deleting one entry j∈Sj\in S requires re-optimizing ww and V^\hat{V} on S∖{j}S\setminus\{j\}. Doing that for every candidate deletion at every step is still prohibitively expensive.

We therefore seek a surrogate objective that makes it inexpensive to compare candidate deletions while accounting for how the remaining entries can compensate. After removing an entry, we also want to reuse previous computations to evaluate the next deletions efficiently. Starting from (5), we derive a quadratic surrogate with these properties.

Attention as a ratio of two linear terms. We introduce the variable U≜diag⁡(w)V^∈R∣S∣×dvU \triangleq\operatorname{diag}(w)\hat{V}\in\mathbb{R}^{|S|\times d_v}, whose row corresponding to entry j∈Sj\in S is uj=wjv^jTu_j = w_j\hat{v}_j^{\mathsf{T}} and which absorbs the attention multipliers ww into the values V^\hat{V}. This is an exact change of variables: since wj>0w_j>0, we can recover the original values as v^j=uj/wj\hat{v}_j=u_j/w_j. Substituting into (2), the output of the compacted cache can be written as the ratio

o^i=niμi,ni≜∑j∈SPijuj∈Rdv,μi=∑j∈SPijwj∈R.(6)\hat{o}_i = \frac{n_i}{\mu_i},\qquad n_i \triangleq\sum_{j\in S} P_{ij}u_j\in\mathbb{R}^{d_v},\qquad\mu_i = \sum_{j\in S}P_{ij}w_j\in\mathbb{R}. \tag*{(6)}

The numerator nin_i and the denominator μi\mu_i are linear in UU and ww, respectively.

For the original cache, the numerator is ∑j=1TPijvj=oi\sum_{j=1}^{T}P_{ij}v_j=o_i and the denominator is ∑j=1TPij=1\sum_{j=1}^{T}P_{ij}=1, since every row of PP sums to one. Instead of searching for an o^i\hat{o}_i matching this ratio, we ask the compacted cache to reproduce numerator and denominator separately, ni≈oin_i\approx o_i and μi≈1\mu_i\approx1. The second condition is the mass requirement of (5), and together they imply o^i≈oi\hat{o}_i\approx o_i. Define the residuals ri≜ni−oir_i\triangleq n_i-o_i and εi≜μi−1\varepsilon_i\triangleq\mu_i-1,

o^i−oi=ni−μioiμi=ri−εioiμi,hence∥o^i−oi∥2≤∥ri∥2+∥εi∥∥oi∥2μi.(7)\hat{o}_i-o_i=\frac{n_i-\mu_i o_i}{\mu_i}=\frac{r_i-\varepsilon_i o_i}{\mu_i},\qquad\text{hence}\qquad\lVert\hat{o}_i-o_i\rVert_2\leq\frac{\lVert r_i\rVert_2+\lVert\varepsilon_i\rVert\lVert o_i\rVert_2}{\mu_i}. \tag*{(7)}

The output error is thus small whenever both residuals are small: a small εi\varepsilon_i also keeps μi\mu_i close to one.

Quadratic surrogate. We construct a surrogate of (4) by summing the squared residuals from (7) over all queries. In matrix form, the rir_i are the rows of PSU−O∈RN×dvP_S U-O\in\mathbb{R}^{N\times d_v}, and the εi\varepsilon_i are the entries of μ−1=PSw−1∈RN\mu-1=P_Sw-1\in\mathbb{R}^{N}. A weight γ2>0\gamma^2>0 controls the relative importance of mass preservation (see Appendix § 7.§ 3), giving

∥O−PSU∥F2+γ2∥1−PSw∥22=∥[O  γ1]−PS[U  γw]∥F2.(8)\lVert O-P_S U\rVert_F^2+\gamma^2\lVert1-P_Sw\rVert_2^2=\lVert[O\ \ \gamma1]-P_S[U\ \ \gamma w]\rVert_F^2. \tag*{(8)}

The original loss (4) couples ww and V^\hat{V} through their products and the division by μi\mu_i, whereas for a fixed support SS, the quadratic surrogate separates the optimization of UU and ww into two linear least-squares problems with the same design matrix PS∈RN×∣S∣P_S\in\mathbb{R}^{N\times|S|}. The right-hand side stacks the targets into [O  γ1]∈RN×(dv+1)[O\ \ \gamma1]\in\mathbb{R}^{N\times(d_v+1)} and the coefficients into [U  γw]∈R∣S∣×(dv+1)[U\ \ \gamma w]\in\mathbb{R}^{|S|\times(d_v+1)}, yielding a single linear least-squares problem with dv+1d_v+1 target columns.

Support-selection score. In (8), UU is unconstrained, since any UU is attained by V^=diag⁡(w)−1U\widehat{V} = \operatorname{diag}(w)^{-1}U, but the last column of [U γw][U\ \gamma w] is constrained by w>0w > 0. To obtain an unconstrained quadratic problem, we remove this constraint and replace [U γw][U\ \gamma w] with a free matrix B∈R∣S∣×(dv+1)B \in\mathbb{R}^{|S| \times(d_v+1)}. Each row of BB corresponds to a retained cache entry jj: its first dvd_v coefficients replace the weighted value wjv~jw_j\widetilde{v}_j, and its last coefficient replaces the scaled attention multiplier γwj\gamma w_j. These coefficients need not correspond to a valid compacted cache because the last coefficient can be negative. In practice, fewer than half a percent of the retained entries end with a negative coefficient in the last column (Appendix § 15), and valid multipliers are restored by the final refit (§ 3.4).

Finally, we add a small ridge penalty so that the regression has a unique solution for every support. With Y≜[O γ1]∈RN×(dv+1)Y \triangleq[O\ \gamma1] \in\mathbb{R}^{N \times(d_v+1)}, we define the support score

F(S)≜min⁡B∥Y−PSB∥F2+λ∥B∥F2,λ>0.(9)\mathcal{F}(S) \triangleq\min_B \|Y - P_S B\|_F^2 + \lambda\|B\|_F^2,\qquad\lambda> 0. \tag*{(9)}

YY and λ\lambda stay fixed during support selection: YY depends only on the original cache, and λ\lambda is set once per head (Appendix § 8). For a fixed support SS, F(S)\mathcal{F}(S) is the minimum value of this quadratic objective after optimizing all coefficients in BB. Changing SS changes the available columns of PSP_S and therefore also the optimal coefficients: removing an entry requires the remaining coefficients to compensate for its absence.

Greedy elimination with closed-form compensation

With the support score F(S)\mathcal{F}(S) in place, we now develop a greedy elimination algorithm that uses it to choose which cache entries to retain. Starting from a support larger than the target budget tt, we repeatedly remove the entry whose deletion causes the smallest increase in F(S)\mathcal{F}(S), allowing the remaining coefficients to compensate at each step. The quadratic structure of (9) lets us compute both these loss increases and the compensating updates in closed form, using an approach developed in the pruning literature ([15, 8]). We first describe the optimal coefficients on the current support, then show how to evaluate and apply a deletion.

Optimal coefficients on the current support. Each column of BB contains the coefficients used to reconstruct one target column of YY: either an output coordinate or the attention mass. In (9), these linear least-squares problems all have the same Hessian 2(PSTPS+λI)2(P_S^\mathsf{T}P_S + \lambda I) (see Appendix § 7.§ 2). A single ∣S∣×∣S∣|S| \times|S| inverse GG therefore suffices for all columns. Writing BB and GG for the optimal coefficients and shared inverse on the current support SS, we have

B=GPSTY∈R∣S∣×(dv+1),G≜(PSTPS+λI)−1∈R∣S∣×∣S∣.(10)B = G P_S^\mathsf{T}Y \in\mathbb{R}^{|S| \times(d_v+1)},\qquad G \triangleq(P_S^\mathsf{T}P_S + \lambda I)^{-1} \in\mathbb{R}^{|S| \times|S|}. \tag*{(10)}

The current BB and GG suffice to evaluate every candidate deletion and obtain the optimal coefficients afterward, without solving another regression problem. For an entry j∈Sj \in S, we define its saliency sjs_j as the increase in the optimal surrogate objective when that entry is removed:

sj≜F(S∖{j})−F(S)=∥Bj,:∥22Gjj.(11)s_j \triangleq\mathcal{F}(S \setminus\{j\}) - \mathcal{F}(S) = \frac{\|B_{j,:}\|_2^2}{G_{jj}}. \tag*{(11)}

The saliency sjs_j measures the surrogate loss increase after the remaining coefficients have been re-optimized. An entry can make a large contribution to the original outputs yet have low saliency if other retained entries can compensate for its removal.

Once an entry jj is selected for removal, we obtain the optimal coefficients and inverse for the reduced support directly from the current matrices. Writing −j-j for the indices in S∖{j}S \setminus\{j\}, the updates are

B←B−j,:−G−j,jBj,:Gjj,G←G−j,−j−G−j,jGj,−jGjj.(12)B \leftarrow B_{-j,:} - \frac{G_{-j,j}B_{j,:}}{G_{jj}},\qquad G \leftarrow G_{-j,-j} - \frac{G_{-j,j}G_{j,-j}}{G_{jj}}. \tag*{(12)}

The updated BB is the exact minimizer of (9) on S∖{j}S \setminus\{j\}, and GG is the corresponding inverse Gram matrix. We repeatedly remove the entry with the smallest current saliency, update BB and GG, and recompute the remaining saliencies until ∣S∣=t|S| = t, without solving another regression problem from scratch. A detailed derivation is given in Appendix § 7.§ 4.

Implementation details

KV-Surgeon builds on the greedy elimination process described above, with a few practical additions. To reduce computational cost, we restrict the initial set of candidates, delete entries in blocks, and use a cheaper selection rule for heads that retain a relatively large fraction of their original cache entries. After selecting the support, we refit the attention multipliers ww and values V^\hat{V} to obtain a valid compacted cache. Algorithm 1 summarizes the complete method. We describe these additions below, with further implementation details in Appendix § 8 and ablations in Appendix § 11.§ 3.

Algorithm 1 KV-Surgeon for one attention head

Require: keys K∈RT×dkK \in\mathbb{R}^{T \times d_k}, values V∈RT×dvV \in\mathbb{R}^{T \times d_v}, calibration queries Q∈RN×dkQ \in\mathbb{R}^{N \times d_k}, cache budget tt, pool factor cc, block size nbn_b, relative ridge λ0\lambda_0, mass weight γ0\gamma_0, fallback threshold τ\tau, multiplier bound β\beta

  1. P←softmax⁡(QK⊤/dk)P \gets\operatorname{softmax}(QK^\top/\sqrt{d_k}) row-wise, O←PVO \gets PV

  2. sjLOO←∑i=1NPij2(1−Pij)2∥vj−oi∥22s_j^{\mathrm{LOO}} \gets\sum_{i=1}^{N} \frac{P_{ij}^{2}}{(1-P_{ij})^{2}}\lVert v_j-o_i\rVert_{2}^{2} for j=1,…,Tj=1,\ldots,T

  3. if t>τTt > \tau T then ▷ mild-compaction fallback

  4. S←S \gets indices of the tt largest sjLOOs_j^{\mathrm{LOO}}

  5. return SS, w=1w=1, V^=VS,:\hat{V}=V_{S,:}

  6. end if

  7. m←min⁡{T,⌈ct⌉}m \gets\min\{T,\lceil ct\rceil\}, S←S \gets indices of the mm largest sjLOOs_j^{\mathrm{LOO}} ▷ select candidate pool

  8. γ←γ0RMS⁡i∥oi∥2\gamma\gets\gamma_0\operatorname{RMS}_i\lVert o_i\rVert_2, Y←[O γ1]Y \gets[O\ \gamma\mathbf{1}]

  9. λ←λ0tr⁡(PS⊤PS)/m\lambda\gets\lambda_0\operatorname{tr}(P_S^\top P_S)/m

  10. G←(PS⊤PS+λI)−1G \gets(P_S^\top P_S+\lambda I)^{-1}, B←GPS⊤YB \gets GP_S^\top Y

  11. while ∣S∣>t|S|>t do ▷ greedy elimination

  12. sj←∥B:,j∥22/Gjjs_j \gets\lVert B_{:,j}\rVert_2^2/G_{jj} for j∈Sj\in S

  13. J←J \gets the min⁡{nb,∣S∣−t}\min\{n_b,|S|-t\} entries of SS with the smallest sjs_j

  14. R←S∖JR \gets S\setminus J

  15. B←BR,:−GR,JGJ,J−1BJ,:B \gets B_{R,:}-G_{R,J}G_{J,J}^{-1}B_{J,:}

  16. G←GR,R−GR,JGJ,J−1GJ,RG \gets G_{R,R}-G_{R,J}G_{J,J}^{-1}G_{J,R}

  17. S←RS \gets R

  18. end while

  19. w←arg min⁡e−β≤wj≤eβ∥1−PSw∥22w \gets\operatorname*{arg\,min}_{e^{-\beta}\leq w_j\leq e^\beta}\lVert\mathbf{1}-P_Sw\rVert_2^2 ▷ final refit of attention multipliers

  20. P^←diag⁡(PSw)−1PSdiag⁡(w)\hat{P} \gets\operatorname{diag}(P_Sw)^{-1}P_S\operatorname{diag}(w)

  21. V^←arg min⁡V^∥P^V^−O∥F2\hat{V} \gets\operatorname*{arg\,min}_{\hat{V}}\lVert\hat{P}\hat{V}-O\rVert_F^2 ▷ final refit of values

  22. return S,w,V^S,w,\hat{V}

Candidate pool. To limit the size of GG and the number of deletion steps, we first rank entries by a leave-one-out (LOO) score. We obtain it by removing entry jj in (2), keeping unit multipliers and the remaining values unchanged, and evaluating the output-preservation loss (4):

sjLOO≜∑i=1NPij2(1−Pij)2∥vj−oi∥22.(13)s_j^{\mathrm{LOO}} \mathrel{\triangleq} \sum_{i=1}^{N}\frac{P_{ij}^{2}}{(1-P_{ij})^{2}}\lVert v_j-o_i\rVert_2^2. \tag*{(13)}

LOO measures the exact output error on the original cache without adjusting the remaining entries, whereas the saliency in (11) measures the surrogate loss increase accounting for compensation. We keep the m=min⁡{T,⌈ct⌉}m=\min\{T,\lceil ct\rceil\} entries with the largest sjLOOs_j^{\mathrm{LOO}} and perform greedy elimination only on this pool, using c=4c=4. We also use (13) directly as the score of the LOO baseline (§ 4.1). The score derivation and pool-size ablation are given in Appendix § 7.§ 5 and Appendix § 11.§ 3, respectively.

Block deletion. We select a block J⊂SJ\subset S containing the entries with the smallest current saliencies. Analogously to (12), the optimal coefficients and inverse for the reduced support R=S∖JR=S\setminus J are obtained by

B←BR,:−GR,JGJ,J−1BJ,:;G←GR,R−GR,JGJ,J−1GJ,R,R≜S∖J.(14)B \gets B_{R,:}-G_{R,J}G_{J,J}^{-1}B_{J,:};\qquad G \gets G_{R,R}-G_{R,J}G_{J,J}^{-1}G_{J,R},\qquad R \mathrel{\triangleq} S\setminus J. \tag*{(14)}

For any selected block JJ, these updates give the exact minimizer of the surrogate on S∖JS\setminus J. Selecting JJ by individual saliencies, however, need not minimize the joint deletion cost. Empirically, deleting multiple entries at once improves efficiency without hurting performance. Further implementation details are given in Appendix § 8.

Final refit. The support-selection procedure determines which entries to retain, but the unconstrained coefficients BB need not represent a valid compacted cache. We therefore discard BB and GG and refit the multipliers ww and values V^\hat{V} on the selected support SS. Following Zweiger et al. [34], we first minimize ∥1−PSw∥22\lVert1-P_{S}w\rVert_{2}^{2} subject to box constraints on ww, obtaining positive multipliers that preserve the original attention mass as closely as possible. We then fix ww and optimize V^\hat{V} to minimize the output-preservation loss (4). The resulting cache retains the original keys with refitted multipliers and values. See Appendix § 8 for further details.

Mild-compaction fallback. For heads that retain a relatively large fraction of their original cache entries, we skip greedy elimination and the final refit, retaining the tt entries with the largest LOO scores, their original values, and unit multipliers. Since these heads undergo little compaction, this simpler procedure reduces computation with negligible accuracy loss. Further implementation details are given in Appendix § 8 and the corresponding ablation in Appendix § 11.§ 3.

Experiments

We compare KV-SURGEON to existing methods and show that it improves the cost–accuracy frontier across different models, benchmarks, and compaction ratios. We then analyze which part of the algorithm is the source of this improvement through controlled ablations. Finally, we study how much of the gain is retained when self-study calibration is replaced by a single repeat pass. Our code is available at github.com/ZIB-IOL/KV-Surgeon.

Experimental setup

Benchmarks and models. We evaluate offline KV-cache compaction on long-context multiple-choice question-answering tasks from QuALITY [25] and LongHealth [1], and code completion tasks from Long Code Arena [3], where each compacted context is reused across many questions. We evaluate five models, Qwen3-4B, Qwen3-4B-Instruct-2507, Llama-3.1-8B-Instruct, Gemma-3-12B, and Qwen3-30B-A3B [31, 11, 27], spanning three model families, dense and mixture-of-experts architectures, and different attention variants. Qwen3-4B-Instruct-2507 replaces Qwen3-4B on LongHealth and Long Code Arena because it supports longer contexts. We consider {100×,50×,20×,10×,5×}\{100\times,50\times,20\times,10\times,5\times\} compaction, with 50×50\times as the primary operating point. Dataset construction and evaluation details are given in Appendix § 9.

Protocol. All accuracies are means over five random seeds, with one standard error reported in the tables. All methods shown in the main comparison, except LLM summarization, use heterogeneous allocation of the global cache budget across heads. The allocation is computed once per model on data disjoint from the evaluation benchmarks following Zweiger et al. [34] and kept fixed between methods. All methods using calibration additionally share the attention-multiplier parameterization and final cache refit of § 3, so their comparisons isolate differences in support selection. KV-SURGEON hyperparameters are fixed once on Qwen3-4B with QuALITY at 50× compaction and reused for all other models, benchmarks, and compaction ratios, i.e., KV-SURGEON does not require per-model or per-benchmark tuning.

Calibration and cost. To collect calibration queries, we use two different approaches. Cheap calibration queries are obtained by a repeat pass, which concatenates the context with a “repeat verbatim” prompt and another copy of the context (Kim et al., [17]). For self-study, the more expensive approach, we prompt the model to discuss the context multiple times and record the queries produced during answer generation (Eyuboglu et al., [6]). The suffix -fast denotes repeat-pass calibration for KV-SURGEON and AM-HAK. AM-OMP-CS is the cheap-solver setting of Zweiger et al. [34], named AM-OMP-fast in the original work, and uses self-study queries. Pipeline time covers calibration-query generation and compaction, but excludes the context prefill shared by all methods and preprocessing performed once per model. Further timing and calibration details are given in Appendix § 9.

Baselines. Our main prior baseline is attention matching (Zweiger et al., [34]), for which we evaluate both AM-HighestAttentionKeys (AM-HAK) and AM-OMP using the authors’ implementation and hyperparameters. We also adapt several serving-time eviction methods to the offline setting (Appendix § 13) and include our adaptation of OBCache in the main experiments. LOO ranks entries by the exact single-deletion score of (13) and shares KV-SURGEON’s calibration queries, head-budget allocation, and final refit, providing a controlled comparison to independent selection. We additionally include LLM summarization and query-free baselines (Appendix § 10).

KV-Surgeon improves the cost–accuracy frontier

At 50× compaction, both KV-SURGEON and KV-SURGEON-fast exceed the prior state of the art (Table 1). KV-SURGEON-fast reaches 63.9% mean accuracy in 54 seconds per context, compared with 63.2% for AM-OMP in 763 seconds, a 14.1× reduction in pipeline time. Self-study calibration improves KV-SURGEON further to 65.1% in 145 seconds, 1.9 percentage points above AM-OMP at 5.3× lower time. At comparable cost, KV-SURGEON-fast is 3.3 percentage points ahead of adapted OBCache, while KV-SURGEON is 3.0 points ahead of AM-HAK.

MethodTime (s)Qwen3-4B QuAL.Qwen3-4B LongH.Llama-3.1-8B QuAL.Llama-3.1-8B LongH.Gemma-3-12B QuAL.Gemma-3-12B LongH.Qwen3-30B QuAL.Qwen3-30B LongH.Mean
Repeat-pass
KV-SURGEON-fast (ours)5465.9 ±0.466.9 ±0.561.0 ±0.461.5 ±0.668.1 ±0.552.1 ±0.471.4 ±0.364.1 ±0.263.9 ±0.15
OBCache (adapted)5862.4 ±0.762.8 ±0.959.8 ±0.352.4 ±0.266.6 ±0.450.2 ±0.867.3 ±0.462.8 ±0.460.5 ±0.20
AM-HAK-fast5458.1 ±0.553.5 ±1.358.7 ±0.653.5 ±1.162.2 ±0.445.6 ±1.265.8 ±0.559.8 ±0.657.1 ±0.30
Self-study
KV-SURGEON (ours)14566.8 ±0.367.8 ±0.862.3 ±0.562.1 ±0.367.5 ±0.756.4 ±0.772.5 ±0.665.2 ±0.465.1 ±0.20
LOO13965.6 ±0.264.2 ±1.261.2 ±0.759.1 ±0.665.1 ±0.549.6 ±0.769.6 ±0.362.3 ±0.762.1 ±0.24
AM-HAK13864.1 ±0.965.0 ±0.860.4 ±0.558.2 ±0.565.1 ±0.352.7 ±1.469.5 ±0.361.4 ±0.462.0 ±0.26
AM-OMP-CS26665.7 ±0.465.9 ±1.160.6 ±0.855.8 ±0.967.2 ±0.250.9 ±0.869.7 ±0.563.1 ±0.262.4 ±0.24
AM-OMP76366.4 ±0.265.5 ±0.661.3 ±0.657.3 ±0.967.7 ±0.354.5 ±0.969.2 ±0.463.9 ±0.663.2 ±0.22
Q-Filters (query-free)1.652.4 ±0.543.6 ±0.447.7 ±0.836.1 ±1.155.9 ±0.339.0 ±0.750.9 ±0.343.2 ±0.546.1 ±0.22
Summarization5.151.2 ±0.528.0 ±0.746.7 ±0.331.5 ±0.750.2 ±0.439.4 ±0.454.2 ±0.647.2 ±0.643.6 ±0.19
Full context–72.1 ±0.380.5 ±0.862.7 ±0.573.0 ±0.870.6 ±0.474.5 ±0.480.7 ±0.478.3 ±0.574.0 ±0.19

Table 1. Accuracy (%) at 50× compaction. Entries are means over five seeds with standard error over seeds in grey. Within each group and column, bold denotes the highest mean and underlining denotes results that trail the highest mean by at most two standard errors of the difference. The Qwen3-4B column uses Qwen3-4B on QuALITY and Qwen3-4B-Instruct-2507 on LongHealth. Summarization uses the prompt whose summary length is closest to 50× compaction (Appendix § 10). The Mean column contains the means over the eight model–benchmark pairs, and Time is the geometric mean of pipeline time per context in seconds.

These gains are consistent across models and benchmarks. For both calibration methods, KV-SURGEON is best or tied for best within uncertainty on all eight model–benchmark pairs, while KV-SURGEON-fast is ahead of every other repeat-pass method beyond uncertainty. Thus, the more expensive AM-OMP variants no longer lie on the cost–accuracy frontier at our primary operating point (Figure 1).

The advantage of KV-SURGEON also persists across compaction ratios. Figure 2 shows mean accuracy over the eight model–benchmark pairs relative to KV-SURGEON. All prior methods are worse by more than two standard errors at every compaction ratio. The gap is largest between 100× and 20× compaction and narrows at 10× and 5×, where all methods approach the performance of the full-context ceiling. We therefore focus the analysis below on large compaction ratios, where support selection has the largest effect.

Mean accuracy relative to KV-SURGEON across compaction ratios

Figure 2. Mean accuracy over the eight pairs of Table 1 relative to KV-SURGEON. Error bars are one standard error of the difference. AM-OMP and AM-OMP-CS are shown only at the ratios their solver reaches on every model and benchmark.

The same compute-time advantage transfers to project-level code completion on Long Code Arena (Table 12, Appendix § 10.§ 1). At 50×, KV-SURGEON and KV-SURGEON-fast match AM-OMP within uncertainty while using 9.7 and 21.5 times less compute time, respectively. At 20×, KV-SURGEON has the highest point estimate, with AM-OMP-CS the only prior method within uncertainty at 6.7 times higher cost.

Table 12: Code completion accuracy (%) and pipeline time vs. compaction ratio on Long Code Arena project-level code completion with Qwen3-4B-Instruct-2507 (20 Python repository snapshots, n=650n = 650 next-line completions, exact match of the first generated line). Each entry is the mean over five seeds; the grey number is the standard error over seeds. Time is average query-generation plus compaction wall-clock per repository, in seconds. Full-context ceiling: 40.6%. The best accuracy per ratio is bold; underlined entries are within 2se2+sebest22\sqrt{\mathrm{se}^{2}+\mathrm{se}_{\mathrm{best}}^{2}} of the best. ‘–’ marks ratios the AM-OMP solvers do not reach.

MethodAccuracy (%)Time (s)
100×50×20×10×5×100×50×20×10×5×
StreamingLLM22.6 ±0.223.3 ±0.222.0 ±0.124.5 ±0.132.5 ±0.17.628.077.788.188.39
L2 key-norm23.2 ±0.123.4 ±0.123.4 ±0.223.4 ±0.127.6 ±0.27.458.558.777.708.12
Q-Filters22.8 ±0.122.4 ±0.223.8 ±0.127.4 ±0.134.7 ±0.27.117.417.508.027.82
KVzip20.5 ±0.222.4 ±0.228.6 ±0.436.2 ±0.538.3 ±0.2217232292379596
H2O22.5 ±0.124.1 ±0.330.9 ±0.236.4 ±0.239.4 ±0.2221230307385572
KVMerger13.5 ±0.215.1 ±0.224.4 ±0.131.7 ±0.235.9 ±0.24905546889621293
OBCache22.0 ±0.225.4 ±0.332.7 ±0.237.2 ±0.239.2 ±0.3235243309391554
AM-HAK-fast22.2 ±0.423.7 ±0.332.4 ±0.137.4 ±0.139.1 ±0.3222245287384536
AM-HAK22.7 ±0.324.6 ±0.531.0 ±0.237.2 ±0.339.1 ±0.2437448505628846
AM-OMP-CS23.1 ±0.425.5 ±0.333.3 ±0.3––64911105128––
AM-OMP23.5 ±0.327.0 ±0.4–––16465037–––
LOO22.6 ±0.325.3 ±0.232.5 ±0.237.2 ±0.238.8 ±0.4444469534661872
KV-SURGEON-fast22.8 ±0.226.5 ±0.233.1 ±0.336.9 ±0.239.8 ±0.1204234297407542
KV-SURGEON23.6 ±0.326.8 ±0.433.9 ±0.238.1 ±0.339.7 ±0.24745197718751322

Table 12.

Sources of the performance gain

The gain over independent selection comes from compensating the surviving cache entries as the support changes. To isolate this effect, we keep the surrogate, candidate pool, calibration queries, and final refit fixed and disable only the compensating update: we delete entries based on the saliency ((11)) but do not apply the update ((12)) to the remaining entries, so the saliencies stay fixed and the elimination reduces to a single ranking of the candidate pool. At 50× compaction on Qwen3-4B with QuALITY, this reduces accuracy from 66.9% to 63.9% (Table 2). KV-SURGEON without compensation also performs similarly to LOO, which uses the different deletion rule ((13)) and does not adapt the remaining entries at all. Replacing the saliency score alone does not explain the improvement. Rather, the gain comes from updating the remaining entries during selection. Additional controls that remove the opportunity for iterative compensation lead to the same conclusion (Appendices § 11 and § 12).

MethodSelection ruleCompensationAccuracy (%)
KV-SURGEON(11)✓66.9
KV-SURGEON w/o compensation(11)✗63.9
LOO(13)✗64.7

Table 2. Qwen3-4B on QuALITY (first 25 articles) at 50× compaction. We compare the impact of compensation during selection. We vary the selection rule, i.e., the saliency by which entries are ranked for deletion, and whether the surviving entries are updated after each deletion.

The improvement is also not an artifact of the optimized allocation of the global cache budget across heads inherited from [34]. Under uniform allocation, KV-SURGEON remains 3.0 accuracy points ahead of AM-HAK (Appendix § 11). Compensation-aware support selection therefore provides an improvement that is orthogonal to that of the offline-compaction pipeline proposed by Zweiger et al. [34].

Cheap calibration preserves most of the gain

KV-SURGEON is comparatively insensitive to how calibration queries are collected. Replacing self-study with a single repeat pass reduces pipeline time from 145 to 54 seconds per context at 50× compaction while reducing mean accuracy by only 1.2 points. The same change is substantially more costly for AM-HAK, which loses 4.9 points (Table 1). This makes KV-SURGEON-fast not only cheaper, but sufficient to outperform all prior methods at the primary operating point.

This robustness persists across compaction ratios. Replacing self-study with repeat-pass calibration costs KV-SURGEON at most 1.2 points of mean accuracy at any compaction ratio, with gap shrinking as more cache entries are retained. Detailed results across ratios are reported in Appendix § 10; Appendix § 12 offers a hypothesis for this robustness.

Conclusion

Prior offline KV-cache compaction methods first deleted cache entries and then adapted the remaining ones. We showed that deletion and adaptation can be coupled efficiently, and that doing so improves accuracy. We derived a quadratic surrogate of the attention-output error that allows for an efficient greedy algorithm with compensation-aware selection: every candidate deletion is scored after the retained entries have compensated for it. The resulting method, KV-SURGEON, improves the cost–accuracy frontier at every compaction ratio on QuALITY, LongHealth, and Long Code Arena with models from 4B to 30B parameters, and its fast variant exceeds all prior methods at two fifths of the cost of the strongest baseline. A controlled comparison attributes the gain over independent selection to compensation during selection, not to the surrogate.

Acknowledgment

This research was partially supported by the DFG Cluster of Excellence MATH+ (EXC-2046/2, project id 390685689) funded by the Deutsche Forschungsgemeinschaft (DFG) as well as by the German Federal Ministry of Research, Technology and Space (research campus Modal, fund number 05M14ZAM, 05M20ZBM) and the VDI/VDE Innovation + Technik GmbH (fund number 16IS23025B).

We would also like to thank the Speinshart Scientific Center for AI and SuperTech, where part of this work was conducted, for providing such a stimulating research environment.

Derivations

The surrogate as a second-order Taylor expansion

An alternative route to the same surrogate starts with the exact output loss after substituting U=diag⁡(w)V^U = \operatorname{diag}(w)\widehat{V}:

L(S,w,V^)=∑i=1N1μi2∥(∑j∈SPijuj−oi)+(1−μi)oi∥22.(15)\mathcal{L}(S,w,\widehat{V}) = \sum_{i=1}^{N} \frac{1}{\mu_i^2}\left\lVert\left(\sum_{j\in S}P_{ij}u_j-o_i\right)+(1-\mu_i)o_i\right\rVert_2^2. \tag*{(15)}

Replacing μi−2\mu_i^{-2} by its value of one at the original cache gives the quadratic

Q(S,w,U)≜∑i=1N∥∑j∈SPijuj−μioi∥22.(16)Q(S,w,U) \triangleq\sum_{i=1}^{N}\left\lVert\sum_{j\in S}P_{ij}u_j-\mu_i o_i\right\rVert_2^2. \tag*{(16)}

Dropping the cross term between the output and mass residuals separates the two terms:

∥O−PSU∥F2+∑i=1N∥oi∥22(1−(PSw)i)2.(17)\lVert O-P_SU\rVert_F^2+\sum_{i=1}^{N}\lVert o_i\rVert_2^2\left(1-(P_Sw)_i\right)^2. \tag*{(17)}

Replacing the query-dependent weights ∥oi∥2\lVert o_i\rVert_2 by the shared γ\gamma then gives (8). The quadratic QQ in (16) is the second-order Taylor expansion of L\mathcal{L} around the original cache. This supplies an alternative derivation of the surrogate in § 3.2. The method represents a deletion by removing an index from SS, and a support SS and the original cache have parameters of different sizes. To place them in a common coordinate system we use, in this proof only, a full-length multiplier vector m∈RTm\in\mathbb{R}^{T} with mj=wjm_j=w_j for j∈Sj\in S and mj=0m_j=0 otherwise, and U~∈RT×dv\widetilde{U}\in\mathbb{R}^{T\times d_v} with rows mjvjm_jv_j, which vanish outside SS. Then ∑j∈SPijuj=PiU~\sum_{j\in S}P_{ij}u_j=P_i\widetilde{U} and μi=Pim\mu_i=P_im, where PiP_i is row ii of PP, so that

L=∑i=1N∥PiU~−(Pim)oi∥22(Pim)2,Q=∑i=1N∥PiU~−(Pim)oi∥22\mathcal{L}=\sum_{i=1}^{N}\frac{\left\lVert P_i\widetilde{U}-(P_im)o_i\right\rVert_2^2}{(P_im)^2},\qquad Q=\sum_{i=1}^{N}\left\lVert P_i\widetilde{U}-(P_im)o_i\right\rVert_2^2

are functions of (U~,m)∈RT×dv×RT(\widetilde{U},m)\in\mathbb{R}^{T\times d_v}\times\mathbb{R}^{T} whose domain contains the original cache (U~,m)=(V,1)(\widetilde{U},m)=(V,1). There the vector inside the norms is PiV−(Pi1)oi=oi−oi=0P_iV-(P_i1)o_i=o_i-o_i=0 for every query, because PiV=oiP_iV=o_i by the definition of OO and Pi1=1P_i1=1 since every row of PP is a softmax; hence L\mathcal{L} and QQ vanish together with their gradients. Write (U~,m)=(V+ΔU,1+Δm)(\widetilde{U},m)=(V+\Delta_U,1+\Delta_m). Substituting, the vector inside the norms becomes Pi(V+ΔU)−(Pi(1+Δm))oi=(PiV−oi)+PiΔU−(PiΔm)oi=PiΔU−(PiΔm)oiP_i(V+\Delta_U)-(P_i(1+\Delta_m))o_i=(P_iV-o_i)+P_i\Delta_U-(P_i\Delta_m)o_i=P_i\Delta_U-(P_i\Delta_m)o_i, again by PiV=oiP_iV=o_i and Pi1=1P_i1=1. So its squared norm is a homogeneous quadratic in the perturbation, while (Pim)−2=1−2PiΔm+O(∥Δm∥22)(P_im)^{-2}=1-2P_i\Delta_m+O(\lVert\Delta_m\rVert_2^2). Hence L=Q+O(∥(ΔU,Δm)∥3)\mathcal{L}=Q+O(\lVert(\Delta_U,\Delta_m)\rVert^3), and QQ, itself a quadratic, is the second-order Taylor polynomial of L\mathcal{L} at the original cache. As in OBS (Hassibi & Stork, [15]), the expansion is then used at deletions, which move mjm_j from one to zero and row jj of U~\widetilde{U} from vjv_j to zero and are not small perturbations.

For unchanged values, U~=diag⁡(m)V\widetilde{U}=\operatorname{diag}(m)V, the two terms inside the norms are Pidiag⁡(m)V=∑jmjPijvjP_i\operatorname{diag}(m)V=\sum_jm_jP_{ij}v_j and (Pim)oi=∑jmjPijoi(P_im)o_i=\sum_jm_jP_{ij}o_i, so the vector inside the norms is ∑jmjPij(vj−oi)\sum_jm_jP_{ij}(v_j-o_i) and the frozen quadratic is the quadratic form

Q=m⊤Hm,Hjk≜∑i=1NPijPik(vj−oi)⊤(vk−oi).Q=m^\top Hm,\qquad H_{jk}\triangleq\sum_{i=1}^{N}P_{ij}P_{ik}(v_j-o_i)^\top(v_k-o_i).

Its off-diagonal entries record whether the errors of deleting jj and kk reinforce or cancel. Its diagonal Hjj=∑iPij2∥vj−oi∥22H_{jj}=\sum_iP_{ij}^2\lVert v_j-o_i\rVert_2^2 is the second-order truncation of the exact single-deletion loss, the score of (13) without the factor $(1-P_{ij})^{-2} {xref}(Appendix A.5). Finally, $H1=0$ because $\sum_kP_{ik}(v_k-o_i)=0$. This is the null direction of the Hessian along uniform scalings of all weights, which leave the ratio of {xref}(2) unchanged; the frozen quadratic alone therefore does not determine the scale of the multipliers, and the mass term of {xref}(8) does {xref}(Appendices A.3 and H.1`.

Hessian structure of the surrogate

We compare the quadratic objectives of § 3.2 through their Hessians in the unknowns (U,w)(U,w). Stack the unknowns as x≜(U:,1,…,U:,dv,w)∈R∣S∣(dv+1)x \triangleq(U_{:,1},\ldots,U_{:,d_v},w) \in\mathbb{R}^{|S|(d_v+1)}, where U:,cU_{:,c} is column cc of UU, and write O:,cO_{:,c} for column cc of OO.

After freezing the normalization. The frozen objective (16) is ∥PSU−diag⁡(PSw)O∥F2\|P_SU-\operatorname{diag}(P_Sw)O\|_F^2. Column cc of diag⁡(PSw)O\operatorname{diag}(P_Sw)O is diag⁡(O:,c)PSw\operatorname{diag}(O_{:,c})P_Sw, so

∑i=1N∥(∑j∈SPijuj−oi)+(1−μi)oi∥22=∑c=1dv∥PSU:,c−diag⁡(O:,c)PSw∥22.\sum_{i=1}^{N}\left\|\left(\sum_{j\in S}P_{ij}u_j-o_i\right)+(1-\mu_i)o_i\right\|_2^2=\sum_{c=1}^{d_v}\|P_SU_{:,c}-\operatorname{diag}(O_{:,c})P_Sw\|_2^2.

This is a quadratic in xx. Its Hessian has the diagonal blocks 2PSTPS2P_S^{\mathsf T}P_S for each column U:,cU_{:,c}, the diagonal block 2PSTdiag⁡(∥o1∥22,…,∥oN∥22)PS2P_S^{\mathsf T}\operatorname{diag}(\|o_1\|_2^2,\ldots,\|o_N\|_2^2)P_S for ww, and the off-diagonal blocks −2PSTdiag⁡(O:,c)PS-2P_S^{\mathsf T}\operatorname{diag}(O_{:,c})P_S between U:,cU_{:,c} and ww. The off-diagonal blocks are the Hessian of the cross term in (16): expanding the square gives 2∑i∑jPijuj−oi, (1−μi)oi⟩2\sum_i\sum_j P_{ij}u_j-o_i,\ (1-\mu_i)o_i\rangle, whose bilinear part in (U,w)(U,w) is −2∑cU:,cTPSTdiag⁡(O:,c)PSw-2\sum_c U_{:,c}^{\mathsf T}P_S^{\mathsf T}\operatorname{diag}(O_{:,c})P_Sw. Because of these blocks, the columns of UU and the multipliers are not separate regressions on PSP_S. Scoring a deletion, or computing the coefficients after one, requires the inverse of the full Hessian of dimension ∣S∣(dv+1)|S|(d_v+1) instead of an ∣S∣×∣S∣|S|\times|S| matrix, which multiplies the memory by (dv+1)2(d_v+1)^2 and the cost of every update by at least the same factor.

After dropping the cross term. The objective (17) is a function of UU plus a function of ww, so its Hessian is block diagonal, with the blocks 2PSTPS2P_S^{\mathsf T}P_S for the columns of UU and the block 2PSTdiag⁡(∥o1∥22,…,∥oN∥22)PS2P_S^{\mathsf T}\operatorname{diag}(\|o_1\|_2^2,\ldots,\|o_N\|_2^2)P_S for ww. Every column can be optimized on its own. The multipliers, however, have a different Gram matrix from the values, so greedy elimination would carry two inverses and update both after every deletion.

After replacing the weights by γ\gamma. In (8) the mass term is γ2∥1−PSw∥22=∥γ1−PS(γw)∥22\gamma^2\|1-P_Sw\|_2^2=\|\gamma1-P_S(\gamma w)\|_2^2, a regression of the column γ1\gamma1 on PSP_S in the unknown γw\gamma w, with Gram matrix PSTPSP_S^{\mathsf T}P_S. All dv+1d_v+1 diagonal blocks of the Hessian are now 2PSTPS2P_S^{\mathsf T}P_S and there are no off-diagonal blocks. The ridge in (9) adds 2λI2\lambda I to each block, so the Hessian of (9) in BB consists of dv+1d_v+1 identical blocks 2(PSTPS+λI)2(P_S^{\mathsf T}P_S+\lambda I).

Closed form. Expanding (9) gives

∥Y−PSB∥F2+λ∥B∥F2=tr⁡(YTY)−2tr⁡(BTPSTY)+tr⁡(BT(PSTPS+λI)B).\|Y-P_SB\|_F^2+\lambda\|B\|_F^2=\operatorname{tr}(Y^{\mathsf T}Y)-2\operatorname{tr}(B^{\mathsf T}P_S^{\mathsf T}Y)+\operatorname{tr}\left(B^{\mathsf T}(P_S^{\mathsf T}P_S+\lambda I)B\right).

The matrix PSTPS+λIP_S^{\mathsf T}P_S+\lambda I is positive definite for λ>0\lambda>0, since xT(PSTPS+λI)x=∥PSx∥22+λ∥x∥22>0x^{\mathsf T}(P_S^{\mathsf T}P_S+\lambda I)x=\|P_Sx\|_2^2+\lambda\|x\|_2^2>0 for x≠0x\ne0. The objective is therefore strictly convex in BB, and its unique minimizer is the stationary point (PSTPS+λI)B=PSTY(P_S^{\mathsf T}P_S+\lambda I)B=P_S^{\mathsf T}Y, that is, B=GPSTYB=GP_S^{\mathsf T}Y with G=(PSTPS+λI)−1G=(P_S^{\mathsf T}P_S+\lambda I)^{-1}, which is (10). Column cc of BB is GPSTY:,cGP_S^{\mathsf T}Y_{:,c}, so one inverse serves all columns. Inserting the minimizer and using (PSTPS+λI)B=PSTY(P_S^{\mathsf T}P_S+\lambda I)B=P_S^{\mathsf T}Y for the first equality and G(PSTPS+λI)G=GG(P_S^{\mathsf T}P_S+\lambda I)G=G for the second,

F(S)=tr⁡(YTY)−tr⁡(BT(PSTPS+λI)B)=tr⁡(YTY)−tr⁡(YTPSGPSTY).(18)\mathcal{F}(S)=\operatorname{tr}(Y^{\mathsf T}Y)-\operatorname{tr}\left(B^{\mathsf T}(P_S^{\mathsf T}P_S+\lambda I)B\right)=\operatorname{tr}(Y^{\mathsf T}Y)-\operatorname{tr}\left(Y^{\mathsf T}P_SGP_S^{\mathsf T}Y\right). \tag*{(18)}

Scale of the mass term

In (17) the mass error of query ii is weighted by ∥oi∥22\|o_i\|_2^2: a query with a large output is hurt more by a given relative mass deficit. These weights depend neither on ww nor on SS, so the mass term of (17) could be minimized as it stands, with the Gram matrix PSTdiag⁡(∥o1∥22,…,∥oN∥22)PSP_S^{\mathsf T}\operatorname{diag}(\|o_1\|_2^2,\ldots,\|o_N\|_2^2)P_S. Carrying it through the elimination would require a second inverse next to GG, updated after every deletion. Replacing ∥oi∥2\|o_i\|_2 by one common scalar γ\gamma gives the mass term the Gram matrix PSTPSP_S^{\mathsf T}P_S of the output term, so that one inverse serves all dv+1d_v+1 columns (Appendix § 7.§ 2).

We set γ≜γ0RMS⁡i∥oi∥2=γ0(N−1∑i∥oi∥22)1/2\gamma\triangleq\gamma_0\operatorname{RMS}_i\|o_i\|_2=\gamma_0\left(N^{-1}\sum_i\|o_i\|_2^2\right)^{1/2} with a dimensionless γ0>0\gamma_0>0. The RMS keeps the mass column of YY on the scale of the output columns: for a uniform relative mass deficit 1−μi≡ϵ1-\mu_i\equiv\epsilon, the mass term of (17) is ϵ2∑i∥oi∥22\epsilon^2\sum_i\|o_i\|_2^2 and that of (8) is Nγ02ϵ2N\gamma_0^2\epsilon^2, and the two agree for every ϵ\epsilon if and only if γ0=1\gamma_0=1. The factor γ0\gamma_0 therefore sets the weight of the mass term relative to the output term, with γ0=1\gamma_0=1 matching the cost that a uniform deficit has under (17). We use γ0=1\gamma_0=1 throughout (Appendix § 9). Setting γ0=0\gamma_0=0 removes the mass term from the surrogate and changes accuracy without one standard error (Appendix § 11.§ 3).

Deletion saliencies and compensation

We derive the saliency (11) and the updates (12) and (14) from the block structure of the inverse GG. Throughout, SS is the current support, A≔PSTPS+λIA \coloneqq P_S^{\mathsf T}P_S+\lambda I, G=A−1G=A^{-1}, and B=GPSTYB=GP_S^{\mathsf T}Y as in (10). Rows and columns of AA, GG, and BB are indexed by the elements of SS, so that an entry keeps its index when other entries are deleted. For j∈Sj\in S, −j-j denotes the index set S∖{j}S\setminus\{j\}: G−j,−jG_{-j,-j} is GG without row and column jj, G−j,jG_{-j,j} is column jj of GG without its jj-th entry, and B−j,:B_{-j,:} is BB without row jj. We write pj∈RNp_j\in\mathbb{R}^N for column jj of PP, the attention weights of all queries on entry jj.

Deleting an entry removes a row and a column of AA. Entry (k,l)(k,l) of PSTPSP_S^{\mathsf T}P_S is pkTplp_k^{\mathsf T}p_l and involves only the columns kk and ll. Removing column jj from PSP_S removes row and column jj from PSTPSP_S^{\mathsf T}P_S and changes no other entry, and λI\lambda I loses the same row and column. The Gram matrix of the reduced support is therefore the principal submatrix

PS∖{j}TPS∖{j}+λI=A−j,−j.(19)P_{S\setminus\{j\}}^{\mathsf T}P_{S\setminus\{j\}}+\lambda I=A_{-j,-j}. \tag*{(19)}

This requires the same λ\lambda on both supports: a ridge that changes with SS would change the remaining entries as well.

Block inverse. The block equations of AG=IAG=I for the partition ({j},−j)\left(\{j\},-j\right) are

AjjGjj+Aj,−jG−j,j=1,A−j,jGjj+A−j,−jG−j,j=0,A−j,jGj,−j+A−j,−jG−j,−j=I.A_{jj}G_{jj}+A_{j,-j}G_{-j,j}=1,\qquad A_{-j,j}G_{jj}+A_{-j,-j}G_{-j,j}=0,\qquad A_{-j,j}G_{j,-j}+A_{-j,-j}G_{-j,-j}=I.

A−j,−jA_{-j,-j} is invertible as a principal submatrix of a positive definite matrix, and Gjj=ejTA−1ej>0G_{jj}=e_j^{\mathsf T}A^{-1}e_j>0. The second equation gives A−j,j=−A−j,−jG−j,j/GjjA_{-j,j}=-A_{-j,-j}G_{-j,j}/G_{jj}, and substituting this into the third gives A−j,−j(G−j,−j−G−j,jGj,−j/Gjj)=IA_{-j,-j}\left(G_{-j,-j}-G_{-j,j}G_{j,-j}/G_{jj}\right)=I. Hence

(A−j,−j)−1=G−j,−j−G−j,jGj,−jGjj,1Gjj=Ajj−Aj,−j(A−j,−j)−1A−j,j.(20)\left(A_{-j,-j}\right)^{-1}=G_{-j,-j}-\frac{G_{-j,j}G_{j,-j}}{G_{jj}},\qquad\frac{1}{G_{jj}}=A_{jj}-A_{j,-j}\left(A_{-j,-j}\right)^{-1}A_{-j,j}. \tag*{(20)}

where the second identity follows from the first block equation after inserting (A−j,−j)−1A−j,j=−G−j,j/Gjj\left(A_{-j,-j}\right)^{-1}A_{-j,j}=-G_{-j,j}/G_{jj}. Equivalently, the matrix Mj≔G−G:,jGj,:/GjjM_j\coloneqq G-G_{:,j}G_{j,:}/G_{jj} has zero row jj and zero column jj, and its remaining block is (A−j,−j)−1\left(A_{-j,-j}\right)^{-1}.

The update of GG. By (19), the inverse Gram matrix of S∖{j}S\setminus\{j\} is (A−j,−j)−1\left(A_{-j,-j}\right)^{-1}, which by (20) is the second update in (12).

The update of BB. Since Gj,:PSTY=Bj,:G_{j,:}P_S^{\mathsf T}Y=B_{j,:},

MjPSTY=B−G:,jBj,:Gjj.M_jP_S^{\mathsf T}Y=B-\frac{G_{:,j}B_{j,:}}{G_{jj}}.

Row jj of this matrix is zero because row jj of MjM_j is zero. Because column jj of MjM_j is zero as well, the rows −j-j of MjPSTYM_jP_S^{\mathsf T}Y equal (Mj)−j,−jPS∖{j}TY=(A−j,−j)−1PS∖{j}TY(M_j)_{-j,-j}P_{S\setminus\{j\}}^{\mathsf T}Y=\left(A_{-j,-j}\right)^{-1}P_{S\setminus\{j\}}^{\mathsf T}Y, which by (19) is the minimizer (10) on the reduced support. These rows are B−j,:−G−j,jBj,:/GjjB_{-j,:}-G_{-j,j}B_{j,:}/G_{jj}, the first update in (12). The updated coefficients are thus the exact minimizer of (9) on S∖{j}S\setminus\{j\}, not an approximation to it.

The saliency. Applying (18) on both supports, the term tr⁡(YTY)\operatorname{tr}(Y^{\mathsf T}Y) cancels in F(S∖{j})−F(S)F(S\setminus\{j\})-F(S). Since MjM_j vanishes on row and column jj, PS∖{j}(A−j,−j)−1PS∖{j}T=PSMjPSTP_{S\setminus\{j\}}\left(A_{-j,-j}\right)^{-1}P_{S\setminus\{j\}}^{\mathsf T}=P_SM_jP_S^{\mathsf T}, and therefore

sj=F(S∖{j})−F(S)=tr⁡(YTPS(G−Mj)PSTY)=tr⁡(YTPSG:,jGj,:PSTY)Gjj=∥Gj,:PSTY∥22Gjj=∥Bj,:∥22Gjj,\begin{aligned} s_j=F(S\setminus\{j\})-F(S)=\operatorname{tr}\left(Y^{\mathsf T}P_S(G-M_j)P_S^{\mathsf T}Y\right)=\frac{\operatorname{tr}\left(Y^{\mathsf T}P_SG_{:,j}G_{j,:}P_S^{\mathsf T}Y\right)}{G_{jj}} \\ &=\frac{\left\|G_{j,:}P_S^{\mathsf T}Y\right\|_2^2}{G_{jj}}=\frac{\left\|B_{j,:}\right\|_2^2}{G_{jj}}, \end{aligned}

which is (11).

Interpretation. A coefficient matrix with Bj,:′=0B'_{j,:}=0 has the same objective value on SS as its rows −j-j have on S∖{j}S\setminus\{j\}, since row jj multiplies column jj of PSP_S and contributes nothing to the ridge penalty, and every coefficient matrix on S∖{j}S\setminus\{j\} arises in this way. Hence F(S∖{j})=min⁡{∥Y−PSB′∥F2+λ∥B′∥F2:Bj,:′=0}≥F(S)F(S\setminus\{j\})=\min\{\|Y-P_SB'\|_F^2+\lambda\|B'\|_F^2:B'_{j,:}=0\}\geq F(S), and sjs_j is the smallest increase of the objective over all coefficient matrices with zero row jj. The objective is a quadratic in BB with Hessian 2A2A and zero gradient at the minimizer, so ∥Y−PS(B+Δ)∥F2+λ∥B+Δ∥F2=F(S)+tr⁡(ΔTAΔ)\lVert Y-P_S(B+\Delta)\rVert_F^2+\lambda\lVert B+\Delta\rVert_F^2=\mathcal{F}(S)+\operatorname{tr}(\Delta^{\mathsf{T}}A\Delta) for every Δ\Delta. Setting row jj to zero without changing the other rows, Δ=−ejBj,:\Delta=-e_jB_{j,:}, increases the objective by Ajj∥Bj,:∥22A_{jj}\lVert B_{j,:}\rVert_2^2. Since AjjGjj≥1A_{jj}G_{jj}\ge1 for positive definite AA (Cauchy–Schwarz in the inner product defined by AA: 1=(ejTej)2≤(ejTAej)(ejTA−1ej)1=(e_j^{\mathsf{T}}e_j)^2\le(e_j^{\mathsf{T}}Ae_j)(e_j^{\mathsf{T}}A^{-1}e_j)), the compensated cost sjs_j is at most the uncompensated one, with equality if and only if pjp_j is orthogonal to all other retained columns. By (20) and (18) with the target pjp_j,

1Gjj=λ+∥pj∥22−pjTPS∖{j}(PS∖{j}TPS∖{j}+λI)−1PS∖{j}Tpj=λ+min⁡c∥pj−PS∖{j}c∥22+λ∥c∥22,\frac{1}{G_{jj}}=\lambda+\lVert p_j\rVert_2^2-p_j^{\mathsf{T}}P_{S\setminus\{j\}}\left(P_{S\setminus\{j\}}^{\mathsf{T}}P_{S\setminus\{j\}}+\lambda I\right)^{-1}P_{S\setminus\{j\}}^{\mathsf{T}}p_j=\lambda+\min_c\lVert p_j-P_{S\setminus\{j\}}c\rVert_2^2+\lambda\lVert c\rVert_2^2,

the ridge-regularized residual of regressing the attention column of entry jj on the attention columns of the other retained entries. The saliency is therefore the squared coefficient magnitude of entry jj times the part of its attention column that the other retained columns do not reproduce, plus the ridge. An entry with a large coefficient is cheap to delete when its attention column lies close to the span of the other columns, and an entry with a small coefficient is expensive to delete when its attention column lies far from that span.

Deleting a block. Let J⊆SJ\subseteq S and R≜S∖JR\triangleq S\setminus J. The block equations of AG=IAG=I on the partition (J,R)(J,R) read AR,JGJ,J+AR,RGR,J=0A_{R,J}G_{J,J}+A_{R,R}G_{R,J}=0 and AR,JGJ,R+AR,RGR,R=IA_{R,J}G_{J,R}+A_{R,R}G_{R,R}=I, and GJ,JG_{J,J} is positive definite as a principal submatrix of GG. Eliminating AR,J=−AR,RGR,JGJ,J−1A_{R,J}=-A_{R,R}G_{R,J}G_{J,J}^{-1} from the second equation gives AR,R(GR,R−GR,JGJ,J−1GJ,R)=IA_{R,R}(G_{R,R}-G_{R,J}G_{J,J}^{-1}G_{J,R})=I, so (AR,R)−1=GR,R−GR,JGJ,J−1GJ,R(A_{R,R})^{-1}=G_{R,R}-G_{R,J}G_{J,J}^{-1}G_{J,R}, and the matrix MJ≜G−G:,JGJ,J−1GJ,:M_J\triangleq G-G_{:,J}G_{J,J}^{-1}G_{J,:} vanishes on the rows and columns in JJ. The argument for one entry applies verbatim with GJ,:PSTY=BJ,:G_{J,:}P_S^{\mathsf{T}}Y=B_{J,:}: the rows RR of MJPSTYM_JP_S^{\mathsf{T}}Y, which are BR,:−GR,JGJ,J−1BJ,:B_{R,:}-G_{R,J}G_{J,J}^{-1}B_{J,:}, are the minimizer of (9) on RR, and (AR,R)−1(A_{R,R})^{-1} is its inverse Gram matrix, which is (14). The exact cost of the joint deletion is

F(S∖J)−F(S)=tr⁡(YTPS(G−MJ)PSTY)=tr⁡(BJ,:TGJ,J−1BJ,:).(21)\mathcal{F}(S\setminus J)-\mathcal{F}(S)=\operatorname{tr}\left(Y^{\mathsf{T}}P_S(G-M_J)P_S^{\mathsf{T}}Y\right)=\operatorname{tr}\left(B_{J,:}^{\mathsf{T}}G_{J,J}^{-1}B_{J,:}\right). \tag*{(21)}

Since the minimizer on RR does not depend on the order in which RR is reached, (14) gives the same coefficients and inverse as ∣J∣\lvert J\rvert successive single deletions of the elements of JJ. The block cost (21) equals ∑j∈Jsj\sum_{j\in J}s_j when GJ,JG_{J,J} is diagonal and differs from it otherwise: it is the sum of the sequential saliencies, each evaluated after the preceding deletions. KV-SURGEON selects JJ by the individual saliencies, computed before any entry of JJ is removed. This choice of JJ is the only approximation of the block step; the updates (14) are exact for the surrogate.

The single-deletion score

The score of (13) is the one case in which the exact loss of (4) has a closed form: a single deletion with every other cache parameter at its original value, S={1,…,T}∖{j}S=\{1,\ldots,T\}\setminus\{j\}, w=1w=1, and v^k=vk\hat{v}_k=v_k for k∈Sk\in S. Then U=VSU=V_S, μi=1−Pij\mu_i=1-P_{ij}, and ∑k∈SPikvk−μioi=(oi−Pijvj)−(1−Pij)oi=−Pij(vj−oi)\sum_{k\in S}P_{ik}v_k-\mu_io_i=(o_i-P_{ij}v_j)-(1-P_{ij})o_i=-P_{ij}(v_j-o_i), so (2) and (4) give

o^i−oi=−Pij1−Pij(vj−oi),L=∑i=1NPij2(1−Pij)2∥vj−oi∥22=sjLOO.\hat{o}_i-o_i=-\frac{P_{ij}}{1-P_{ij}}(v_j-o_i),\qquad\mathcal{L}=\sum_{i=1}^{N}\frac{P_{ij}^2}{(1-P_{ij})^2}\lVert v_j-o_i\rVert_2^2=s_j^{\mathrm{LOO}}.

Goel et al. [10] and An et al. [2] derive the per-query error for serving-time eviction, with queries read from the prompt suffix; summing its squared norm over the calibration queries carries it to the offline setting. The error is the product of two factors. The renormalization factor Pij/(1−Pij)P_{ij}/(1-P_{ij}) is large for a heavy hitter (Zhang et al., [33]) with PijP_{ij} near one, because the mass of the deleted entry is redistributed over retained entries that hold little mass themselves. The value novelty vj−oiv_j-o_i is small when the entry carries what the head already retrieves, so even a heavily attended entry can be deleted at no cost if its value is close to the current output. KV-SURGEON uses the score in three roles: as the prefilter that forms the candidate pool, as the selection rule of the mild-compaction fallback, and, followed by the same final refit, as the controlled baseline LOO of § 4.3. Its second-order truncation, the diagonal HjjH_{jj} of Appendix § 7.§ 1, drops the factor (1−Pij)−2(1-P_{ij})^{-2}.

Algorithm and implementation

Algorithm 1 in § 3.4 gives the complete procedure for one attention head. This section provides the hyperparameters, solvers, and computational details.

Multipliers as logit biases. For every retained entry j∈Sj \in S, the compacted cache stores the original key kjk_j, the refit value v^j\hat{v}_j, and the logarithm log⁡wj\log w_j of its multiplier. At inference, log⁡wj\log w_j is added to the logit of entry jj before the softmax, so that the entry contributes eZij+log⁡wj=wjeZije^{Z_{ij}+\log w_j}=w_j e^{Z_{ij}} to the unnormalized attention of query ii, which is (2). The bound e−β≤wj≤eβe^{-\beta} \le w_j \le e^\beta of the final refit is the bound ∣log⁡wj∣≤β\lvert\log w_j\rvert\le\beta on the logit bias of any single entry; it bounds the shift that compaction introduces and leaves the original logit ZijZ_{ij} unchanged. Mass preservation, μi≈1\mu_i \approx1, keeps the total unnormalized attention of the compacted cache at that of the original cache, so that the compacted cache draws the same share of attention when it is served next to other tokens (Appendix § 14).

Candidate pool and ridge. The pool consists of the m=min⁡{T,⌈ct⌉}m=\min\{T,\lceil ct\rceil\} entries with the largest scores (13), with c=4c=4. The score is evaluated with a floor, Pij2/((1−Pij)2+10−3)P_{ij}^{2}/((1-P_{ij})^{2}+10^{-3}), which bounds the weight of entries that receive almost all attention of a query; the LOO baseline uses the same evaluation. The minimum matters for heads with T/c<t≤τTT/c < t \le\tau T, whose pool is the whole cache. The ridge is set relative to the scale of the Gram matrix on the pool, λ=λ0tr⁡(PSTPS)/m\lambda=\lambda_0\operatorname{tr}(P_S^{\mathsf T}P_S)/m with λ0=0.01\lambda_0=0.01, computed once when the pool is formed and kept fixed for all later supports. A fixed λ\lambda is required for the updates (12) and (14) to be exact, because the Gram matrix of a reduced support is a principal submatrix of the current one only if both carry the same ridge (Appendix § 7.§ 4). Since mm can exceed NN, PSTPSP_S^{\mathsf T}P_S is singular on the pool in general, and the ridge is what makes GG well defined there. The inverse GG and the coefficients B=GPSTYB=GP_S^{\mathsf T}Y are computed explicitly once, on the pool, from a Cholesky factorization of PSTPS+λIP_S^{\mathsf T}P_S+\lambda I; if the factorization fails, λ\lambda is increased tenfold, at most three times.

Block deletions. Each elimination step deletes the nb=32n_b=32 entries with the smallest saliencies; the last step deletes min⁡{nb,∣S∣−t}\min\{n_b,\lvert S\rvert-t\} entries, so that the loop ends at ∣S∣=t\lvert S\rvert=t exactly. The updates (14) require solving linear systems with the nb×nbn_b \times n_b matrix GJ,JG_{J,J}, which is positive definite as a principal submatrix of GG. Compared with single deletions, the block step computes the saliencies once per block rather than once per deletion and runs the updates as matrix products with nbn_b columns; the arithmetic count is the same.

Final refit. After the elimination, BB and GG are discarded, and the multipliers and values are solved on SS in two ordered steps, following the refit of attention matching ([34]). The multipliers solve the box-constrained least-squares problem

w≜arg⁡min⁡e−β≤wj≤eβ ∥1−PSw∥22,β=3.(22)w \triangleq\underset{e^{-\beta}\leq w_j\leq e^\beta}{\arg\min}\ \left\lVert1-P_Sw\right\rVert_2^2,\qquad\beta=3. \tag*{(22)}

The box restores the positivity dropped in § 3.2 and bounds the logit bias of every entry. The solver is that of Zweiger et al. [34] and solves (22) approximately. It works with the unnormalized attention E=exp⁡(QKT/dk−max⁡)E=\exp(QK^{\mathsf T}/\sqrt{d_k}-\max), the row maximum of the logits subtracted, and its row sums ss, so that P=diag⁡(s)−1EP=\operatorname{diag}(s)^{-1}E, and minimizes ∥ESw−s1∥22\lVert E_Sw-s\mathbf{1}\rVert_2^2, which is (22) with row ii scaled by sis_i. The unconstrained least-squares solution is computed by a QR solve, clamped to the box, and then refined by two projected gradient steps with step size 1/∥ES∥221/\lVert E_S\rVert_2^2, clamping after each step; the spectral norm is estimated by three power iterations. With ww fixed, the normalized attention matrix of the compacted cache is P^≜diag⁡(PSw)−1PSdiag⁡(w)\hat{P}\triangleq\operatorname{diag}(P_Sw)^{-1}P_S\operatorname{diag}(w), cf. (2), and the values solve the linear least-squares problem

V^≜arg⁡min⁡V^ ∥P^V^−O∥F2(23)\hat{V}\triangleq\underset{\hat{V}}{\arg\min}\ \left\lVert\hat{P}\hat{V}-O\right\rVert_F^2 \tag*{(23)}

which is min⁡V^L(S,w,V^)\min_{\hat{V}}\mathcal{L}(S,w,\hat{V}), the exact output-preservation loss (4) for the chosen support and multipliers. All dvd_v columns of V^\hat{V} share the Gram matrix P^TP^\hat{P}^{\mathsf T}\hat{P} and are solved at once. They are computed by a least-squares solve; if the solve fails numerically, the normal equations (P^TP^+10−6aˉI)V^=P^TO(\hat{P}^{\mathsf T}\hat{P}+10^{-6}\bar{a}I)\hat{V}=\hat{P}^{\mathsf T}O are solved by a Cholesky factorization instead, where aˉ\bar{a} is the mean diagonal of P^TP^\hat{P}^{\mathsf T}\hat{P}. The order of the two solves is forced: P^\hat{P} depends on ww through diag⁡(w)\operatorname{diag}(w) and through PSwP_Sw, so the values have to be solved after the multipliers. The minimizer of (23) is unique if and only if PSP_S has full column rank, which cannot hold for t>Nt>N.

Mild-compaction fallback. Heads whose budget exceeds the fraction τ=0.3\tau= 0.3 of their cache, t>τTt > \tau T, skip the pool, the elimination, and the final refit: they retain the tt entries with the largest scores (13), their original values, and unit multipliers. Eviction is near-lossless at such mild compaction, the O(t3)O(t^3) solves are largest for exactly these heads, and for t>Nt > N the value solve (23) is underdetermined. Disabling the fallback leaves accuracy unchanged and adds 37% to pipeline time (Appendix § 11.§ 3).

Complexity. Forming the Gram matrix of a pool of mm candidates costs O(Nm2)O(Nm^2) and its inverse O(m3)O(m^3); the right-hand side PSTYP_S^\mathsf{T}Y costs O(Nmdv)O(Nmd_v) and the initial coefficients B=GPSTYB = GP_S^\mathsf{T}Y cost O(m2dv)O(m^2d_v). In each elimination step, the saliencies cost O(∣S∣(dv+1))O(|S|(d_v + 1)) given BB and the diagonal of GG, the update of BB costs O(∣S∣nb(dv+1)+nb2)O(|S|n_b(d_v + 1) + n_b^2), and the update of GG costs O(∣S∣2nb)O(|S|^2n_b). Summed over the (m−t)/nb(m-t)/n_b steps, the loop costs O(m3+m2dv)O(m^3 + m^2d_v), the same count as m−tm-t single deletions. The elimination on a pool of mm entries thus costs O(Nm2+m3+Nmdv+m2dv)O(Nm^2 + m^3 + Nmd_v + m^2d_v) per head, and its memory is dominated by the m×mm \times m matrix GG. The pool bounds mm by ctct, so these costs grow with the budget tt and not with the cache size TT; eliminating from the full cache instead changes accuracy within noise at 3.8× the compaction time (Appendix § 11.§ 3). The fallback removes the O(t3)O(t^3) terms for the heads with the largest budgets.

Hyperparameters. All hyperparameters were fixed once on Qwen3-4B with QuALITY at 50× and reused unchanged for every other model, benchmark, and ratio (Appendix § 9): the mass weight γ0=1\gamma_0 = 1 (Appendix § 7.§ 3), the relative ridge λ0=0.01\lambda_0 = 0.01, the pool factor c=4c = 4, the block size nb=32n_b = 32, the fallback threshold τ=0.3\tau= 0.3, and the multiplier bound β=3\beta= 3. Appendix § 11.§ 3 varies γ0\gamma_0, cc, and τ\tau.

Experimental details

This section records what is needed to reproduce and read the experiments; § 4.1 gives the summary. Appendix § 9.§ 1 states the protocol and conventions and Appendix § 9.§ 2 breaks down where the pipeline time goes.

Protocol and conventions

Task and benchmarks. The model reads a context once, the resulting cache is compacted once by a target factor between 5× and 100×, and all benchmark questions about that context are answered from the compacted cache, so calibration and compaction are one-time costs per context. QuALITY uses the dev split, articles 0–49, with n=894n = 894 multiple-choice questions; one article is one context. LongHealth consists of 20 fictional patient records, grouped into four contexts of five patients with roughly 60k tokens each; each record is compacted as its own chunk at the same ratio and the compacted chunks are concatenated (Appendix § 14), and all n=400n = 400 multiple-choice questions are evaluated against their contexts. Accuracy is the percentage of correctly answered questions. Answers are extracted from the generated text, and questions whose answer cannot be parsed count as incorrect; parse rates are checked per run and are uniformly high in the reported cells, so parsing does not drive the reported differences. All eight model and benchmark combinations are reported.

Compaction ratio and per-head budgets. The compaction factor, 5× to 100×, is the nominal ratio of the original cache size to the compacted one. Cache-side methods are reported at the nominal ratio because measured effective ratios agree with it to within one percent. Heads differ widely in how much compaction they tolerate, so the compaction factor is a global budget rather than a per-head prescription. Head (ℓ,h)(\ell, h) receives its own retained fraction rℓhr_{\ell h}, subject to the constraint that mean⁡ℓhrℓh\operatorname{mean}_{\ell h} r_{\ell h} equals the reciprocal of the compaction factor; each head is additionally capped at rℓh≤0.75r_{\ell h} \le0.75, and the budget a capped head cannot use is redistributed to the other heads in proportion to their shares, so the global ratio is preserved. The allocation is computed once per model on contexts disjoint from the benchmark contexts, following the procedure introduced by Zweiger et al. [34]. We measure per head how the log-perplexity of model-generated reference answers degrades as that head alone is compressed, and we allocate the budget along these influence curves. The solver is ratio-agnostic: it finds one set of per-head proportions that works across all target ratios, and this single allocation is rescaled to each compaction factor. Every method in a table consumes the same allocation, so differences between rows are attributable to selection and refit alone; the published configuration of KVzip, reported only in Table 16, is the deliberate exception. Uniform per-head budgets serve as an ablation (Appendix § 11).

Methodas publishedcalib. queries+ refit+ budgets
H2O47.4±0.547.4 \pm0.548.7±0.448.7 \pm0.456.1±0.456.1 \pm0.462.3±0.462.3 \pm0.4
OBCache43.2±0.243.2 \pm0.253.0±0.453.0 \pm0.458.1±0.358.1 \pm0.362.4±0.762.4 \pm0.7
KVMerger47.7±0.547.7 \pm0.547.6±0.247.6 \pm0.251.5±0.551.5 \pm0.557.2±0.557.2 \pm0.5
KVzip36.4±0.336.4 \pm0.342.6±0.342.6 \pm0.343.5±0.643.5 \pm0.649.8±0.449.8 \pm0.4

Table 16. Each external baseline from its published configuration to our pipeline, one component at a time, at 50×50 \times on Qwen3-4B / QuALITY. As published: own queries (H2O and KVMerger use context prefill, OBCache its last-64 observation window, KVzip its repeat prompt with a global cross-head threshold), uniform or own head allocation, no refit. The remaining columns use repeat-pass calibration queries.

Calibration tiers. All implemented methods score positions against calibration queries recorded from the model itself and, except AM-OMP, come in two tiers that differ mainly in how these queries are generated. The fast tier prompts the model to reproduce the context and records the query vectors of that single pass. The self-study tier additionally generates self-study conversations about the context, which cost more time but match the future workload better. AM-HAK-fast and KV-SURGEON-fast are the fast variants of AM-HAK and KV-SURGEON. AM-OMP, AM-OMP-CS, and KV-SURGEON are self-study methods; AM-OMP-CS is the cheap-solver setting of Zweiger et al. [34], named AM-OMP-fast there, which selects several keys per greedy step and refits less often. After selecting which positions to keep, every calibrated method applies the same support-fixed refit of the retained multipliers and values (§ 3.4), so accuracy differences between them reflect the selection rule. AM-OMP is evaluated only at the most aggressive ratios because its runtime grows steeply with the retention budget.

Calibration queries. Self-study generates five conversations per context with vLLM: a verbatim repetition of the context, a summary, an aggregation of key facts, a JSON structuring of the context, and three self-written questions with answers. The repetition is teacher-forced, with the context itself as the answer; the summary, aggregation, and JSON conversations are answered without thinking (at most 2048 tokens, temperature 0.7, top-pp 0.8, top-kk 20); the question conversation uses thinking for both writing and answering the questions (at most 8192 and 4096 tokens, temperature 0.6, top-pp 0.95, top-kk 20). The calibration queries are the query vectors of the answer tokens, capped at 50,000 per attention head by random subsampling. The repeat pass is the repetition conversation alone, that is, a single forward pass over the context, the repeat prompt, and a second copy of the context, without any generation. Queries are extracted on-policy, following Zweiger et al. [34]: layer 0 is compacted with the original queries, and for each later layer the same sequences are run through the model with the already compacted earlier layers in place, so every layer is compacted against the queries it receives at inference.

Replication and uncertainty. Each cell is the mean over five replicate runs with explicit seeds, and the grey number is the standard error over these runs; a single run is noisy to about ±1.5\pm1.5 points at n=894n = 894 and ±2.0\pm2.0 at n=400n = 400, comparable to many method gaps, so we only trust differences that survive the seed error bars. These standard errors measure generation noise under fixed contexts and questions, not uncertainty over the population of contexts, and LongHealth contributes only four composite contexts; generalization rests on the spread of the margins across the eight combinations in Appendix § 10. Full-context ceilings come from seed-replicated runs without compaction under the same protocol.

Timing conventions. Pipeline time is the average wall-clock per context spent on calibration query generation plus compaction, in seconds. It excludes prefilling the context to extract its cache, answer generation, and answer extraction, all of which are common to all methods. Query-free methods therefore report compaction time alone. All runs are single-job SLURM runs on machines with H200 GPUs, launched with the same tooling, so times are comparable within a table; comparisons across models should be treated as indicative. Every table splits calibrated methods by calibration tier, repeat-pass above self-study; AM-OMP-CS uses self-study queries and sits in the self-study group.

Defaults. The method defaults were fixed once on Qwen3-4B with QuALITY at 50×50\times and reused unchanged for every other model, benchmark, and ratio: the mass-term scale γ=1\gamma= 1, so that γ\gamma is the RMS norm of the full-cache outputs; the ridge λ0=0.01\lambda_0 = 0.01, applied relative to the mean diagonal of PSTPSP_S^{\mathsf{T}} P_S on the candidate pool rather than as an absolute penalty; the block size nb=32n_b = 32 selections per elimination step; the candidate pool of m=min⁡{T,[4T]}m = \min\{T, [4T]\} entries; the threshold τ=0.3\tau= 0.3 on the retained fraction t/Tt/T above which a head is left to plain eviction; and, in the final refit, the bound ∣log⁡wj∣≤β=3|\log w_j| \le\beta= 3 on the served logit biases, that is, wj∈[e−3,e3]w_j \in[e^{-3}, e^3], the interval that Table 18 refers to. Appendix § 11 varies γ0\gamma_0, the pool, and the threshold; Appendix § 8 describes how each hyperparameter enters the algorithm.

Ratiow~<0\widetilde{w}<0median headheads w/ anyrel. movecorr.at bounds
100×0.42%0.00%13.6%0.810.391.3% / 14.7%
50×0.33%0.00%19.4%0.700.511.3% / 9.4%
20×0.24%0.00%24.6%0.570.621.8% / 5.9%
10×0.24%0.00%28.0%0.540.682.9% / 5.5%
5×0.28%0.00%33.0%0.580.704.7% / 4.1%

Table 18. Diagnostics of the unconstrained multiplier coefficients w~≔B:,dv+1/γ\widetilde{w} \coloneqq B_{:,d_v+1}/\gamma that the elimination leaves on the final support and of the served multipliers ww after the box-constrained refit of (22), per ratio, on Qwen3-4B / QuALITY (seed 0, all 14,400 head instances; heads served by fallback or zero budget excluded). Columns: fraction of kept entries with w~j<0\widetilde{w}_j < 0 (pooled over heads, and the median head); fraction of heads with at least one negative coefficient; median per-head relative movement ∥w−w~∥2/∥w~∥2\lVert w-\widetilde{w}\rVert_2/\lVert\widetilde{w}\rVert_2 and correlation of ww against w~\widetilde{w}; fraction of served multipliers pinned at the bounds e±βe^{\pm\beta}, β=3\beta=3.

Where the time goes

Query generation sets the cost of the self-study tier. Self-study query generation is a sampled generation pass over the context and costs the same whichever method consumes the queries: 29 to 33 seconds per QuALITY article and 193 to 341 per LongHealth context on the dense models, 3.4 to 5.8 ms per token, and 162 and 1062 seconds on Qwen3-30B-A3B, whose mixture-of-experts decoding runs four to five times slower per token under vLLM. A repeat pass, including re-extraction of its query vectors, costs 5 to 160 seconds at 50× on the dense models and on Qwen3-30B-A3B with QuALITY, and about 300 seconds on Qwen3-30B-A3B with LongHealth; the query-free methods need no pass at all. Table 3 splits the self-study pipeline for LOO, KV-SURGEON, and AM-HAK, which consume the same queries. At 50×, compaction is 3 to 25% of the pipeline for all three, so the spread of their pipeline times in Appendix § 10, 2 to 12%, comes entirely from the compaction step, while the order-of-magnitude gaps are between tiers.

Model, benchmarkQuery gen. (s)LOO 50×LOO 5×KV-SURGEON 50×KV-SURGEON 5×AM-HAK 50×AM-HAK 5×
Qwen3-4B, QuALITY337.72910.5537.028
Llama-3.1-8B, LongHealth274662849357857277
Gemma-3-12B, QuALITY291.24.81.7111.14.8
Qwen3-30B-A3B, QuALITY1625.520––4.620
Qwen3-30B-A3B, LongHealth106247–65–––

Table 3. Where self-study pipeline time goes. Query generation is the sampled self-study pass, in seconds per context; it does not depend on the method or on the compaction factor. The remaining columns are the compaction step alone, in seconds per context, at 50× and 5× for the three methods that consume the same queries. Means over all seeded runs; the sums of query generation and compaction differ from the pipeline times of Appendix § 10 by up to 15%, which is run-to-run timing variation. ‘–’ marks cells not measured.

Compaction grows with the retained fraction. The compaction step of KV-SURGEON costs 1.4× that of LOO at 50× and 1.8 to 2.3× at 5×, because the block solve grows with the candidate pool: the log-log slope of compaction time against the retained fraction is 0.45 to 0.6 for LOO and AM-HAK and 0.65 to 0.95 for KV-SURGEON, and since query generation does not depend on the compaction factor, the compaction share rises from about 20% to 50–60% across the grid on the dense models. Gemma-3-12B’s compaction is small because five of every six layers use sliding-window attention and only the global layers are compacted.

Full results

The tables that follow cover one model and benchmark combination each and report QA accuracy and pipeline time for every method at all five compaction ratios, under the protocol of Appendix § 9. The conventions are the same throughout and are stated once here. Rows are grouped as in Table 1, query-free, repeat-pass, and self-study, separated by midrules, and the best accuracy per ratio within each group is bold; an entry is underlined when it trails the bold entry by at most two standard errors of the difference, computed from the two seed standard errors, so that bold without any underlined entry in the same group and column marks a separation beyond seed noise. Time is pipeline time per context in seconds; LongHealth contexts are about eight times longer than QuALITY articles, so every method costs roughly an order of magnitude more there. ‘–’ marks ratios a method does not reach: AM-OMP and AM-OMP-CS are capped because their solver cost grows with the retention budget. Summarization replaces the context by a model-generated summary of it. We use three prompts that lead to summaries of different lengths; the summary length is not a size parameter, so summarization has no table row, and Table 1 and Figure 1 report the prompt whose resulting cache size was closest to 50× compaction.

Observations across the grids. Three regularities are not visible in Table 1. First, mild compaction saturates: averaged over the eight combinations, the self-study methods span 54.7 to 59.3 points at 100×100 \times but only 72.9 to 73.7 at 5×5 \times against a ceiling of 74.0, and Llama-3.1-8B on QuALITY reaches its ceiling of 62.7% at 20×20 \times, so that combination is informative only at 50×50 \times and 100×100 \times. Second, KV-SURGEON is never behind beyond noise at the cell level: it is bold in 32 of the 40 self-study cells and within noise of the best in the other eight, and its largest deficit anywhere is 1.3 points, to an AM-OMP variant costing far more. Third, KV-SURGEON-fast is bold or within noise in 37 of the 40 repeat-pass cells and separated from every other repeat-pass method in all 16 cells at 50×50 \times and 100×100 \times; its three losses beyond noise are all at 10×10 \times and 5×5 \times and at most 1.8 points.

Query-free baselines. Q-Filters, StreamingLLM, and the L2L_2 key-norm heuristic use the same optimized per-head budgets as every other method and need no calibration pass. Q-Filters is the best of them at every ratio, with a mean of 46.5% at 50×50 \times over the seven combinations that report all three, where KV-SURGEON-fast reaches 63.8% on the same seven for about forty more seconds per context, so at this compaction, calibration is necessary.

Long Code Arena

Table 12 reports project-level code completion on Long Code Arena [3] with Qwen3-4B-Instruct-2507, the experiment behind the last paragraph of § 4.2. The benchmark is the large-context configuration of its project-level code completion task: each datapoint is a repository snapshot at a fixed commit, one held-out completion file, and a list of target lines in that file.

Contexts and questions. We walk the test split in order and keep the first snapshot of each not-yet-seen repository whose Python files plus completion file fit 120,000 Gemma-3 tokens, until 20 repositories are collected; the dataset order and commit hashes are recorded, so the selection is deterministic. The context of a repository is the concatenation of its non-empty .py files in snapshot order, each preceded by a header with its path; the completion file itself is not part of the context. The median context is 73,298 Qwen tokens (range about 45k to 95k). Every listed target line with non-blank content is one question, n=650n = 650 in total. A question shows the path of the completion file and its prefix, all lines before the target, in a code fence, and asks for exactly the next line; prefixes longer than 16,000 characters are truncated to their tail at a line boundary, which affects two questions. The prefix is part of the question, not of the compacted context, so compaction is tested through the repository context alone. The answer is generated inside an open code fence with at most 64 new tokens.

Compaction and scoring. As for LongHealth (Appendix § 14), each repository is compacted in chunks: consecutive files are packed into chunks of at most 10,000 tokens without crossing file boundaries, about nine per repository, each chunk is compacted at the target ratio, and the compacted chunks are concatenated. Head budgets, calibration, final refit, method configurations, and the five-seed protocol are identical to the LongHealth cells; seeds affect calibration-query sampling and generation, not the fixed set of repositories and questions. A completion is correct when its first generated code line, after dropping empty lines and fence lines and stripping surrounding whitespace, matches the reference line exactly; accuracy is the mean over the 650 questions. Time is query generation plus compaction per repository. The full-context ceiling under the same questions and scorer is 40.6%, and the query-free baselines reach 22 to 23% from the file prefix alone, so the effective range of the benchmark is about 22 to 41 points.

Results. At 100×100 \times no calibrated method is more than 0.4 points above the best query-free baseline, so the budget rather than the selection rule limits accuracy there. From 50×50 \times on, the calibrated methods separate. KV-SURGEON and KV-SURGEON-fast match AM-OMP within uncertainty at 50×50 \times with 9.7×\times and 21.5×\times less pipeline time, KV-SURGEON has the highest point estimate at 20×20 \times and 10×10 \times, and at 5×5 \times every calibrated method except KVzip and KVMerger is within 1.8 points of the ceiling. OBCache is again the strongest ported method, and AM-OMP-CS is the only prior method within uncertainty of KV-SURGEON at 20×20 \times, at 6.7×\times its cost.

MethodAccuracy (%) 100×Accuracy (%) 50×Accuracy (%) 20×Accuracy (%) 10×Accuracy (%) 5×Pipeline time (s) 100×Pipeline time (s) 50×Pipeline time (s) 20×Pipeline time (s) 10×Pipeline time (s) 5×
L2L_2 key-norm37.0 ±0.337.9 ±0.441.2 ±0.651.1 ±0.364.2 ±0.30.70.60.50.60.6
Q-Filters47.1 ±0.752.4 ±0.562.0 ±0.266.5 ±0.369.9 ±0.20.50.60.50.50.6
StreamingLLM40.4 ±0.644.7 ±0.452.0 ±0.458.4 ±0.464.2 ±0.20.70.50.50.80.7
KVzip48.0 ±0.449.8 ±0.461.6 ±0.469.1 ±0.570.5 ±0.21617212640
H2O60.0 ±0.562.3 ±0.4<u>68.2</u> ±0.4<u>70.3</u> ±0.471.3 ±0.21617202740
OBCache60.1 ±0.362.4 ±0.7<u>68.3</u> ±0.6<u>70.2</u> ±0.371.3 ±0.11617222741
KVMerger53.7 ±0.457.2 ±0.563.7 ±0.468.6 ±0.170.3 ±0.236425576106
AM-HAK-fast56.7 ±0.358.1 ±0.566.5 ±0.3<u>70.8</u> ±0.571.9 ±0.11517202838
KV-SURGEON-fast62.4 ±0.165.9 ±0.468.9 ±0.371.3 ±0.571.9 ±0.21416222728
AM-HAK59.9 ±0.264.1 ±0.969.0 ±0.271.5 ±0.2<u>71.7</u> ±0.43537416165
AM-OMP-CS<u>62.2</u> ±0.665.7 ±0.470.6 ±0.271.8 ±0.3–5184277919–
AM-OMP<u>62.4</u> ±0.466.4 ±0.2<u>70.1</u> ±0.2––1173141700––
LOO61.5 ±0.565.6 ±0.2<u>70.2</u> ±0.2<u>71.4</u> ±0.272.3 ±0.33738436166
KV-SURGEON63.4 ±0.466.8 ±0.3<u>70.2</u> ±0.2<u>71.6</u> ±0.572.3 ±0.53741506891

Table 4. QuALITY with Qwen3-4B. Full-context ceiling 72.1 ± 0.3%.

MethodAccuracy (%) 100×Accuracy (%) 50×Accuracy (%) 20×Accuracy (%) 10×Accuracy (%) 5×Pipeline time (s) 100×Pipeline time (s) 50×Pipeline time (s) 20×Pipeline time (s) 10×Pipeline time (s) 5×
L2L_2 key-norm38.2 ±0.837.5 ±0.436.0 ±0.651.8 ±0.564.8 ±0.87.04.94.96.05.3
Q-Filters<u>37.6</u> ±0.443.6 ±0.456.2 ±0.669.1 ±0.576.5 ±0.44.84.85.15.45.2
StreamingLLM34.6 ±0.539.4 ±0.742.9 ±0.855.4 ±0.364.2 ±0.45.35.65.24.65.6
KVzip31.8 ±1.039.9 ±0.864.6 ±0.675.9 ±0.377.7 ±0.4206222278363530
H2O49.6 ±0.658.4 ±0.471.2 ±0.476.2 ±0.9<u>78.5</u> ±0.2203222277370529
OBCache52.8 ±0.662.8 ±0.971.2 ±0.476.2 ±0.4<u>77.9</u> ±1.0222233277371555
KVMerger35.2 ±0.445.5 ±0.465.6 ±0.876.2 ±0.6<u>78.1</u> ±0.84064615987721122
AM-HAK-fast43.5 ±0.953.5 ±1.373.0 ±0.878.5 ±0.479.3 ±0.5204215263357530
KV-SURGEON-fast57.5 ±0.866.9 ±0.5<u>72.5</u> ±0.676.7 ±0.6<u>78.8</u> ±0.5193220297415628
AM-HAK53.7 ±0.465.0 ±0.873.7 ±0.877.2 ±0.5<u>78.3</u> ±0.4331349409512696
AM-OMP-CS57.8 ±1.0<u>65.9</u> ±1.174.5 ±0.979.1 ±0.5–5861091451816653–
AM-OMP59.3 ±0.365.5 ±0.676.0 ±0.5––1678488429489––
LOO53.6 ±0.464.2 ±1.274.2 ±0.577.5 ±0.5<u>78.5</u> ±0.5353359426551701
KV-SURGEON<u>59.1</u> ±0.567.8 ±0.8<u>74.8</u> ±0.7<u>77.8</u> ±0.7<u>78.8</u> ±0.43593875237491227

Table 5. LongHealth with Qwen3-4B-Instruct-2507. Full-context ceiling 80.5 ± 0.8%.

MethodAccuracy (%) 100×Accuracy (%) 50×Accuracy (%) 20×Accuracy (%) 10×Accuracy (%) 5×Pipeline time (s) 100×Pipeline time (s) 50×Pipeline time (s) 20×Pipeline time (s) 10×Pipeline time (s) 5×
L2L_2 key-norm38.0 ±0.440.2 ±0.548.1 ±0.556.4 ±0.560.6 ±0.10.50.50.50.50.6
Q-Filters40.8 ±0.347.7 ±0.856.7 ±1.060.9 ±0.462.5 ±0.30.60.60.60.60.6
StreamingLLM38.7 ±0.543.2 ±0.449.0 ±0.754.1 ±0.459.2 ±0.20.50.50.60.60.6
KVzip46.0 ±0.650.5 ±0.658.9 ±0.1<u>64.1</u> ±0.6<u>63.4</u> ±0.31415182434
H2O55.7 ±0.559.1 ±0.4<u>63.1</u> ±0.365.5 ±0.5<u>64.2</u> ±0.21415182534
OBCache56.9 ±0.459.8 ±0.3<u>63.2</u> ±0.463.7 ±0.1<u>64.1</u> ±0.71516192535
KVMerger49.4 ±0.654.0 ±0.759.6 ±0.462.4 ±0.3<u>63.4</u> ±0.43237486292
AM-HAK-fast54.9 ±0.758.7 ±0.6<u>63.0</u> ±0.463.8 ±0.364.5 ±0.41415182434
KV-SURGEON-fast58.5 ±0.661.0 ±0.463.4 ±0.663.8 ±0.6<u>64.3</u> ±0.81315202229
AM-HAK57.0 ±0.760.4 ±0.563.2 ±0.4<u>63.9</u> ±0.263.8 ±0.22829334053
AM-OMP-CS57.1 ±0.6<u>60.6</u> ±0.862.8 ±0.864.6 ±0.4–4274283934–
AM-OMP58.6 ±0.561.3 ±0.663.1 ±0.7––1012881573––
LOO58.0 ±0.4<u>61.2</u> ±0.7<u>63.1</u> ±0.363.1 ±0.4<u>63.2</u> ±0.32728323951
KV-SURGEON60.3 ±0.762.3 ±0.563.2 ±0.6<u>63.9</u> ±0.363.5 ±0.52831395068

Table 6. QuALITY with Llama-3.1-8B-Instruct. Full-context ceiling 62.7 ± 0.5%.

MethodAccuracy (%) 100×50×20×10×5×Pipeline time (s) 100×50×20×10×5×
L2L_2 key-norm33.0 ±\pm1.234.1 ±\pm1.637.6 ±\pm0.750.5 ±\pm0.362.5 ±\pm0.65.65.95.65.66.2
Q-Filters36.0 ±\pm0.836.1 ±\pm1.139.9 ±\pm0.649.5 ±\pm0.861.4 ±\pm0.27.05.76.06.65.7
StreamingLLM37.1 ±\pm1.137.2 ±\pm0.842.2 ±\pm1.145.4 ±\pm0.556.3 ±\pm0.85.95.25.75.65.7
KVzip23.3 ±\pm1.141.0 ±\pm1.463.5 ±\pm0.771.3 ±\pm0.472.7 ±\pm0.5173179229302437
H2O43.5 ±\pm0.750.6 ±\pm0.966.2 ±\pm0.670.2 ±\pm0.573.2 ±\pm0.6173189220307437
OBCache44.7 ±\pm0.952.4 ±\pm0.266.6 ±\pm0.471.5 ±\pm1.073.2 ±\pm0.5193202232326457
KVMerger34.5 ±\pm0.842.8 ±\pm0.657.3 ±\pm0.267.8 ±\pm0.672.5 ±\pm0.5337397505643929
AM-HAK-fast44.4 ±\pm1.253.5 ±\pm1.168.0 ±\pm0.573.5 ±\pm1.474.3 ±\pm0.3165180221303447
KV-SURGEON-fast53.9 ±\pm1.061.5 ±\pm0.668.8 ±\pm0.471.4 ±\pm0.573.0 ±\pm0.5153181262287403
AM-HAK48.4 ±\pm1.158.2 ±\pm0.570.2 ±\pm0.772.8 ±\pm0.370.5 ±\pm1.0291311350456614
AM-OMP-CS47.9 ±\pm0.555.8 ±\pm0.966.1 ±\pm0.5––56412095867––
AM-OMP49.2 ±\pm0.657.3 ±\pm0.969.0 ±\pm0.6––1650529235590––
LOO44.5 ±\pm1.759.1 ±\pm0.666.8 ±\pm0.770.8 ±\pm0.973.4 ±\pm0.6295323360453620
KV-SURGEON54.0 ±\pm0.862.1 ±\pm0.371.5 ±\pm1.273.2 ±\pm0.574.1 ±\pm0.8313349487654908

Table 7. LongHealth with Llama-3.1-8B-Instruct. Full-context ceiling 73.0 ±\pm 0.8%.

MethodAccuracy (%) 100×50×20×10×5×Pipeline time (s) 100×50×20×10×5×
L2L_2 key-norm41.3 ±\pm0.442.5 ±\pm0.645.9 ±\pm0.452.4 ±\pm0.268.3 ±\pm0.30.30.30.30.30.4
Q-Filters46.3 ±\pm0.650.9 ±\pm0.359.9 ±\pm0.770.6 ±\pm0.477.3 ±\pm0.10.30.40.40.40.3
StreamingLLM44.7 ±\pm0.547.5 ±\pm0.353.8 ±\pm0.160.9 ±\pm0.470.2 ±\pm0.30.30.30.30.30.3
KVzip48.3 ±\pm0.253.0 ±\pm0.460.4 ±\pm0.370.3 ±\pm0.778.7 ±\pm0.25663669678
H2O60.6 ±\pm0.466.5 ±\pm0.373.7 ±\pm0.778.3 ±\pm0.280.5 ±\pm0.45353596476
OBCache61.7 ±\pm0.267.3 ±\pm0.473.1 ±\pm0.578.4 ±\pm0.380.0 ±\pm0.36263616788
KVMerger58.2 ±\pm0.663.9 ±\pm0.672.2 ±\pm0.275.1 ±\pm0.379.2 ±\pm0.1768294100122
AM-HAK-fast60.3 ±\pm0.365.8 ±\pm0.571.2 ±\pm0.377.3 ±\pm0.479.5 ±\pm0.35152566377
KV-SURGEON-fast66.5 ±\pm0.271.4 ±\pm0.376.5 ±\pm0.278.4 ±\pm0.480.2 ±\pm0.35354616576
AM-HAK63.5 ±\pm0.569.5 ±\pm0.374.0 ±\pm0.378.2 ±\pm0.380.3 ±\pm0.4156162168172194
AM-OMP-CS63.5 ±\pm0.669.7 ±\pm0.575.2 ±\pm0.478.5 ±\pm0.4–165183283616–
AM-OMP63.6 ±\pm0.669.2 ±\pm0.475.5 ±\pm0.2––199300996––
LOO64.7 ±\pm0.369.6 ±\pm0.374.9 ±\pm0.378.3 ±\pm0.779.8 ±\pm0.1163165170173214
KV-SURGEON67.6 ±\pm0.472.5 ±\pm0.677.4 ±\pm0.379.2 ±\pm0.280.5 ±\pm0.3164159166181198

Table 8. QuALITY with Qwen3-30B-A3B. Full-context ceiling 80.7 ±\pm 0.4%.

MethodAccuracy (%) 100×50×20×10×5×Pipeline time (s) 100×50×20×10×5×
Q-Filters–43.2 ±\pm0.5––––––––
OBCache52.7 ±\pm0.462.8 ±\pm0.468.6 ±\pm0.574.4 ±\pm0.176.7 ±\pm0.3391395402409424
AM-HAK-fast50.4 ±\pm1.159.8 ±\pm0.466.9 ±\pm0.474.3 ±\pm0.577.2 ±\pm0.2358361362372389
KV-SURGEON-fast54.7 ±\pm0.364.1 ±\pm0.270.2 ±\pm0.575.0 ±\pm0.377.1 ±\pm0.2363366373386413
AM-HAK51.4 ±\pm0.461.4 ±\pm0.469.8 ±\pm0.573.7 ±\pm0.176.8 ±\pm0.311211129113011591162
AM-OMP-CS52.6 ±\pm0.563.1 ±\pm0.270.0 ±\pm0.3––127115693521––
AM-OMP53.3 ±\pm0.263.9 ±\pm0.6–––21474011–––
LOO52.1 ±\pm0.362.3 ±\pm0.769.3 ±\pm0.474.2 ±\pm1.277.0 ±\pm0.311091112113111431159
KV-SURGEON55.9 ±\pm0.365.2 ±\pm0.471.4 ±\pm0.475.8 ±\pm0.677.6 ±\pm0.311241135114911771211

Table 9. LongHealth with Qwen3-30B-A3B. Full-context ceiling 78.3 ±\pm 0.5%. Of the query-free methods, only Q-Filters at 50× was run on this combination; KVzip, H2O, and KVMerger were not run.

MethodAccuracy (%) 100×50×20×10×5×Pipeline time (s) 100×50×20×10×5×
L2L_2 key-norm47.4±0.547.4 \pm0.548.5±0.348.5 \pm0.349.3±0.249.3 \pm0.250.8±0.150.8 \pm0.155.3±0.555.3 \pm0.50.30.30.30.30.3
Q-Filters53.2±0.553.2 \pm0.555.9±0.355.9 \pm0.361.7±0.461.7 \pm0.465.4±0.465.4 \pm0.468.2±0.468.2 \pm0.40.30.30.30.30.3
StreamingLLM49.3±0.649.3 \pm0.650.2±0.350.2 \pm0.352.4±0.552.4 \pm0.555.7±0.355.7 \pm0.361.4±0.461.4 \pm0.40.30.30.30.30.3
KVzip56.0±0.256.0 \pm0.257.6±0.857.6 \pm0.863.1±0.463.1 \pm0.467.2±0.567.2 \pm0.569.1±0.469.1 \pm0.46.06.26.77.49.1
H2O61.5±0.361.5 \pm0.366.2±0.266.2 \pm0.268.1±0.268.1 \pm0.271.1±0.471.1 \pm0.471.3±0.471.3 \pm0.46.06.16.67.49.0
OBCache62.7±0.362.7 \pm0.366.6±0.466.6 \pm0.468.0±0.168.0 \pm0.170.5±0.470.5 \pm0.471.2±0.271.2 \pm0.26.196.476.847.549.39
KVMerger56.5±0.256.5 \pm0.261.1±0.261.1 \pm0.264.8±0.464.8 \pm0.467.6±0.367.6 \pm0.369.3±0.269.3 \pm0.21212151925
AM-HAK-fast59.5±0.259.5 \pm0.262.2±0.462.2 \pm0.466.8±0.566.8 \pm0.569.3±0.469.3 \pm0.469.5±0.369.5 \pm0.36.16.26.77.48.9
KV-SURGEON-fast65.2±0.365.2 \pm0.368.1±0.568.1 \pm0.570.4±0.870.4 \pm0.871.0±0.671.0 \pm0.670.6±0.270.6 \pm0.26.06.57.48.811
AM-HAK61.5±0.661.5 \pm0.665.1±0.365.1 \pm0.368.8±0.368.8 \pm0.370.0±0.370.0 \pm0.370.9±0.470.9 \pm0.42930303134
AM-OMP-CS64.2±0.364.2 \pm0.367.2±0.267.2 \pm0.269.2±0.369.2 \pm0.370.3±0.370.3 \pm0.3–323756125–
AM-OMP64.7±0.464.7 \pm0.467.7±0.367.7 \pm0.369.8±0.469.8 \pm0.4––3859180––
LOO60.5±0.360.5 \pm0.365.1±0.565.1 \pm0.568.6±0.368.6 \pm0.370.5±0.470.5 \pm0.470.4±0.470.4 \pm0.42929303133
KV-SURGEON65.5±0.265.5 \pm0.267.5±0.767.5 \pm0.770.0±0.470.0 \pm0.470.9±0.470.9 \pm0.471.1±0.271.1 \pm0.23031333539

Table 10. QuALITY with Gemma-3-12B-it. Full-context ceiling 70.6±0.4%70.6 \pm0.4\%.

MethodAccuracy (%) 100×50×20×10×5×Pipeline time (s) 100×50×20×10×5×
L2L_2 key-norm37.6±0.537.6 \pm0.538.9±1.238.9 \pm1.237.8±0.637.8 \pm0.640.4±0.440.4 \pm0.441.0±0.641.0 \pm0.66.26.26.36.16.0
Q-Filters38.4±0.238.4 \pm0.239.0±0.739.0 \pm0.739.4±0.939.4 \pm0.944.5±0.844.5 \pm0.853.9±0.753.9 \pm0.76.06.16.36.16.1
StreamingLLM40.9±0.340.9 \pm0.339.5±0.939.5 \pm0.939.3±0.639.3 \pm0.642.0±0.342.0 \pm0.344.4±0.644.4 \pm0.66.15.96.06.16.3
KVzip38.1±0.538.1 \pm0.539.8±0.739.8 \pm0.744.5±0.644.5 \pm0.652.9±0.852.9 \pm0.860.7±0.660.7 \pm0.65559647495
H2O38.5±0.638.5 \pm0.647.3±0.547.3 \pm0.555.1±0.255.1 \pm0.263.5±0.663.5 \pm0.668.8±0.768.8 \pm0.75460647491
OBCache41.3±0.541.3 \pm0.550.2±0.850.2 \pm0.856.1±0.456.1 \pm0.464.0±0.864.0 \pm0.869.7±0.569.7 \pm0.559.259.966.475.195.3
KVMerger33.7±0.633.7 \pm0.636.1±0.836.1 \pm0.842.5±0.642.5 \pm0.650.1±0.950.1 \pm0.959.2±0.659.2 \pm0.697106140170239
AM-HAK-fast41.5±1.041.5 \pm1.045.6±1.245.6 \pm1.254.6±0.854.6 \pm0.861.8±0.661.8 \pm0.666.0±0.766.0 \pm0.75759807396
KV-SURGEON-fast45.6±0.645.6 \pm0.652.1±0.452.1 \pm0.461.1±0.361.1 \pm0.366.5±0.766.5 \pm0.771.2±1.171.2 \pm1.153597197138
AM-HAK44.7±0.744.7 \pm0.752.7±1.452.7 \pm1.462.5±0.662.5 \pm0.667.2±0.267.2 \pm0.271.0±0.571.0 \pm0.5198207210227291
AM-OMP-CS43.6±0.943.6 \pm0.950.9±0.850.9 \pm0.861.2±0.961.2 \pm0.966.2±0.766.2 \pm0.7–2252876242048–
AM-OMP45.5±1.245.5 \pm1.254.5±0.954.5 \pm0.961.9±1.061.9 \pm1.0––3536892831––
LOO42.5±0.742.5 \pm0.749.6±0.749.6 \pm0.760.6±0.660.6 \pm0.667.2±0.767.2 \pm0.769.8±0.769.8 \pm0.7206205213218249
KV-SURGEON48.4±1.148.4 \pm1.156.4±0.756.4 \pm0.763.0±0.763.0 \pm0.768.8±0.868.8 \pm0.871.8±0.571.8 \pm0.5194201224263346

Table 11. LongHealth with Gemma-3-12B-it. Full-context ceiling 74.5±0.4%74.5 \pm0.4\%.

Component ablations

This section holds every ablation of the shared pipeline and of KV-SURGEON behind § 4.3 and Table 2: the shared pipeline components in Appendix § 11.§ 1, compensation in Appendix § 11.§ 2, and the efficiency and design choices in Appendix § 11.§ 3. Every ablation runs on Qwen3-4B with QuALITY at 50×50 \times, changes one component of the pipeline of § 3 at a time, and reports the mean over five seeds with one standard error over seeds. Two protocols are used and must not be mixed. The 50-article protocol (Table 13 and Table 15) is that of the main tables, 894 questions; its self-study controls are the KV-SURGEON, LOO, and AM-HAK entries of Table 1, and its time is pipeline time, calibration-query generation plus compaction. The 25-article protocol (Table 14) uses the first 25 articles, so its accuracies are compared only against the reference row of the same panel and never against the main-table numbers, and its time is compaction only, because query generation is identical across arms. The fast-tier row of Table 13 was run with the fast configuration in use at the time of the ablation, whose reference values (65.5%, 5.4 s) differ from the KV-SURGEON-fast entry of Table 1; it too is read only against its own control. Defaults are those of Appendix § 9.

AblationMethodDefault Acc. (%)Default Time (s)Ablated Acc. (%)Ablated Time (s)
Final refit off (plain eviction on the selected support)LOO65.6 ±0.23860.2 ±0.435
Mass term off (γ0=0\gamma_0 = 0)KV-SURGEON66.8 ±0.34167.0 ±0.443
Mild-compaction fallback off (threshold 0.3 →\to 1.0)KV-SURGEON-fast65.5 ±0.25.465.5 ±0.27.4

Table 13. One-component ablations on Qwen3-4B with QuALITY at 50×, all 50 articles, five seeds, one standard error over seeds. Time is pipeline time per context (calibration-query generation plus compaction). The self-study controls are the runs of Table 1; the fast-tier control is the fast configuration in use at the time of the ablation and is read only against its own row. The head-budget ablation is in Table 15.

MethodQueriesuniform budgetsoptimized budgets
no refitrefit+ refit
AM-HAKself-study54.1 ±0.2\pm0.257.2 ±0.5\pm0.564.1 ±0.9\pm0.9
LOOself-study53.2 ±0.5\pm0.557.8 ±0.6\pm0.665.6 ±0.2\pm0.2
KV-SURGEONself-study58.2 ±0.4\pm0.460.2 ±0.3\pm0.366.8 ±0.3\pm0.3
AM-OMPself-study–59.0 ±0.5\pm0.566.4 ±0.2\pm0.2
AM-HAK-fastrepeat48.1 ±0.5\pm0.553.2 ±0.3\pm0.358.1 ±0.5\pm0.5
KV-SURGEON-fastrepeat56.3 ±0.5\pm0.558.6 ±0.5\pm0.565.9 ±0.4\pm0.4
AM-OMP-CSself-study–58.1 ±0.4\pm0.465.7 ±0.4\pm0.4

Table 15. The two shared pipeline components switched independently, at 50×50 \times on Qwen3-4B / QuALITY, 50 articles, five seeds: the support-fixed refit (values and multipliers) and the optimized per-head budgets. All methods use our calibration queries; the AM-OMP value reconstruction cannot be disabled. LOO with optimized budgets and no refit is the plain-eviction row of Table 13; the ported eviction methods are in Table 16.

Shared pipeline components: head budgets and final refit

Both components are inherited from attention matching ([34]) and applied to every calibrated method, so their effect is measured per method. Table 15 switches them independently for our methods and the attention-matching baselines; the ported eviction methods are walked through the same switches in Table 16.

Head budgets. The ablation replaces the optimized per-head budgets of Appendix § 9 by uniform per-layer budgets at the same global ratio. It is the largest single lever, and it is not specific to KV-SURGEON: with the refit in place, KV-SURGEON loses 6.6 points, AM-HAK 6.9, and LOO 7.8. Under uniform budgets KV-SURGEON remains 2.4 points ahead of LOO and 3.0 ahead of AM-HAK, so the selection-rule margins of § 4.3 do not depend on the optimized budgets. KVzip, the one baseline that sets its own head allocation from a global attention threshold, leads to the same conclusion: ported with the shared budgets and refit, it collapses under strong compaction, a median of 15.3 points below KV-SURGEON-fast at 50×50 \times and 100×100 \times, yet sits a median of 1.6 points below the ceiling at 5×5 \times (Appendix § 10); the deficit tracks how hard the compaction is, not how good the score is.

Final refit. The refit is ablated on the LOO support, where it can be switched off without touching selection (Table 13). Serving the selected keys with their original multipliers and values, which is plain eviction on the score of (13), costs 5.4 points against LOO with the refit. Across methods the two switches compound: the budgets are the larger lever, worth +4 to +8 points on top of the refit, and the refit adds +1 to +7 on top of raw compaction (Table 15 and Table 16). The improvements are not the same for all methods, but KV-SURGEON is ahead in all three settings. Panel (c) of Table 14 decomposes the refit into its two solves on the KV-SURGEON support; it is kept as supporting evidence for Appendix § 14.§ 1 and is not built on elsewhere.

KV-SURGEON-specific component: compensation

Panel (b) of Table 14 isolates compensation. The surrogate, the 4t4t candidate pool, and the final refit are held fixed and only the compensating update of (12) is disabled, so that elimination proceeds greedily on the same surrogate saliencies. This costs 2.9±0.82.9 \pm0.8 points (seed-paired; 3.0 between the seed means of Table 2), and leaves greedy elimination no better than LOO selection on the same articles (64.7%). Two controls show that the gain is not a better standalone objective. Greedy elimination on the exact set loss of (4) instead of the surrogate reaches 65.8%, 1.1 ±\pm 1.3 below KV-SURGEON and too noisy on 25 articles to separate from either side. Shrinking the candidate pool to the support itself (pool factor 1 in panel (a)), which leaves the elimination nothing to eliminate or compensate, costs the same 2.9 points. The loss-level counterpart, that the compensated support moves toward an exact-refit oracle and that the compensation generalizes to held-out queries, is in Appendix § 12.

Efficiency and design choices

The remaining choices change accuracy by at most one standard error at their defaults and mainly control cost.

Mass term. Setting γ0=0\gamma_{0}=0 removes the mass term from the surrogate (Table 13). Accuracy moves by +0.2 points, within one standard error, at 2 s more pipeline time.

Candidate pool. The elimination runs on the min⁡{T,⌈4t⌉}\min\{T,\lceil4t\rceil\} best entries per head by the score of (13) (panel (a) of Table 14). Widening the pool to the full cache changes accuracy by 0.2 points (66.9 against 66.7) and multiplies compaction time by 3.8 (10 against 38 s); halving it to 2t2t costs 1.0 point.

Mild-compaction fallback. Heads whose budget tt exceeds 30% of their cache are served by plain eviction on the score of (13), without pool, elimination, or final refit: eviction is near-lossless there, the O(t3)O(t^{3}) value solve is the dominant cost and is largest exactly for these heads, and for t>Nt>N the value solve of (23) is underdetermined. Raising the threshold to 1.0 disables the fallback (Table 13). The accuracy of KV-SURGEON-fast is unchanged to the reported precision, and its pipeline time rises from 5.4 to 7.4 s, so the fallback saves 27% of the pipeline. The fallback was not ablated on the self-study tier.

Surrogate refresh. The frozen surrogate can be re-solved at the current normalization ratios μ\mu every 256 or 64 eliminations, either reweighting the residuals of (17) (panel (a) of Table 14) or consistently, holding that mass fixed so that the refreshed objective agrees with the served output (panel (b)). At the default pool the reweighted refresh costs 1.6 and 1.9 points at 1.3× and 2.2× the compaction time, and the consistent refresh costs 1.3 ± 0.7 and 0.7 ± 0.2 points. Across the pool sweep the refreshed arm is never better than the frozen one beyond one standard error of the difference (the largest apparent gain is +1.0 at pool factor 1, with standard errors of 1.0 and 0.7), while its cost grows to 11× at the full cache. At the loss level, measured as in Appendix § 12, the refresh changes which positions survive, Jaccard 0.55 to 0.85 against the frozen support, without changing the exact loss after the final refit on calibration or held-out queries (within ±2% on every head where a refresh occurs). Freezing is therefore kept for cost, not because it regularizes.

Pool factorRefresh off Acc. (%)Refresh off sRefresh every 256 Acc. (%)Refresh every 256 sRefresh every 64 Acc. (%)Refresh every 64 s
1 (LOO selection)64.0 ±1.07.965.0 ±0.77.864.1 ±0.68.0
265.9 ±1.08.766.0 ±0.59.265.8 ±0.710
4 (default)66.9 ±0.31065.3 ±0.31365.0 ±0.522
866.5 ±0.71565.5 ±0.42866.0 ±0.374
1666.8 ±0.42266.0 ±0.75964.5 ±0.5181
50 (full cache)66.7 ±0.53865.9 ±0.412666.7 ±0.5416

Table 14a. (a) Candidate-pool width and reweighted surrogate refresh (KV-SURGEON)

VariantAcc. (%)Δ\Delta vs. KV-SURGEON
surrogate with compensation (KV-SURGEON)66.9 ±0.6—
surrogate, greedy, no compensation63.9 ±1.6−2.9 ±0.8
exact loss (4), greedy, no compensation65.8 ±2.8−1.1 ±1.3
LOO selection (same articles)64.7 ±0.9−2.1 ±0.4
consistent refresh every 25665.6 ±1.5−1.3 ±0.7
consistent refresh every 6466.1 ±0.4−0.7 ±0.2

Table 14b. (b) Selection objective at pool factor 4, refresh off, same final refit

Final refit re-solvesRefresh off Acc. (%)Refresh off sRefresh every 256 Acc. (%)Refresh every 256 s
values and multipliers (default)66.9 ±0.31065.3 ±0.313
values only, multipliers from the elimination65.5 ±0.59.764.2 ±0.512
multipliers only, values from the elimination52.7 ±0.81242.7 ±1.612
none, both from the elimination64.7 ±1.18.560.9 ±0.511

Table 14c. (c) What the final refit re-solves on the KV-SURGEON support, pool factor 4

tbl:14: Ablations under the 25-article protocol on Qwen3-4B with QuALITY at 50×, five seeds, one standard error over seeds; accuracies are compared only within this table. The three panels are separate runs, so the same configuration can appear in more than one panel with slightly different numbers. Time is compaction only. (a) The pool holds the ⌈pool factor×t⌉\lceil\text{pool factor} \times t \rceil best entries per head by the score of (13); pool factor 1 is LOO selection with the shared final refit and 50 saturates at the full cache. The reweighted refresh re-solves the surrogate at the current normalization ratios μ\mu every 256 or 64 eliminations. (b) Greedy rows eliminate on the stated objective without the compensating update of (12); the exact-loss row evaluates (4) on the current support at every step; the consistent refresh re-solves the surrogate at the current normalization ratios μ\mu while holding that mass fixed, so that the refreshed objective agrees with the served output. Differences are seed-paired; run times were not recorded for this panel. (c) Whatever the final refit does not re-solve is kept from the coefficients BB that the elimination itself leaves on the final support.

Compensation at the loss level and calibration robustness

This section measures compensation directly on the attention-output loss rather than through accuracy, and then asks why repeat-pass calibration costs KV-SURGEON less than it costs the exact single-deletion score; § 4.3 and § 4.4 cite the results. All measurements use Qwen3-4B and Llama-3.1-8B, five QuALITY articles, and every head, that is, 1440 head–article pairs on Qwen3-4B and 1280 on Llama-3.1-8B. Scores are computed from the self-study calibration queries, and the exact loss of (4) is evaluated on held-out benchmark questions the scores never saw; where the same measurement on the calibration queries differs, it is given in parentheses.

Compensation moves the support toward the oracle and generalizes. Against an oracle that runs the same greedy backward elimination but scores every candidate deletion by the exact loss (4) after refitting the remaining entries, on the 546 heads where this is affordable (t≤57t \le57, Qwen3-4B), LOO selection sits 46% above the oracle’s loss and KV-SURGEON 25% (median relative loss 0.213, 0.183, and 0.146; random selection 0.243), closing 45% of the gap, and on the typical head the closed fraction is 39%; the oracle is itself greedy, so these gaps are to exact-loss greedy elimination rather than to the optimal support. KV-SURGEON beats LOO on 84% of heads and still shares only 44% of its keys with the oracle set, because many near-equivalent supports exist. On the supports KV-SURGEON selects at 50×, the final refit leaves 25% of the raw-eviction loss on Qwen and 7.5% on Llama on held-out questions, against 25% and 7.7% on the calibration queries: no head overfits, and on no head is the stored cache worse than eviction. On Llama raw eviction at 50× leaves a loss larger than the output itself, so the final refit, which every calibrated method shares, removes most of the loss there, and selection decides the remainder. The coefficients the elimination itself produces already achieve most of this (31% and 8%), but they cannot be served raw: on 1% of Qwen heads and 5% of Llama heads they exceed the eviction loss, and the final refit never does, which is the loss-level counterpart of the final-refit ablation of Appendix § 11.§ 1.

Why repeat-pass calibration costs KV-SURGEON less than the exact score. Averaged over the eight combinations at 50×, replacing self-study queries with a single repeat pass costs KV-SURGEON 1.2 points (Table 1); the drop is 4.3 points on LongHeal with Gemma-3-12B and at most 1.3 elsewhere. At the level of rankings, recomputing the scores from a single repeat pass drops the Spearman correlation between the surrogate and the exact loss over random deletion sets, computed within one head and one set size, from 0.905 to 0.786 on Qwen and from 0.929 to 0.833 on Llama, and that of the score of (13) from 0.881 to 0.690 on both, so under cheap queries the surrogate loses about half the ranking fidelity the exact score loses. Cross-head comparability, which is what the per-head budget allocation consumes, is unaffected (0.81 and 0.91 at 98% deletion), so budget allocation does not need self-study queries. The surrogate is therefore less sensitive to the calibration queries than the exact score, not insensitive.

Hypothesis, not tested as a mechanism. The factor (1−Pij)−2(1 - P_{ij})^{-2} in the exact deletion score amplifies exactly the queries a repeat pass gets wrong: a query for which one token receives unusually large attention contributes disproportionately to that token’s score, so an atypical repeat-pass attention pattern moves the exact ranking more than it moves the frozen surrogate, which contains no such amplification. This is consistent with the measurements above and is a candidate mechanism for the fast-tier robustness of § 4.4, but it does not establish why AM-HAK degrades more strongly under the same change: AM-HAK ranks tokens by attention mass rather than by either of these objectives, so its larger calibration drop may have a different cause.

Ported baselines: from the published regime to ours

H2O, OBCache, KVMerger, and KVzip are serving-time or self-allocating methods; this section describes how each is ported into the offline pipeline. Each port replaces the method’s own queries by the shared repeat-pass calibration queries, keeps its selection score, and serves the selected support with the shared per-head budgets and final refit of § 3.4. For OBCache, the published observation window of the last 64 prompt tokens is replaced by the calibration queries, and its second-order score is aggregated over them. Table 16 validates the port by walking each method from its published configuration to our pipeline one component at a time, at 50×50 \times on Qwen3-4B with QuALITY under the 50-article protocol of Appendix § 9.

The pipeline we use, inherited from Zweiger et al. [34], is worth 9 to 19 points to each of the eviction methods we ported to the offline compaction regime; the budgets are the largest single step for KVMerger and KVzip, the refit for H2O, and the calibration queries for OBCache. Even with every component, the best ported rule, OBCache at 62.4, stays 3.5 points below KV-SURGEON-fast (65.9) at the same cost, and H2O at 62.3 is within noise of OBCache. The two hybrid configurations with their own queries but our budgets (H2O 58.7±0.258.7 \pm0.2, KVMerger 57.5±0.557.5 \pm0.5) confirm that budgets alone do not close the gap.

Cache construction and the role of mass matching

Chunked contexts. Long structured contexts, for example records of several patients, are compacted one chunk at a time. At inference the compacted blocks sit side by side in one cache, and the softmax normalizes across all of them. Block bb therefore competes for the attention of query ii through its total unnormalized mass mib=∑j∈SbwjeZijm_i^b = \sum_{j\in S_b} w_j e^{Z_{ij}}. A compaction that shrinks a block’s mass re-routes attention away from that block and toward its neighbors, even when the reconstruction within the block is perfect. In this setting the absolute mass of a block is meaningful, and it must be preserved alongside the outputs. Lemma 1 makes this precise, and Appendix § 14.§ 1 discusses what mass matching can and cannot tell selection.

Lemma 1 (Serving next to other tokens) Suppose query ii attends to the compacted cache together with further tokens whose unnormalized attention sums to ci=∑ℓ=1cieZiℓc_i = \sum_{\ell=1}^{c_i} e^{Z_{i\ell}} for some ci≥0c_i \ge0 and whose output on their own is oi′o'_i. Then the served output is

μio^i+cioi′μi+ci,compared withoi+cioi′1+ci(24)\frac{\mu_i \hat{o}_i + c_i o'_i}{\mu_i + c_i}, \qquad\text{compared with} \qquad \frac{o_i + c_i o'_i}{1+c_i} \tag*{(24)}

for the original cache. The two agree for every ci≥0c_i \ge0 and every oi′o'_i if and only if o^i=oi\hat{o}_i = o_i and μi=1\mu_i = 1.

Proof. The softmax over all tokens has the denominator ∑j∈SwjeZij+ci∑ℓeZiℓ\sum_{j\in S} w_j e^{Z_{ij}} + c_i \sum_{\ell} e^{Z_{i\ell}} and the numerator ∑j∈SwjeZijv^j+cioi′∑ℓeZiℓ\sum_{j\in S} w_j e^{Z_{ij}}\hat{v}_j + c_i o'_i \sum_{\ell} e^{Z_{i\ell}}. Dividing both by ∑ℓeZiℓ\sum_{\ell} e^{Z_{i\ell}} and using ∑j∈Swjpij=μi\sum_{j\in S} w_j p_{ij} = \mu_i and ∑j∈Swjpijv^j=μio^i\sum_{j\in S} w_j p_{ij}\hat{v}_j = \mu_i\hat{o}_i from (2) and (3) gives the first expression. The original cache is the case S={1,…,T}S = \{1,\ldots,T\}, w=1w = 1, V^=V\hat{V} = V, for which μi=1\mu_i = 1 and o^i=oi\hat{o}_i = o_i. If o^i=oi\hat{o}_i = o_i and μi=1\mu_i = 1, the two expressions coincide. Conversely, ci=0c_i = 0 gives o^i=oi\hat{o}_i = o_i; then both expressions are convex combinations of oio_i and oi′o'_i with the weights μi/(μi+ci)\mu_i/(\mu_i+c_i) and 1/(1+ci)1/(1+c_i) on oio_i, which agree for ci>0c_i > 0 and oi′≠oio'_i \ne o_i only if μi=1\mu_i = 1. □

The role and limits of mass matching

Attention matching ([34]), the strongest prior offline method, builds its selection and refit around reproducing each query’s attention mass on the compacted block. Two consequences of § 3.2 matter here: for how the refit must be run, and for what mass matching can tell selection.

Per-position mass fitting is harmful alone and misleading as a selection signal. Non-uniform multipliers change the retained attention pattern, so the original values no longer reconstruct oio_i under the reweighted pattern. Fitting multipliers to mass targets without the subsequent value solve is therefore worse than no refit at all, which is why the refit of § 3.4 applies the two solves only as an ordered unit. This is measured on the KV-Surgeon support: re-solving the multipliers alone scores 12.0 points below serving the elimination’s own coefficients with no refit at all, and 14.2 below the full final refit (panel (c) of Table 14). The mechanism is the reweighting rather than the mass objective in particular, so the ablation bounds what mass fitting costs when it is run alone and does not separate it from other multiplier objectives. Mass matching also misleads selection. Weighting the mass term heavily, formally γ→∞\gamma\to\infty in (9), reduces the saliency (11) to its mass component, so that entries are ranked by their fractional contribution to reproducing the attention mass alone, as in attention matching, and their values play no role in selection. This discards both factors that the exact loss (13) says matter, the value novelty ∥vj−oi∥2\lVert v_j-o_i\rVert^2 and the heavy-hitter weight (1−Pij)−2(1-P_{ij})^{-2}. At mild compaction the difference is small, because retained masses stay near one and all criteria agree. At aggressive compaction the two criteria part ways, and the exact loss sides with the output: replacing mass ranking by KV-Surgeon selection inside an otherwise identical pipeline is worth 1.3 points at 20×20\times, 3.0 at 50×50\times, and 4.3 at 100×100\times (Figure 2).

None of this contradicts the published attention-matching results, because all of those results combine mass matching with a value refit.

Served multipliers in chunked caches. Lemma 1 says that a compacted block must preserve its attention mass when it is served next to other tokens. We test this on LongHealth with KV-Surgeon-fast on Qwen3-4B-Instruct-2507, where every context holds five patient records compacted as separate chunks. We vary only what multipliers the compacted entries are served with: the box-constrained refit of § 3.4, the multipliers that the elimination itself leaves on the support, clamped to the same box, or unit multipliers. Values are refit in all three cases. Each setting is run in two regimes. In the first, all five records are compacted. In the second, two or three records are kept uncompacted next to the compacted ones; the two complementary masks {1, 3} and {0, 2, 4} are both run, so every record is served once compacted and once uncompacted, and accuracy is split by whether a question asks about a compacted or an uncompacted record.

Three things follow from Table 17. First, unit multipliers are harmless when everything is compacted the same but harmful when compacted cache chunks are served next to uncompacted ones. With all records compacted they cost 1.6 and 1.7 points. With uncompacted neighbors the same compacted records lose 12.2 points at 100× and 8.9 at 50×, while the uncompacted neighbors gain 1 to 3 points. This is the re-routing of Lemma 1: a block whose mass falls below the original hands attention to its neighbors. When every block is compacted, the deficits are similar and largely cancel. Second, mass-preserving multipliers make a block’s accuracy independent of its neighbors: for both fitted settings the compacted records score the same whether their neighbors are compacted or not. Third, the multipliers that the elimination leaves on the support, clamped to the box of (22), match the refit within seed noise, so the final multiplier solve can be skipped at no cost. Removing the mass term from the surrogate (γ0=0\gamma_{0}=0) changes every cell within two standard errors, consistent with Appendix § 11.§ 3: mass preservation is carried by the served multipliers, not by the selection.

Multipliers100× All compacted100× Mixed compacted100× Mixed uncompacted50× All compacted50× Mixed compacted50× Mixed uncompacted
Refit (default)57.5 ±0.858.0 ±0.778.2 ±0.666.9 ±0.567.9 ±0.679.4 ±0.5
From the elimination56.7 ±0.456.5 ±0.779.2 ±0.568.5 ±0.767.8 ±0.378.7 ±0.5
Unit55.9 ±0.645.8 ±0.881.3 ±0.265.2 ±0.659.0 ±0.980.6 ±0.5

Table 17. Accuracy (%) by served multipliers, KV-SURGEON-fast on LongHealth with Qwen3-4B-Instruct-2507, five seeds, standard error over seeds in grey. All compacted: all five records compacted. Mixed: two or three records served uncompacted; accuracy on questions about the compacted and the uncompacted records is reported separately. Each column covers all 400 questions.

Multiplier diagnostics for the unconstrained elimination

Table 18 shows the impact of a relaxation that makes closed-form compensation possible, i.e., relaxing the multiplier coefficients to real numbers instead of positive numbers. Fewer than half a percent of kept coefficients end negative at any ratio, the median head has no negative coefficients, and the numbers are unchanged between the repeat and self-study query tiers. The refit is calibration, not sign repair: it rescales substantially (median relative movement 0.5 to 0.8, correlation 0.4 to 0.7) and its pinning at the upper bound grows from 4% of multipliers at 5× to 15% at 100×, where restoring the attention mass requires the largest multipliers. Negative coefficients concentrate in early layers (1–6), and refit movement is largest in late layers (25–34).

References

  1. [1]Lisa Adams, Felix Busch, Tianyu Han, Jean-Baptiste Excoffier, Matthieu Ortola, Alexander Löser, Hugo JWL. Aerts, Jakob Nikolas Kather, Daniel Truhn, and Keno Bressen. Longhealth: A question answering benchmark with long clinical documents, 2024. URL https://arxiv.org/abs/2401.14490.
  2. [2]Yongqi An, Chang Lu, Kuan Zhu, Tao Yu, Chaoyang Zhao, Hong Wu, Ming Tang, and Jinqiao Wang. Rest-kv: Robust kv cache eviction with layer-wise output reconstruction and spatial-temporal smoothing. In C. Vondrick, B. Hariharan, C. Raffel, L. Pinto, D. Yang, and A. Faust (eds.), International Conference on Learning Representations, volume 2026, pp. 86943–86967, 2026. URL https://proceedings.iclr.cc/paper_files/paper/2026/file/8be9c134bb193d8bd3827d4df8488228-Paper-Conference.pdf.
  3. [3]Egor Bogomolov, Aleksandra Eliseeva, Timur Galimzyanov, Evgeniy Glukhov, Anton Shapkin, Maria Tigina, Yaroslav Golubev, Alexander Kovrigin, Arie Van Deursen, Malileh Izadi, et al. Long code arena: a set of benchmarks for long-context code models. arXiv preprint arXiv:2406.11612, 2024. URL https://arxiv.org/pdf/2406.11612.
  4. [4]Chi-Chih Chang, Wei-Cheng Lin, Chien-Yu Lin, Chong-Yan Chen, Yu-Fang Hu, Pei-Shuo Wang, Ning-Chi Huang, Luis Ceze, Mohamed Abdelfattah, and Kai-Chiang Wu. Palu: Kv-cache compression with low-rank projection. In International Conference on Learning Representations, volume 2025, pp. 50222–50249, 2025. URL https://proceedings.iclr.cc/paper_files/paper/2025/file/7da6e0e00702c60607a6ae05c802ef85-Paper-Conference.pdf.arxiv.org/abs/2407.21118
  5. [5]Alessio Devoto, Yu Zhao, Simone Scardapane, and Pasquale Minervini. A simple and effective l2 norm-based strategy for kv cache compression. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 18476–18499, 2024. URL https://aclanthology.org/2024.emnlp-main.1027.pdf.arxiv.org/abs/2406.11430
  6. [6]Sabri Eyuboglu, Ryan Ehrlich, Simran Arora, Neel Guha, Dylan Zinsley, Emily Liu, Atri Rudra, James Y Zou, Azalia Mirhoseini, and Christopher Re. Cartridges: Lightweight and general-purpose long context representations via self-study. In International Conference on Learning Representations, volume 2026, pp. 42642–42687, 2026. URL https://proceedings.iclr.cc/paper_files/paper/2026/file/4681359a7b1e94571598ad1adda35e6e-Paper-Conference.pdf.arxiv.org/abs/2506.06266
  7. [7]Yuan Feng, Junlin Lv, Haoyu Guo, Yukun Cao, S Kevin Zhou, and Xike Xie. Criticalkv: Optimizing kv cache eviction from an output perturbation perspective, 2026. URL https://openreview.net/pdf?id=vMwlcLYl4b.arxiv.org/abs/2502.03805
  8. [8]Elias Frantar and Dan Alistarh. Sparsegpt: Massive language models can be accurately pruned in one-shot. In International Conference on Machine Learning, pp. 10323–10337. PMLR, 2023. URL https://proceedings.mlr.press/v202/frantar23a.arxiv.org/abs/2301.00774
  9. [9]Nathan Godey, Alessio Devoto, Yu Zhao, Simone Scardapane, Pasquale Minervini, Éric de la Clergerie, and Benoît Sagot. Q-filters: Leveraging qk geometry for efficient kv cache compression. arXiv preprint arXiv:2503.02812, 2025. URL https://arxiv.org/pdf/2503.02812.
  10. [10]Raghav Goel, Junyoung Park, Mukul Gagrani, Dalton Jones, Matthew J Morse, Matthew Harper Langston, Christopher Lott, and Mingu Lee. Coate: Optimizing kv cache memory through attention output error-based token eviction. In ICLR 2026 Workshop on Memory for LLM-Based Agentic Systems, 2026. URL https://openreview.net/pdf?id=yoIbP0NoZv.
  11. [11]Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jau hri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Alex Vaughan, Amy Yang, Angela Fan, Anirudh Goyal, Anthony Hartshorn, Aobo Yang, Archi Mitra, Archie Sranykumar, Artem Koren ev, Arthur Hinsvark, Arun Rao, Aston Zhang, Aurelien Rodriguez, Austen Gregerson, Ava Spataru, Baptiste Roziere, Bethany Biron, Binh Tang, Bobbie Chern, Charlotte Cau cheteux, Chaya Nayak, Chloe Bi, Chris Marra, Chris McConnell, Christian Keller, Christophe Touret, Chunyang Wu, Corinne Wong, Cristian Canton Ferrer, Cyrus Nikolaidis, Damien Allonsius, Daniel Song, Danielle Pintz, Danny Livshits, Danny Wyatt, David Esiobu, Dhruv Choudhary, Dhruv Mahajan, Diego Garcia-Olano, Diego Perino, Dieuwke Hupkes, Egor Lakomkin, Ehab AlBadawy, Elina Lob anova, Emily Dinan, Eric Michael Smith, Filip Radeno vic, Francisco Guzmán, Frank Zhang, Gabriel Synnaeve, Gabrielle Lee, Georgia Lewis Anderson, Govind Thattai, Graeme Nail, Gregoire Mialon, Guan Pang, Guillem Cucurell, Hailey Nguyen, Hannah Korevaar, Hu Xu, Hugo Touvron, Ilyan Zarov, Imanol Arrieta Ibarra, Isabel Kloumann, Ishan Misra, Ivan Evtimov, Jack Zhang, Jade Copet, Jaewon Lee, Jan Geffert, Jana Vranes, Jason Park, Jay Mahadeokar, Jeet Shah, Jelmer van der Linde, Jennifer Billock, Jenny Hong, Jenya Lee, Jeremy Fu, Jianfeng Chi, Jianyu Huang, Jiawen Liu, Jie Wang, Jiecao Yu, Joanna Bitton, Joe Spisak, Jongsoo Park, Joseph Rocca, Joshua Johnston, Joshua Saxe, Junteng Jia, Kalyan Vasuden Alwala, Karthik Prasad, Kartikeya Upasani, Kate Plawiak, Ke Li, Kenneth Heafield, Kevin Stone, Khalid El-Arini, Krithika Iyer, Kshitiz Malik, Kuenley Chiu, Kunal Bhalla, Kushal Lakhotia, Lauren Rantala-Yeary, Laurens van der Maaten, Lawrence Chen, Liang Tan, Liz Jenkins, Louis Martin, Lovish Madaan, L ubo Malo, Lukas Blecher, Lukas Landzaat, Luke de Oliveira, Madeline Muzzi, Mahesh Pasupuleti, Mannat Singh, Manohar Paluri, Marcin Kardas, Maria Tsimpoukelli, Mathew Oldham, Mathieu Rita, Maya Pavlova, Melanie Kambadur, Mike Lewis, Min Si, Mitesh Kumar Singh, Mona Hassan, Naman Goyal, Narjes Torabi, Nikolay Bashlykov, Nikolay Bogoychev, Niladri Chatterji, Ning Zhang, Olivier Duchenne, Onur Celebi, Patrick Alrassy, Pengchuan Zhang, Pengwei Li, Petar Vasic, Peter Weng, Prajjwal Bhargava, Pratik Dubal, Praveen Krishnan, Punit Singh Koura, Puxin Xu, Qing He, Qingxiao Dong, Ragavan Srinivasan, Raj Ganapathy, Ramon Calderer, Ricardo Silveira Cabral, Robert Stojnic, Roberta Raileanu, Rohan Maheswari, Rohit Girdhar, Rohit Patel, Romain Sauvestre, Ronnie Polidoro, Roshan Sumbaly, Ross Taylor, Ruan Silva, Rui Hou, Rui Wang, Saghar Hosseini, Sahana Chennabasappa, Sanjay Singh, Sean Bell, Seohyun Sonia Kim, Sergey Edunov, Shao liang Nie, Sharan Narang, Sharath Raparthy, Sheng Shen, Shengye Wan, Shruti Bhosale, Shun Zhang, Simon Vandenhende, Soumya Batra, Spencer Whitman, Sten Sootla, Stephane Collot, Suchin Gururangan, Sydney Borodinsky, Tamar Herman, Tara Fowler, Tarek Sheasha, Thomas Georgiou, Thomas Scialom, Tobias Speckbacher, Todor Mihaylov, Tong Xiao, Ujjwal Karn, Vedan uj Goswami, Vibhor Gupta, Vignesh Ramanathan, Viktor Kerkez, Vincent Gonguet, Virginie Do, Vish Vogeti, Vítor Albiero, Vladan Petrovic, Weiwei Chu, Wenhan Xiong, Wenyin Fu, Whitney Meers, Xavier Martinet, Xiaodong Wang, Xiaofang Wang, Xiaoqing Ellen Tan, Xide Xia, Xinfeng Xie, Xuchao Jia, Xuewei Wang, Yaelle Goldschlag, Yashesh Gaur, Yasmine Babaei, Yi Wen, Yiwen Song, Yuchen Zhang, Yue Li, Yuning Preprint. Under review.
  12. [13]Yuzhe Gu, Xiyu Liang, Jiaojiao Zhao, and Enmao Diao. Obcache: Optimal brain kv cache pruning for efficient long-context llm inference. 2026. URL https://openreview.net/pdf?id=f58VZpG6ls. Preprint. Under review.arxiv.org/abs/2510.07651
  13. [14]Zhiyu Guo, Hidetaka Kamigaito, and Taro Watanabe. Attention score is not all you need for token importance indicator in kv cache reduction: Value also matters. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 21158–21166, 2024. URL https://aclanthology.org/2024.emnlp-main.1178.pdf.arxiv.org/abs/2406.12335
  14. [15]Babak Hassibi and David Stork. Second order derivatives for network pruning: Optimal brain surgeon. In S. Hanson, J. Cowan, and C. Giles (eds.), Advances in Neural Information Processing Systems, volume 5. Morgan-Kaufmann, 1993. URL https://proceedings.neurips.cc/paper/1992/file/303ed4c69846ab36c2904d3ba8573050-Paper.pdf.
  15. [16]Coleman Hooper, Sehoon Kim, Hiya Mohammadzadeh, Michael W Mahoney, Yakun S Shao, Kurt Keutzer, and Amir Gholami. Kvquant: Towards 10 million context length llm inference with kv cache quantization. Advances in Neural Information Processing Systems, 37:1270–1303, 2024. URL https://proceedings.neurips.cc/paper_files/paper/2024/file/028cfbcf85435d39a40c4d61b42c994-paper-conference.pdf.arxiv.org/abs/2401.18079
  16. [17]Jang-Hyun Kim, Jinuk Kim, Sangwoo Kwon, Jae W Lee, Sangdoo Yun, and Hyun Oh Song. Kvzip: Query-agnostic kv cache compression with context reconstruction. Advances in Neural Information Processing Systems, 38:1675663–167591, 2026. URL https://proceedings.neurips.cc/paper_files/paper/2025/file/f4eaa4b8f2d08edb3f0af990d56134ea-Paper-Conference.pdf.arxiv.org/abs/2505.23416
  17. [18]Yann LeCun, John S. Denker, and Sara A. Solla. Optimal brain damage. In David S. Touretzky (ed.), Advances in Neural Information Processing Systems 2, [NIPS Conference, Denver, Colorado, USA, November 27-30, 1989], pp. 598–605. Morgan Kaufmann, 1989. URL https://proceedings.neurips.cc/paper/1989/hash/6c9882bbac1c7093bd25041881277658-Abstract.html.
  18. [19]Yuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh, Acyr Locatelli, Hanchen Ye, Tianle Cai, Patrick Lewis, and Deming Chen. Snapkv: Llm knows what you are looking for before generation. Advances in Neural Information Processing Systems, 37:22947–22970, 2024. URL https://proceedings.neurips.cc/paper_files/paper/2024/file/28ab41842603e0f7323e54185d19bde-Paper-Conference.pdf.arxiv.org/abs/2404.14469
  19. [20]Manlai Liang, JiaMing Zhang, Xiong Li, and Jinlong Li. Lagkv: Lag-relative information of the kv cache tells which tokens are important. arXiv preprint arXiv:2504.04704, 2025. URL https://arxiv.org/pdf/2504.04704.
  20. [21]Zichang Liu, Aditya Desai, Fangshuo Liao, Weitao Wang, Victor Xie, Zhaozhuo Xu, Anastasios Kyrillidis, and Anshumali Shrivastava. Scissorhands: Exploiting the persistence of importance hypothesis for llm kv cache compression at test time. Advances in Neural Information Processing Systems, 36:52342–52364, 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/file/a452a7c6c463e4ae8fbdc614c6e983e6-Paper-Conference.pdf.arxiv.org/abs/2305.17118
  21. [22]Zirui Liu, Jiayi Yuan, Hongye Jin, Shaochen Zhong, Zhaozhuo Xu, Vladimir Braverman, Beidi Chen, and Xia Hu. KIVI: A tuning-free asymmetric 2bit quantization for KV cache. In Ruslan Salakhutdinov, Zico Kolter, Katherine Heller, Adrian Weller, Nuria Oliver, Jonathan Scarlett, and Felix Berkenkamp (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 32332–32344. PMLR, 21–27 Jul 2024. URL https://raw.githubusercontent.com/mlresearch/v235/main/assets/liu24bz/liu24bz.pdf.DOI
  22. [23]Piotr Nawrot, Adrian Łańcucki, Marcin Chochowski, David Tarjan, and Edoardo Ponti. Dynamic memory compression: Retrofitting LLMs for accelerated inference. In Ruslan Salakhutdinov, Zico Kolter, Katherine Heller, Adrian Weller, Nuria Oliver, Jonathan Scarlett, and Felix Berkenkamp (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 37396–37412. PMLR, 21–27 Jul 2024. URL https://raw.githubusercontent.com/mlresearch/v235/main/assets/nawrot24a/nawrot24a.pdf. Preprint. Under review.arxiv.org/abs/2403.09636
  23. [24]Matanel Oren, Michael Hassid, Nir Yarden, Yossi Adi, and Roy Schwartz. Transformers are multi-state rnns. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 18724–18741, 2024. URL https://aclanthology.org/2024.emnlp-main.1043.pdf.arxiv.org/abs/2401.06104
  24. [25]Richard Yuanzhe Pang, Alicia Parrish, Nitish Joshi, Nikita Nangia, Jason Phang, Angelica Chen, Vishakh Padmakumar, Johnny Ma, Jana Thompson, He He, and Samuel R. Bowman. Quality: Question answering with long input texts, yes!, 2022. URL https://arxiv.org/abs/2112.08608.
  25. [26]Utkarsh Saxena, Gobinda Saha, Sakshi Choudhary, and Kaushik Roy. Eigen attention: Attention in low-rank space for kv cache compression. In Findings of the Association for Computational Linguistics: EMNLP 2024, pp. 15332–15344, 2024. URL https://aclanthology.org/2024.findings-emnlp.899.pdf.arxiv.org/abs/2408.05646
  26. [27]Gemma Team, Aishwarya Kamath, Johan Ferret, Shreya Pathak, Nino Vieillard, Ramona Merhej, Sarah Perrin, Tatiana Matejovicova, Alexandre Ramé, Morgane Rivière, et al. Gemma 3 technical report. arXiv preprint arXiv:2503.19786, 2025.
  27. [28]Zhongwei Wan, Xinjian Wu, Yu Zhang, Yi Xin, Chaofan Tao, Zhihong Zhu, Xin Wang, Siqi Luo, Jing Xiong, Longyue Wang, et al. D2o: Dynamic discriminative operations for efficient long-context inference of large language models. arXiv preprint arXiv:2406.13035, 2024. URL https://arxiv.org/pdf/2406.13035.
  28. [29]Zheng Wang, Boxiao Jin, Zhongzhi Yu, and Minjia Zhang. Model tells you where to merge: Adaptive kv cache merging for llms on long-context tasks. arXiv preprint arXiv:2407.08454, 2024. URL https://arxiv.org/pdf/2407.08454.
  29. [30]Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In International Conference on Learning Representations, volume 2024, pp. 21875–21895, 2024. URL https://proceedings.iclr.cc/paper_files/paper/2024/file/5e5fd8f863c6d8ae392a93fd271c9-Paper-Conference.pdf.
  30. [31]An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chenggen Huang, Chenxu Lv, et al. Qwen3 technical report. arXiv preprint arXiv:2505.09388, 2025. URL https://arxiv.org/pdf/2505.09388.
  31. [32]Yuxin Zhang, Yuxuan Du, Gen Luo, Yunshan Zhong, Zhenyu Zhang, Shiwei Liu, and Rongrong Ji. CaM: Cache merging for memory-efficient LLMs inference. In Ruslan Salakhutdinov, Zico Kolter, Katherine Heller, Adrian Weller, Nuria Oliver, Jonathan Scarlett, and Felix Berkenkamp (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 58840–58850. PMLR, 21–27 Jul 2024. URL https://raw.githubusercontent.com/mlresearch/v235/main/assets/zhang24n/zhang24n.pdf.
  32. [33]Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, et al. H2O: Heavy-hitter oracle for efficient generative inference of large language models. Advances in Neural Information Processing Systems, 36:34661–34710, 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/file/6ceefa7b5572587b78efcceb28278-Paper-Conference.pdf.
  33. [34]Adam Zweiger, Xinhong Fu, Han Guo, and Yoon Kim. Fast kv compaction via attention matching. 306, 2026. URL https://openreview.net/pdf?id=tO1SKTj8pP.

Paper details

vlnc:W_wy58webf
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

Not recorded for this paper · View statement →

Looking for related papers…
Contents