# KVzip: compress the KV cache once, by scoring it with the model's own reread

> Satyajit Ghana — Head of Engineering @ Inkers Technology
> canonical: https://ai.satyajit.si/articles/kvzip-kv-compression
> date: 2026-10-02
> tags: kv-cache, inference, long-context, attention

Long context costs memory, and most of that memory is the KV cache. **KVzip** ([arXiv 2505.23416](https://arxiv.org/abs/2505.23416), NeurIPS'25 oral, [MIT code](https://github.com/snu-mllab/KVzip)) shrinks it with one idea: score every cached pair by how much the model needs it to recite the context back, then throw away the pairs it never reaches for. Because no question is involved in the scoring, the compressed cache serves every question that comes later.

The first version of this page explained that idea from the papers and repository and ran nothing. This one runs it. I installed the official code on an RTX 3090, scored real contexts with its own scorer, and measured the claim the method rests on: that the attention a pair gets during the reread is a better guide to keep it than the attention it got while the context was first read. It is, by a wide margin. One thing the earlier version of this page had backwards is fixed below too.

The second half covers **Attention Matching** ([arXiv 2602.16284](https://arxiv.org/abs/2602.16284)), which keeps none of the real pairs and fits a smaller synthetic cache, and the [Ramp Labs](https://x.com/RampLabs/status/2104636107174334612) write-up that put both methods on GLM-5.3 and reported an 80% smaller cache.

## The cache is the bill

A decoder-only transformer stores, for every token it has seen, the key and value vectors of every attention layer. Generating the next token is then one attention step over that store instead of a re-read of the whole prompt. The [KV cache architecture note](/architectures/attention-kv) covers MHA, MQA, GQA and MLA byte by byte; [how self-attention works](/articles/how-transformers-attention-works) sits under it.

The store grows linearly with context. The KVzip paper's own example: 120K tokens in Qwen2.5-14B at FP16 is about 33 GB of cache, more than the model's 28 GB of weights at the same precision. Every decoded token reads all of it, so the cache sets attention latency as well as memory. Halve it and you get both back.

Shrinking it means dropping pairs. Every method answers the same question differently: which pairs, and scored against what?

## A cache scored for one question fails the next

H2O, SnapKV and PyramidKV score each cached pair by how much the *current query* attends to it, then keep the top fraction. In a one-question setting that works. The tokens the question looks at are the tokens its answer needs.

It breaks when the cache is reused. Compress a document's cache for the first question and you have kept what that question looked at. Ask a second, unrelated question and the pairs it needs may be gone. The KVzip paper measures this on SQuAD with LLaMA3.1-8B (its Figure 2): SnapKV holds up when it re-runs prefill and compression for every question, and falls away when the cache compressed for the first question is reused for the rest. The abstract puts it bluntly: query-aware methods "suffer from performance degradation even at a 90% cache budget ratio under multi-query scenarios."

So the score has to be **query-agnostic**. Compute it once, without reference to any future question, and one compressed cache can serve a whole conversation.

## The reread

KVzip's query-agnostic question is: which pairs does the model need in order to reproduce this context? After the normal prefill, it runs one more forward pass over the cache. The input is a repeat instruction followed by the context itself, teacher-forced, so a single pass simulates the model reciting its context. The code states the prompt literally:

```python
# model/wrapper.py: the reconstruction "query" is the same for every context
prompt = "\n\nRepeat the previous context exactly."
# later chunks: "...starting with <last 8 tokens of the previous chunk>"
input_ids.append((a_ids, torch.cat([q_ids, self.postfix_ids, a_ids], dim=1)))
```

During that pass each cached pair receives some attention from each reciting position. Its importance is the **maximum** it receives, over every reciting position and every query head that shares its KV head (grouped-query attention):

```python
# attention/score.py: softmax over keys, then max over the GQA group and the queries
attn_weights = nn.functional.softmax(attn_weights, dim=-1)
score = attn_weights[..., self.sink:self.sink + ctx_len].amax(dim=(-3, -2))
```

Writing $a^{(g)}_{j,i}$ for the attention that reciting position $j$ in query head $g$ puts on cached pair $i$, after the softmax:

$$
s_i = \max_{j}\ \max_{g \in \text{group}(i)}\ a^{(g)}_{j,i}.
$$

Max, not sum, so a pair that one reciting position depends on heavily is kept even if nothing else looks at it. The system prompt (the "sink") is never evicted. Eviction is a single global threshold over every layer and KV head, so a head whose pairs score high keeps more of them; KVzip adapts AdaKV's variable-length FlashAttention kernel to run a cache with a different length per head.

<Figure
  src="https://media.thesatyajit.com/ai/articles/kvzip-kv-compression/fig1.png?v=9c6cf07bd03f353e"
  alt="A left-to-right pipeline. Context feeds the language model f_LM on Prefill, producing a KV cache KV_c drawn as a green grid of L·H heads by n_c sequence positions. A second box feeds 'Repeat prompt + Context' back into f_LM to Measure max cross-attention, producing a KV importance heatmap with heads on the vertical axis and sequence on the horizontal, cells shaded by importance. Low-scoring pairs are evicted (pair- or head-level), leaving a sparse green KV_c,evicted, which f_LM then uses with incoming Queries to decode Responses."
  caption="KVzip scores every cached pair by the maximum attention it receives while the model reconstructs the context from the cache, evicts the lowest, and reuses the compressed cache for any later query (KVzip, Figure 4)."
/>

## Why the reread and not the first read

There is a cheaper query-agnostic score sitting right there: the attention each pair received during prefill, when the context read itself. No second pass needed. Why not use that?

The paper's answer is its Figure 5, a histogram of the max attention per pair under both passes, on SQuAD with LLaMA3.1-8B. The reread is **sparser**. During prefill a model mixes information densely across tokens, so many pairs collect a moderate maximum; during the reread most pairs get almost nothing and a few get a lot, because the model can lean on what the cache already encodes plus what its weights know. The data files behind the figure ship in the arXiv source. As plotted, in bins of 0.1, 81.6% of pairs get a maximum below 0.1 under reconstruction against 55.0% under prefill; a finer copy of the same data in bins of 0.05 puts 71.9% against 33.5% below 0.05.

The earlier version of this page said the opposite: that prefill attention is the spiky one and reconstruction the broad one. That was wrong, and the widget that illustrated it was a toy built on the wrong direction. The chart below replaces it with data.

To check the figure I ran the official scorer, unmodified, on Qwen3-4B-Instruct-2507 (one RTX 3090, bf16, KVzip's `RetainCache`), and added a hook that records the prefill-side maximum from the same query and key states. The reconstruction scores are KVzip's own `kv.score`. Two sets of contexts: the first 101 SQuAD training contexts that KVzip's own `load_squad` returns (5,892,480 scored pairs in all), and one 8,000-token context from the Paul Graham essay haystack the repository ships for its needle test.

<ReconBars />

On SQuAD, 66.6% of Qwen3-4B's pairs fall in the lowest bin under reconstruction and 22.2% under prefill. In the paper's coarser 0.1 bins that is 76.4% against 37.0%, next to LLaMA3.1-8B's 81.6% against 55.0%. On the long essay it is 75.2% against 24.9%. Different model, same shape as the paper's LLaMA numbers. One detail I had to decide: during prefill every token attends to itself, and that self-attention can set a pair's maximum. Dropping it (the checkbox) moves the prefill histogram further toward zero, to 33.6% in the lowest bin on SQuAD, but it stays well short of the reread's sparsity. The headline figures use KVzip-style scoring with the diagonal included.

Sparse is only good if it is also *right*. A score that is near zero for most pairs is useful for eviction if those pairs really are dispensable. So the second measurement: one prefill per context, then every SQuAD question about that context answered from the same cache, after evicting by the reconstruction score, by the prefill score, or by a seeded random score. Same model, same KVzip global threshold, same greedy decoding (32 new tokens); an answer counts as correct when a gold SQuAD answer string appears in it. That is 98 questions over the first 20 contexts, each run at four cache sizes.

<KVEvictToy />

With the full cache the model gets 89 of the 98 right (90.8%). Keep 20% of the cache by KVzip's reread score and it gets 91; keep 30% or 50% and it gets 90 and 89. Those are the same as the full cache within a question or two, which on 98 questions is noise. At 10% it drops to 71. Score by prefill attention instead and the same budgets give 15, 17 and 41 at 20%, 30% and 50%, and 7 at 10%. Random eviction gives 14, 37 and 69, and 8 at 10%.

That last comparison is the surprise: at 30% and 50% of the cache, evicting by prefill attention is *worse than evicting at random*. It is also a claim about one exact setup (prefill score with each token's self-attention included, under KVzip's single global threshold across heads), so I reran the same contexts with two changes. The loader's cut-off leaves 94 questions on this run, with 85 right on the full cache.

| Kept | Prefill, no self-attention, global | Prefill, uniform per head | Reread, uniform per head | Reread, global (main run, of 98) |
|---|---|---|---|---|
| 10% | 14 | 21 | 17 | 71 |
| 20% | 18 | 28 | 38 | 91 |
| 30% | 28 | 50 | 53 | 90 |
| 50% | 42 | 66 | 73 | 89 |

Dropping the self-attention term helps the prefill score a little and it stays below random at 30% and 50%. The bigger effect is the budget. Give every KV head the same share (KVzip's `pair_uniform` mode) and the prefill score recovers most of the way to the reread score, while the reread score loses most of its lead: 53 against 50 at 30%, and at 10% the prefill score is ahead. So in my run the reread score and the global threshold work as a pair. A global threshold lets a head whose pairs score high keep more of them, which is the right call when the score means "needed to reproduce the context" and the wrong one when it means "attended to while reading". The paper makes the same point in its own ablation (its Figure 16, LLaMA3.1-8B on SQuAD): 92.4 with the non-uniform budget against 77.9 with a uniform one at 30% kept, a smaller gap than mine but the same direction.

This is small-scale. SQuAD contexts are short (a few hundred tokens), the model is 4B, and string containment is a coarse grader. It is not a replication of the paper's benchmark grid. What it does show is the mechanism and its dependency: with KVzip's global budget, the reread score keeps what later questions need and the first-read score does not, at every budget I tried; with a uniform per-head budget, much of that difference goes away.

## The paper's own numbers

The efficiency claim is **3-4x smaller KV cache and about 2x faster FlashAttention decode with negligible loss**, measured on LLaMA3.1-8B with a 124K-token context on an A100 in FP16 (their Figure 8). The 2x is attention decode latency, not end-to-end generation.

The accuracy claim is the benchmark grid below: twelve datasets on Qwen2.5-7B-Instruct-1M, accuracy against the share of cache kept. KVzip stays near flat down to about 30% while H2O, SnapKV and PyramidKV fall away, worst on retrieval tasks where a query-aware cache threw the needle out.

<Figure
  src="https://media.thesatyajit.com/ai/articles/kvzip-kv-compression/fig2.png?v=dda4f6f0f612867f"
  alt="A three-by-four grid of line charts, accuracy in percent on the vertical axis against KV cache ratio from 0.1 to 1.0 on the horizontal, for four methods: KVzip in red, H2O in orange, SnapKV in green, PyramidKV in blue. Rows are Retrieval (NIAH, Retr.KV, Retr.Prefix-Suffix, Code.RepoQA), Contextual QA (SQuAD, GSM8K, En.QA, En.MultiChoice) and Redundancy (En.Summary, Retr.MultiHop, Math.Find, ICL.ManyShot). The red KVzip line stays high and flat as the ratio falls to about 0.3 on nearly every panel, while the other three drop steeply at low ratios, collapsing toward zero on the retrieval tasks."
  caption="Accuracy against KV cache budget, Qwen2.5-7B-1M, twelve datasets. KVzip (red) holds down to ~30% cache where the query-aware baselines collapse, worst on retrieval (KVzip, Figure 9)."
/>

The models span 3B to 14B (LLaMA3.1-3B and 8B, Qwen2.5-7B-1M and 14B-1M, Gemma3-12B) at contexts up to 170K tokens. Gemma3 is compressed only on its global-attention layers.

**The reread is not free.** The paper puts the scoring pass at "approximately twice the computational overhead of standard prefill" with under 2% extra memory, paid once per context. It scores in chunks of $m$ tokens, so the cost is $O(m^2)$ per chunk and $O(m\,n_c)$ over a context of $n_c$ tokens. On my 8,000-token essay the official code took 1.27 s to prefill and 2.66 s to score on the 3090 (one timing, on a box other jobs were sharing), 2.1 times the prefill time, which is about what the paper says. Part of that is structural: the score needs a max over query positions *after* the softmax over keys, which a fused FlashAttention kernel never materialises, so the scoring pass runs attention the slow way. The paper also tests a softmax-free variant that scores on raw logits and trades a little quality for that (its Figure 15).

There is also a cheaper mode. **Context-independent** KVzip computes per-head scores once per model and drops whole heads' context KV, DuoAttention-style, with no per-context cost but a smaller ratio (`--ratio 0.6` recommended, about 1.67x). The README describes the head-score fit as "a few forward passes within one minute", against DuoAttention's optimisation-based fit.

<RepoCard repo="snu-mllab/KVzip" />

One stacked number from the paper: KVzip on top of QServe's 4-bit KV quantization takes a 16.3 GB FP16 cache at 124K tokens to 1.2 GB with 70% eviction. 16.3 / 1.2 is about 13.6x. Eviction and quantization are separate axes, and they multiply.

## Attention Matching keeps none of the real pairs

KVzip keeps a subset of the cached pairs exactly as they were. **Fast KV Compaction via Attention Matching** (Adam Zweiger, Xinghong Fu, Han Guo and Yoon Kim; [arXiv 2602.16284](https://arxiv.org/abs/2602.16284), [code](https://github.com/adamzweiger/compaction), MIT) keeps none of them unchanged. It builds a shorter cache whose keys, per-key biases and values are fitted so that attention over the short cache behaves like attention over the long one.

Take one KV head. The full cache is $(\mathbf{K},\mathbf{V})$ with $T$ rows. The compact cache is $(\mathbf{C}_k, \boldsymbol\beta, \mathbf{C}_v)$ with $t \ll T$ rows, where $\boldsymbol\beta$ is a scalar bias added to each compact key's logit. The requirement is that the compacted prefix still works when later tokens are appended: the user's next turn, the model's own continuation. Attention over a concatenation of blocks is a mixture of each block's local attention, weighted by each block's share of the softmax mass. So for a set of reference queries $q$ it is enough to match two quantities for the prefix block:

$$
\underbrace{\sum_{i=1}^{T} e^{q\cdot k_i}}_{\text{mass}} \approx \sum_{j=1}^{t} e^{q\cdot c_j + \beta_j},
\qquad
\underbrace{\frac{\sum_i e^{q\cdot k_i} v_i}{\sum_i e^{q\cdot k_i}}}_{\text{local output}} \approx \frac{\sum_j e^{q\cdot c_j+\beta_j} c^{v}_j}{\sum_j e^{q\cdot c_j+\beta_j}} .
$$

Match the mass and the block keeps its right share of attention against whatever comes after it. Match the local output and that share carries the right content.

<Figure
  src="https://media.thesatyajit.com/ai/articles/kvzip-kv-compression/fig3.png?v=00687859fdd7229f"
  alt="A long row of blue cells labelled 'Full KV Cache K, V' followed by a few grey 'fixed' cells, compacted via an arrow into a short row of three orange cells labelled 'Compacted C_k, C_v' followed by the same grey fixed cells. Below, the equation: attention of query q over the stacked full keys K and K_fixed and values V and V_fixed is approximately equal to attention of q over the compacted C_k and K_fixed and C_v and V_fixed."
  caption="Attention Matching replaces the real cache with a smaller synthetic one chosen so the attention output is preserved under concatenation with any fixed or future tokens (Attention Matching, Figure 2)."
/>

Solving that jointly would be a nonconvex fit. The paper splits it into three steps, two of which have closed forms:

1. **Pick the compact keys** $\mathbf{C}_k$ from the real keys. Two rules: *HighestAttnKeys* keeps the keys with the largest aggregated attention under the reference queries (the same family of score as KVzip's; the paper's appendix compares aggregation functions), and *OMP* (orthogonal matching pursuit) greedily adds whichever key best explains the attention mass the current set still misses.
2. **Fit the mass.** With keys fixed, the mass condition is linear in $w_j = e^{\beta_j}$: a nonnegative least squares over the reference queries. Then $\beta_j = \log w_j$. A $w_j$ of 5 says this one kept key now stands in for about five keys' worth of attention mass.
3. **Fit the values.** With keys and biases fixed, the attention weights over the compact cache are known numbers, and the value condition is ordinary least squares for $\mathbf{C}_v$.

The reference queries come mainly from a repeat-prefill pass (the same reread KVzip uses), with a few self-study prompts to widen them, and the cache is built one layer at a time so each layer is fitted to the queries the already-compacted layers below it actually produce.

<Figure
  src="https://media.thesatyajit.com/ai/articles/kvzip-kv-compression/fig4.png?v=099067ee7638eea0"
  alt="Scatter plot titled Qwen3 (50x Compaction). Accuracy on the vertical axis from 0.40 to 0.70, average compaction time per article in seconds on a log horizontal axis from 1 to 10,000. A dashed line marks the original cache near 0.71 and another the no-context baseline near 0.37. Summarization sits near 0.52 at about 1 second. H2O+, KVzip, PyramidKV and SnapKV cluster between 0.40 and 0.48 at 2 to 9 seconds. The attention-matching variants rise from AM-HighestAttnKeys-fast near 0.58 at about 8 seconds to AM-HighestAttnKeys near 0.65 at about 45 seconds and AM-OMP near 0.665 at about 300 seconds, inside a green box labelled high quality compaction in under 1 minute for the first two. Cartridges sits to the right, 0.50 to 0.60, at 1,500 to 18,000 seconds."
  caption="Accuracy against compaction time at a fixed 50x ratio, Qwen3-4B on QuALITY (n=894 questions), one H100. KVzip is among the one-shot eviction baselines near the bottom; the fitted methods sit above it, and Cartridges, which trains the compact cache, sits far to the right (Attention Matching, Figure 1)."
/>

That figure is where "50x in seconds" comes from, and it is worth reading carefully. At 50x the original cache scores about 0.71 on QuALITY. The fastest fitted variant (HighestAttnKeys-fast, roughly 8 seconds per article) lands near 0.58; the OMP variants reach about 0.66 but take minutes per article. KVzip, as one of the baselines, sits near 0.42 at this ratio. Fifty-fold compaction is far past where KVzip's paper evaluates it (its curves stop at a 0.1 ratio, 10x), so this is a comparison at the far end of the range, not a contradiction of KVzip's own results.

<Figure
  src="https://media.thesatyajit.com/ai/articles/kvzip-kv-compression/fig5.png?v=48078a3294fd72f2"
  alt="Six line charts in two rows: QuALITY on top and LongHealth below, for Qwen3-4B, Llama3.1-8B and Gemma3-12B. Accuracy on the vertical axes, compacted size from 0.01 to 0.20 on the horizontal. AM-OMP (purple) and AM-HighestAttnKeys (red) sit at or near the dashed original-cache line from 0.05 upward on most panels. KVzip (dark grey) climbs from far below toward them and on the Qwen3-4B LongHealth panel reaches the AM curves at 0.10 and 0.20. H2O+, SnapKV, PyramidKV, summarization and Cartridges sit below the AM curves."
  caption="Accuracy against compacted size on QuALITY and LongHealth for three models. Attention Matching (purple, red) holds near the original cache down to about 5% of the cache; KVzip (grey) catches up at 10-20% on some panels (Attention Matching, Figure 4)."
/>

Across ratios the picture is the same. From about 0.05 of the cache upward, the AM curves sit near the full-cache line on most panels. KVzip closes the gap at 0.10-0.20 on some of them, and the paper credits KVzip's non-uniform head budget for that ("KVzip sometimes matches Attention Matching performance, which we attribute to its non-uniform budget outperforming our precomputed budget at certain compaction ratios"). Their appendix also runs the 6,500 RULER tasks from NVIDIA's kvpress: at 5% of the cache on Llama-3.1-8B-Instruct, KVzip scores 46.6 and AM-HighestAttnKeys-fast 83.3, and at 12.5% they are 92.3 and 95.1 against 95.7 for the full cache (their Table 11). Stacked on a summary, AM-OMP reaches about 200x total (6,340 to 31 effective tokens on average) at roughly the summary's own accuracy (their Table 4).

Two limits stay in the paper. Everything is per KV head, with separate keys, biases and values for each, and nothing addresses a cache that is shared across heads. And the models stop at 12B.

## What Ramp Labs actually measured on GLM-5.3

The write-up that brought both papers to this site is Ramp Labs' "Scaling KV Cache Compression to Frontier Models" (Jeff Zheng and Alex Chen, posted as an [X article](https://x.com/RampLabs/status/2104634941405266021)). Its model is [GLM-5.3](/articles/glm-5-3), the 78-layer model, not the smaller GLM-5.3-Flash the earlier version of this page pointed at. Their architecture description matches the config the GLM-5.3 page reads: DeepSeek Sparse Attention, where a learned indexer picks at most 2,048 positions for each query; IndexShare, which reuses one indexer's selection across a group of layers (21 groups); and multi-head latent attention, where one shared 576-dimensional latent key and 512-dimensional latent value serve all 64 query heads in a layer.

<Video
  src="https://ai.satyajit.si/articles/kvzip-kv-compression/clip1"
  poster="https://media.thesatyajit.com/ai/articles/kvzip-kv-compression/clip1-poster.jpg?v=78a6da53599aae60"
  alt="Animated slides on a light background. Text reads that KV cache compression algorithms were built for dense attention and keep different cache entries for each KV head, shown as four separate point-cloud shapes, one per head; then that GLM's sparse attention uses one shared latent cache that projects into each head's keys and values, with the four shapes merging into one shared block."
  caption="Why the published methods do not drop onto GLM-5.3: both pick a separate subset per KV head, and GLM's cache is one shared latent per layer. Video from @RampLabs' post on X."
/>

That breaks both methods as published. KVzip and Attention Matching choose a separate set of positions per layer and head, and a shared latent cache needs one set for every head in an IndexShare group. And sparse attention only scores what the indexer selected, so a position with no observed attention may simply never have been routed. Their fixes:

- **KVzip**: run the reread with *dense* attention through all 78 layers, so every position gets a score, then choose one shared set per group. Taking the raw maximum across the group lets a few loud heads take the budget. Normalising each head's scores to sum to one first ("normalized maximum") raised strict accuracy on 47 ComplexMCP tool-use tasks at 30% compression to 60.3%, 5.0 points above the raw maximum, over three runs.
- **Attention Matching**: keep shared keys, but fit a separate bias per head and key, then fit shared latent values jointly across heads, layer by layer on queries from the already-compressed lower layers. That is the MLA extension the Attention Matching paper does not have.

The 80% headline comes from the second one. On QuALITY, five articles and 90 questions, four runs, full context scores 91.8%. Attention Matching with OMP keeps 83.9% at 80% compression, 81.8% at 90% and 77.8% at 95%; with HighestAttnKeys it is 73.7% at 95%; eviction alone with their KVzip adaptation is 67.8% at 95%.

<Video
  src="https://ai.satyajit.si/articles/kvzip-kv-compression/clip2"
  poster="https://media.thesatyajit.com/ai/articles/kvzip-kv-compression/clip2-poster.jpg?v=07e0a5e384f6b6fe"
  alt="A slide reading 'We reduced the KV cache by 80%, maintaining over 90% of full-context accuracy' beside a bar chart of answer accuracy against cache compression. Bars: 91.8% full context at 0%, 83.9% at 80% and 81.8% at 90% for OMP Attention Matching, 77.8% at 95% for OMP, 73.7% at 95% for HAK Attention Matching, and 67.8% at 95% for HAK KVzip. Footer: QuALITY, 5 articles, 90 questions, article cache only."
  caption="Ramp's headline chart. The 80% point is Attention Matching with OMP; KVzip-style eviction alone is the rightmost bar. Video from @RampLabs' post on X."
/>

So the claim checks as arithmetic: 83.9 / 91.8 is 91.4% of full-context accuracy at 80% compression. Carry the context with it. The method behind it is Attention Matching with OMP, not KVzip. The sample is 90 questions on five articles, where one question is 1.1 points. And no code is released, so the run cannot be repeated. A reply under the post makes the serving point too: 80% smaller lifts a KV-bound concurrency ceiling by at most 5x, and accuracy alone does not show whether scoring overhead keeps time-to-first-token and tail latency intact. Ramp's own number for that overhead is a 199.775-second dense score-capture pass on their ComplexMCP prefix of 29,807 tokens.

What the write-up does show is that a per-head method can be bent onto a shared-latent sparse model and still work, and that on such a model fitting beats eviction by about 10 points at 95%. That second result agrees with the Attention Matching paper's own small-model comparisons.

## Subset or synthesis

Quantization makes each cached number smaller ([4-bit KV via Model Optimizer](/articles/nvidia-model-optimizer), [sub-2-bit runtime compression](/articles/runtime-dynamic-compression)). Architecture makes the cache grow slower ([GLM-5.3-Flash's linear and sparse layers](/articles/glm-5-3-flash), [SparDA](/articles/sparda), [Grouped Value Attention](/articles/grouped-value-attention), [Flash-dLLM](/articles/flash-dllm)). These two methods work after the fact. KVzip keeps a subset of the real pairs; Attention Matching keeps synthetic ones fitted to behave like the whole.

If I were adding one of them to a serving stack today, I would start with KVzip. It is a scorer and a mask over a cache you already have, the reread costs about one extra prefill per context, and at the ratios its paper evaluates (down to 30% kept) the curves are close to flat. My run says its central mechanism is real, with a condition attached: the reread score plus the global cross-head budget is what makes query-agnostic eviction work, and the cheaper first-read score is not a substitute under that budget. Keep the non-uniform budget if you adopt it; my uniform-budget run lost most of the gain. Past 10x, the Attention Matching results say fitting beats any subset, and Ramp's GLM-5.3 run agrees. I would want their code before believing the 80% transfers to a different workload.

<Callout type="note">
**The run, for anyone repeating it.** Official [snu-mllab/KVzip](https://github.com/snu-mllab/KVzip) at `main`, its pinned stack (torch 2.3.0, transformers 4.51.3, flash-attn 2.7.4.post1, the repo's `csrc` kernel built for sm_86), Qwen3-4B-Instruct-2507 in bf16 on one RTX 3090, `RetainCache` with KVzip's own global threshold. I loaded Qwen3-4B-Instruct-2507 from a local path, which skips the YaRN override `model/load.py` applies to `Qwen3-*` ids, and gave it the plain Qwen template without the empty think block (this model has no thinking mode). The prefill score comes from a hook on the same attention forward that recomputes the context queries and takes the same softmax-then-max as `attention/score.py`, with and without each token's attention to itself. Eviction uses `RetainCache.prune` with `level="pair"` (the global threshold) or `"pair_uniform"` (the same share per head); answers are greedy, 32 new tokens, scored by gold-string containment. Everything else here (the paper's figures, the Attention Matching numbers, Ramp's results) is read from the sources, not rerun.
</Callout>
