---
title: 'HeadKV: Head-Aware KV-Cache Methods'
url: https://www.emergentmind.com/topics/headkv
type: topic
---

# HeadKV: Head-Aware KV-Cache Methods

Searching arXiv for recent papers on HeadKV and related KV-cache compression methods.
I’ll look up the relevant arXiv entries to ground the article in the cited papers.
HeadKV denotes a family of head-aware key-value cache compression methods that allocate memory and eviction decisions at the granularity of individual attention heads rather than treating all heads in a layer uniformly. Across long-context large language models, grouped-query attention systems, visual autoregressive models, and audio-language models, these methods exploit the empirical heterogeneity of heads—such as retrieval, reasoning, semantic-context, locality-biased, global, or modality-specialized behavior—to improve the trade-off between cache size and inference quality under fixed memory budgets [2410.19258], [2508.02401], [2605.20600], [2604.06694].

## 1. Scope, terminology, and the KV-cache bottleneck

In Transformer decoding, the KV cache stores historical key and value tensors so that new tokens can attend to prior context without recomputing the full history. In a multi-layer decoder with $L$ layers and $H$ heads, a per-head cache at decoding step $t$ is written as $K_{\ell,h},V_{\ell,h}\in\mathbb{R}^{t\times d}$, or equivalently as fourth-order tensors $K,V\in\mathbb{R}^{L\times H\times t\times d}$ [2410.14731]. This cache is a major systems bottleneck because its storage and memory-transfer costs grow with sequence length.

Within this setting, “HeadKV” is not a single algorithm but a recurring design principle: allocate cache non-uniformly across heads because heads contribute unequally to downstream performance. The term is used explicitly for several different methods, and related work extends the same head-aware premise to cooperative allocation, low-rank compression, and modality-specific scoring.

| Variant | Domain | Core mechanism |
|---|---|---|
| HeadKV / HeadKV-R2 | Long-context LLM QA | Per-head importance from retrieval or retrieval+reasoning examples |
| CompressKV (a.k.a. HeadKV) | GQA-based LLMs | Semantic Retrieval Heads plus layer-adaptive budgets |
| HeadKV | AR image generation | Local/global head classification plus stratified eviction |
| HeatKV | Visual autoregressive modeling | Per-head, per-scale static pruning |
| AudioKV | Audio-language models | Audio-critical head scoring plus spectral smoothing |

A recurring premise across these methods is that layer-level or uniform-budget compression is too coarse. In the language setting, HeadKV was introduced partly because prior methods such as PyramidKV and SnapKV allocate budgets at layer level and therefore may waste cache on unimportant heads or under-allocate critical ones [2410.19258]. In visual generation, fixed per-head budgets were likewise identified as suboptimal because some heads are locality-biased while others capture broader contextual structure [2605.20600].

## 2. HeadKV in long-context language models

The long-context LLM variant of HeadKV formulates compression as a two-stage pipeline: estimate head importance offline, then allocate per-head budgets and evict tokens accordingly. In “Not All Heads Matter: A Head-Level KV Cache Compression Method with Integrated Retrieval and Reasoning” [2410.19258], the retrieval-only score $S_h^{\text{ret}}$ checks whether the top-scoring token under head $h$ falls inside an inserted answer span, while HeadKV-R2 replaces this with a retrieval-plus-reasoning score that inspects top-$k$ attended tokens and weights those lying in the correct answer segment $A^2$. The stated motivation is that retrieval+reasoning examples yield a denser, more informative head-importance distribution.

Budget assignment is explicit. With base head budget $b$, inflation factor $\beta$, and local window $\alpha$, the dynamic pool is
$$
B=(b/\beta)\times(L\cdot H),
$$
and the per-head budget is
$$
\mathrm{budget}_h=(b-b/\beta)+S_h\times B+\alpha.
$$
At inference time, the method follows SnapKV-style attention pooling: during prefill, it aggregates attention from the last $\alpha$ tokens to all past tokens, ranks tokens by pooled attention score, and keeps the top $\mathrm{budget}_h$ tokens for each head [2410.19258].

The implementation choices are deliberately conservative. The paper fixes $\alpha=8$ instruct tokens for all methods, tunes $\beta$ in $\{1.005,1.01,1.1,1.2,1.5,2,5,10\}$, and does not hard-zero heads; every head receives a nonzero basic budget [2410.19258]. This is important because a common simplification is to interpret head-aware compression as pure head pruning, whereas the reported algorithm instead performs differentiated retention.

Empirically, the method is evaluated on LongBench and LooGLE with Llama-3-8B-Instruct and Mistral-7B-Instruct under KV budgets $\{64,128,256,512,1024\}$ plus Full KV. At KV$=128$, HeadKV-R2 reaches average F1 values of $32.00$ on Llama-3-8B-Instruct and $31.41$ on Mistral-7B-Instruct, compared with $32.90$ and $32.98$ for FullKV, leading to the paper’s summary that it recovers about $97\%$ of full-KV performance while retaining about $1.5\%$ of tokens. The same paper reports that peak memory is reduced by about $90\%$ at KV$=128$ versus FullKV, and that decoding latency is identical to other compressed-KV methods [2410.19258].

The paper also frames a broader methodological claim: contextual QA requires both retrieval and reasoning capability, so head importance should be estimated on examples that exercise both. The superiority of HeadKV-R2 over HeadKV-R and HeadKV-ER in the ablation table is consistent with that interpretation [2410.19258].

## 3. Semantic Retrieval Heads and layer-adaptive HeadKV

A second language-model line uses the name HeadKV through CompressKV, which is described as “CompressKV (a.k.a. HeadKV)” [2508.02401]. Its central claim is that token eviction should not be driven by all heads in grouped-query attention systems. Instead, it first identifies, for each layer $\ell$, a subset $S_\ell$ of “Semantic Retrieval Heads.”

The offline head score is the layer-specific
$$
\mathrm{SemanticRetrievalScore}^{\,\ell}(h)
=
\sum_{t=1}^{T}\mathbb{I}[y_t\in A]\sum_{j\in A} a_{t,j}^{\,\ell,h},
$$
where $A$ is the correct answer span and $a_{t,j}^{\ell,h}$ is the attention weight assigned to cached position $j$ when generating token $y_t$ [2508.02401]. Heads are sorted by this score, and the top-$K$ heads form $S_\ell$.

The retention rule then operates at layer level but is driven only by the selected heads. After prefilling a prompt of length $T_0$, token importance for position $j$ in layer $\ell$ is
$$
I_j^{\,\ell}
=
\frac{1}{|S_\ell|}\sum_{h\in S_\ell}\sum_{t=1}^{T_0} a_{t,j}^{\,\ell,h},
$$
computed over a short observation window, often the last few decoder steps. Given a per-layer budget $M_\ell$, the algorithm retains the top $M_\ell$ positions ranked by $I_j^\ell$, and for all other positions evicts $(K_j^{\ell,h},V_j^{\ell,h})$ for all heads $h$ in that layer [2508.02401].

Budgeting across layers is itself adaptive. CompressKV simulates extreme compression of each layer to a tiny cache, such as $32$ tokens, compares compressed and full attention-block outputs, and derives a normalized per-layer error $\tilde e^{(\ell)}$. Starting from lower bounds $m$, it distributes the remaining budget proportionally to $\tilde e^{(\ell)}$, subject to lower and upper bounds $m\le M_\ell\le M_{\max}$ and a final fix-up loop ensuring $\sum_\ell M_\ell=B_{\mathrm{total}}$ [2508.02401].

This formulation directly challenges a common assumption in earlier heuristic eviction schemes: that aggregating over all heads is an adequate proxy for token importance. The paper reports that the selected semantic heads not only attend to initial and final tokens, as “streaming heads” do, but also collectively activate on answer spans and surrounding semantic context; masking these semantic heads causes a much larger performance drop than masking traditional copy-and-paste heads [2508.02401].

On LongBench, the reported results are unusually aggressive. With only $3\%$ of the full KV cache, CompressKV retains more than $97\%$ of question-answering accuracy; with $19\%$ cache, it matches over $99\%$ of full-cache average performance. On Needle-in-a-Haystack, the paper reports $90\%$ of baseline retrieval accuracy at $0.07\%$ of full cache, described as $256$ entries versus about $400$K full [2508.02401].

## 4. Cooperative allocation and low-rank relatives

HeadKV-style work also sits alongside two neighboring directions: cooperative head-level budget allocation and feature-dimension compression. These papers do not always use the exact name “HeadKV,” but they sharpen the same underlying question: which parts of the KV cache matter, and how should a fixed budget be assigned?

CoKV argues that evaluating heads independently can misestimate their true effect because heads contribute cooperatively during inference. It formulates the extra-budget allocation problem
$$
\max_{b_1,\dots,b_n} U(b_1,\dots,b_n)
\quad \text{subject to} \quad
b_i\ge 0,\ \sum_i b_i=B,
$$
casts heads or head-groups as players in a cooperative game, and scores them with Shapley or Sliced Shapley values. After discarding the $\alpha$ heads with the smallest values, it allocates
$$
b_i = B\frac{\widehat\phi_i}{\sum_j \widehat\phi_j}.
$$
The paper reports state-of-the-art LongBench performance on Llama-3-8B-Instruct and Mistral-7B, $97.29\%$ of FullKV on Llama-3-8B at $128$ tokens, under $50\%$ of FullKV end-to-end prefill+decode time on Mistral-7B, and about $64\%$ peak GPU memory reduction at $32$K tokens [2502.17501].

MatryoshkaKV addresses a different axis: the feature dimension of cached keys and values. Rather than distributing token budgets, it projects each head’s cache from $d$ to a lower rank $r<d$ with trainable orthogonal matrices. The paper starts from PCA and explicitly notes its failure mode: when $r/d$ falls below about $0.6$, PCA projections suffer a rapid accuracy drop even though the keys or values can still be reconstructed with small squared error. MatryoshkaKV replaces static PCA with a distillation objective over trainable orthogonal matrices parameterized by Cayley transforms and uses a nested schedule with ranks in $\{d/8,d/4,d/2,3d/4,d\}$. It then performs adaptive search over layers and heads under a global budget, reporting more than $90\%$ performance with an average KV compression rate of $60\%$, up to $75\%$ in extreme scenarios, and about $2\%$ gain from head-wise adaptive allocation over uniform truncation [2410.14731].

ReCalKV is another feature-dimension method, but it explicitly incorporates head structure. For keys, it uses Head-wise Similarity-aware Reordering (HSR), computing pairwise CKA similarities among heads, greedily grouping similar heads, and applying grouped SVD after reordering the columns of $W_k$. For values, it uses Offline Calibration and Matrix Fusion (OCMF), updating low-rank factors with closed-form offline calibration and fusing the calibrated factor into $W_o$ so that no explicit reconstruction is required online. On LLaMA-2-7B at $70\%$ compression, the paper reports WikiText2 perplexity $6.75$ versus $8.62$ for Palu, zero-shot average $59.90$ versus $52.14$, and LongBench average $29.62$ versus $13.26$ [2505.24357].

A plausible implication is that head-aware token retention and head-aware feature compression are complementary rather than mutually exclusive. The papers do not present a unified system, but together they show that “head awareness” can govern both which cached tokens are kept and how each head’s cached vectors are represented.

## 5. Visual autoregressive HeadKV variants

In autoregressive image generation, HeadKV refers to a distinct but structurally similar idea: classify or rank heads by attention behavior, then assign asymmetric cache budgets. The 2026 paper “Head-Aware Key-Value Compression for Efficient Autoregressive Image Generation” defines two head types. A head is “local” if its minimal backward span $m_h(t)$ satisfying
$$
\sum_{j=t-m_h(t)}^{t-1} a_h(t,j)\ge \tau
$$
falls below a small window size $w_0$; otherwise it is “global.” The default threshold is $\tau=0.9$ [2605.20600].

Budgeting follows directly from this classification. Local heads keep only conditional tokens plus a fixed sliding window, $B_h=|k_c|+w$, while global heads keep conditional tokens plus a fraction $\rho$ of the historical cache and the same window, $B_h=|k_c|+\lfloor \rho T\rfloor+w$. Historical tokens for global heads are compressed by Stratified Token Eviction, which partitions history into long-range and near-range subsets, scores both with average attention over a query buffer of length $P$, and evicts the lowest-scored $M/2$ tokens from each subset [2605.20600].

The stated advantage is that head types can be identified early in generation and then reused, requiring no additional training or dataset-level statistics. The paper reports $50$–$65\%$ memory savings and $2$–$4\times$ speedups relative to full caching, with specific results such as LlamaGen-XL at $\rho=1/6$ using $12.34$ GB, $34.03$ s latency, and $3.78$ it/s on an NVIDIA A6000, and Janus-Pro-7B at $\rho=1/8$ using $20.45$ GB, $36.95$ s, and $1.48$ it/s [2605.20600].

HeatKV applies head tuning to visual autoregressive models that generate multiple scales. Rather than classifying heads as local or global, it aggregates per-head, per-scale attention into $\beta_{\ell,h}[k_1,k_2]$, defines a head-level Cumulative Attention Score (CAS) and a Scale-dependent CAS (S-CAS), and ranks head-scale pairs by importance. Using only $10$ calibration prompts, it builds a static pruning schedule under budget fraction $b$, with a formula for the number of head-scales to prune at scale $k$:
$$
N_k=\left\lceil \frac{T(c_k-bc_{K-1})}{c_k-c_s}\right\rceil.
$$
It then applies an early-pruning procedure that the paper states is optimal in the binary case under mild dominance conditions [2605.14877].

On Infinity-2B, the reported results at equal KV memory show clear gains over ScaleKV. At $20\%$ budget, both methods use $7800$ MB, but HeatKV reports FID $1.02$ versus $1.94$, LPIPS $0.044$ versus $0.079$, and PSNR $28.43$ versus $24.93$. At $10\%$ budget, HeatKV reports FID $1.67$ versus $2.59$. The paper further states that at $b=10\%$, HeatKV matches or surpasses ScaleKV at $b=20\%$ on all fidelity metrics, describing this as a $2\times$ effective compression improvement [2605.14877].

These two visual variants illustrate that HeadKV is not tied to one scoring primitive. One method uses online behavioral classification with no offline statistics [2605.20600]; the other uses offline calibration and a static per-scale schedule [2605.14877]. What they share is the rejection of uniform budgets across heads.

## 6. Audio specialization, limitations, and recurring themes

AudioKV extends the head-aware KV premise to large audio-language models. It identifies “audio-critical” heads offline by semantic-acoustic alignment on ASR data. Using ASR anchors with confidence threshold $\tau=0.95$, it maps recognized words to audio-token spans, records top-$K$ attended positions for each decoding step, computes a per-step hit ratio
$$
r_{t,\mathrm{hit}}^{(\ell,h)}=\frac{c_{t,\mathrm{word}}^{(\ell,h)}}{K},
$$
and averages it over ASR steps to obtain $S_{\mathrm{hit}}^{(\ell,h)}$ [2604.06694]. Total budget $B$ is then split proportionally across heads, or equivalently as a window-plus-baseline-plus-score decomposition.

Its second distinctive component is Spectral Score Smoothing (SSS), which treats per-head importance as a temporal signal, applies RFFT, chooses a cutoff by cumulative spectral energy, filters high frequencies, and mixes the smoothed and raw signals with coefficient $\alpha$. The stated rationale is to suppress high-frequency noise and recover smooth global trends in importance scores [2604.06694].

The reported evaluation spans five models—Qwen2.5-Omni-3B, Qwen2.5-Omni-7B, Qwen3-Omni-30B-A3B, Gemma-3n-E2B, and Gemma-3n-E4B—across ASR, speech translation, and audio question answering. The abstract states that at a $40\%$ compression ratio, AudioKV maintains near-full accuracy on Qwen3-Omni-30B with only a $0.45\%$ drop, while traditional methods suffer catastrophic degradation and repetition. The detailed results also report end-to-end slowdown under $5\%$ and KV-cache memory reduction up to $60$–$80\%$ on NVIDIA A100 [2604.06694].

Several limitations recur across the HeadKV family. First, importance estimation may be task-specific. AudioKV explicitly notes that scores derived from ASR may need recalibration for other downstream tasks such as audio question answering [2604.06694]. Second, independent head ranking may miss synergy, which is precisely the critique motivating CoKV’s Shapley-based allocation [2502.17501]. Third, the best compression axis may depend on the setting: token eviction and budget allocation dominate many HeadKV methods, whereas MatryoshkaKV and ReCalKV demonstrate that feature-dimension compression can also preserve performance under high compression [2410.14731], [2505.24357].

This suggests that HeadKV is best understood as a broader architectural principle: KV compression should follow the functional heterogeneity of attention heads rather than impose uniform retention rules. In language models that heterogeneity is expressed through retrieval and reasoning [2410.19258], semantic context [2508.02401], or cooperation among heads [2502.17501]; in visual models through locality, global structure, and scale dependence [2605.20600], [2605.14877]; and in audio-language models through semantic-acoustic grounding and temporal continuity [2604.06694].

Source: https://www.emergentmind.com/topics/headkv