Large language model (LLM) inference is increasingly bottlenecked by the Key-Value (KV) cache, yet the fine-grained structure of attention-head activations remains poorly understood. We show that pretrained Transformers exhibit a pervasive inter-head linear structure: for a given token, the Query, Key, and Value (QKV) vectors of an attention head can often be reconstructed as a linear combination of a small number of peer heads, typically within the same layer. Across Llama-3.1-8B, Falcon3-10B, OLMo-2-7B, and Qwen3-32B, just 2-5 reference heads recover many target heads with high fidelity (e.g., mean R^2 approx 0.76 for Keys on C4 with five references, and frequently R^2 > 0.85 on GSM8K). This predictability is learned rather than architectural: it is largely absent at random initialization, rises rapidly during pretraining as we track through OLMo-2 checkpoints, and is supported by a theoretical lower bound showing high mean-squared error for linear prediction at initialization. We further connect this emergence to increasing intra-layer alignment of Key projection subspaces. Finally, we exploit this redundancy for efficiency by caching only reference-head KV states and reconstructing the remaining heads on the fly via lightweight linear maps, achieving 2x KV-cache reduction with model-dependent accuracy trade-offs (4.5-5.5 percentage point average drop on Falcon3-10B and Qwen3-32B across five benchmarks, and larger drops on Llama-3.1-8B), and we find that reconstructing Keys is substantially less harmful than reconstructing Values.
Figures & tables
Figure 1: Linear predictability among attention heads enables significant KV-cache compression. (Left) Schematic of approximating a target head’s (orange) Key activations using a learned linear projection from reference heads (green). (Middle) In a pretrained Llama-3.1 8B model, most heads’ Key activations are highly predictable (high R2 ) from a few peers on the C4 dataset ( Raffel et al., 2023 ) , indicating a shared low-rank subspace. (Right) This predictability allows for substantial KV-cache compressionwith minimal performance degradation on benchmarks like TruthfulQA, MMLU-STEM, and Winogrande. The dashed line marks 2 × compression.
Figure 2: Linearity is pervasive—keys, queries, and values all become more predictable as the number of reference heads grows. Shown is the mean R2 when reconstructing key , query , and value activations on a shared 150-sequence slice of C4 for three pretrained models: (Left) LLaMA-3.1 8B (Middle) Falcon-3 10B (Right) OLMo-2 7B. Across all panels, every stream (K, Q, V) shows a monotonic rise in R2 as additional references are added, confirming that head-level representations in each model occupy a low-rank sub-space that can be captured with only a handful of heads.
Figure 3: Dominant predictors migrate from cross-layer to within-layer . For OLMo-2 7B we track, across checkpoints, where a head’s strongest linear predictors reside. (Left): percentage of heads whose single best ( R2 -max) predictor lies in the same layer versus a different layer. (Right): the same percentages after aggregating each head’s five best predictors. At initialization almost all dominant links are inter-layer; by 50 k–100 k steps intra-layer links overtake and remain prevalent, indicating that pre-training progressively concentrates shared computation inside individual layers.
Figure 5: Pipeline for KV-cache compression via head-level redundancy. (1) We log key/value activations on a calibration set. (2) Pair-wise linear probes quantify how well one head predicts another. (3) A thresholded graph selects a minimal reference set that covers all targets. (4) Compact weight matrices Wr→t are trained for those links. (5) During inference, we cache only the reference heads and reconstruct the others on-the-fly, shrinking memory with minimal extra compute.
Figure 5
Model
Method
TruthfulQA
HellaSwag
MMLU Stem
GPQA
Winogrande
Average
Qwen3 32B
Baseline
39.16
82.70
82.39
40.62
73.16
63.61
50% KV Pred
40.02
77.02
74.21
31.91
67.24
58.08
Falcon3 10B
Baseline
37.05
80.95
68.47
34.82
71.19
58.50
50% KV Pred
35.00
74.23
61.90
27.67
71.42
54.04
Llama3.1 8B
Baseline
37.08
79.28
58.70
29.68
73.87
55.72
50% KV Pred
30.35
66.53
44.53
26.34
61.40
45.83
Table 1: Evaluation accuracy (%) across multiple benchmarks with and without 50% KV prediction.
Evaluation Domain
Task/Metric
Calibration Domain
Baseline
Maths
Coding
Psychology
(GSM8K)
(Humaneval)
(MMLU Psyc)
MATH
GSM8k
75.35
71.03
67.77
62.31
Math Intermediate Algebra
10.74
6.97
7.41
7.64
Math Prealgebra
41.90
36.28
32.60
34.32
Math Precalculus
11.42
6.59
6.77
7.14
Table 2: Model performance across different tasks for 50% key and value predictions on Llama3.1 8b instruct
Compression setting
Avg. accuracy
Drop vs. baseline
Baseline (no compression)
36.77%
—
Key-only (50% of keys predicted)
34.80%
− 1.97 pp
Value-only (50% of values predicted)
32.47%
− 4.30 pp
Joint K+V (50% of each predicted)
30.04%
− 6.73 pp
Table 3: Average accuracy on the GSM8k under three compression settings (50% of heads reconstructed in each case). Keys are substantially more resilient to linear approximation than Values, consistent with the asymmetric subspace overlap growth observed during pretraining (§ 3 ).
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
Evaluation Domain
Task/Metric
Calibration Domain
Baseline
Maths
Coding
Psychology
(GSM8K)
(Humaneval)
(MMLU Psyc)
MATH
GSM8k
75.35
74.60
74.60
74.22
Math Intermediate Algebra
10.74
9.85
11.18
9.30
Math Prealgebra
41.90
40.64
40.18
39.83
Math Precalculus
11.42
9.70
10.99
10.07
Appendix
Table 4: Model performance across different tasks for 50% key predictions on Llama3.1 8b instruct
Evaluation Domain
Task/Metric
Calibration Domain
Baseline
Maths
Coding
Psychology
(GSM8K)
(Humaneval)
(MMLU Psyc)
MATH
Gsm8k
75.35
72.78
69.21
68.61
Math Intermediate Algebra
10.74
9.41
9.30
8.41
Math Prealgebra
41.90
40.64
34.90
42.13
Math Precalculus
11.42
8.24
7.69
7.87
Appendix
Table 5: Model performance across different tasks for 50% value predictions on Llama3.1 8b instruct
Window
Proximity
% Conn.
Mean R2
2-layer
Near ( ≤2 )
53.6% ↑
0.2946 ↑
Far ( ≥3 )
46.40% ↓
0.2550 ↓
4-layer
Near ( ≤4 )
53.59% ↑
0.2895 ↑
Far ( ≥5 )
46.41% ↓
0.2506 ↓
Appendix
Table 6: Local vs. distant dominant linear connections. Boldface and arrows highlight the higher density and strength of near-layer links.
Figure 6: GSM8k – Distribution of linear predictability ( R2 ) for LLaMA-3.1 8B. Top row: cumulative distribution functions (CDFs); bottom row: kernel-density estimates (KDEs). Ordering (left→right): Key, Query, Value.
Figure 7: Olmo 2 7B – Distribution of linear predictability ( R2 ) on its pre-training corpus. Top row: cumulative distribution functions (CDFs). Bottom row: kernel-density estimates (KDEs). Left→right in each row: Key, Query, Value.
Figure 8: Heatmap of head-level linear predictability across transformer layers of Llama3.1 8B on C4. Each row corresponds to one attention head and each column to a model layer; the color intensity encodes the coefficient of determination R2 when reconstructing that head’s activations from its strongest reference heads. The gradient from warm to cool colors illustrates that linear redundancy is highest in early layers and gradually diminishes in deeper layers for Llama3.1 8B. Left key states, right value states.
Long-context LLM inference is bottlenecked by quadratic attention computation and growing KV-cache costs. Existing sparse attention and KV-compression methods typically decide which tokens or heads to preserve from runtime attention scores, observation windows, calibration prompts, or learned gates, making head diagnosis input-dependent and costly to deploy. We propose Autonomy-of-Heads (AoH), a data-free method that identifies retrieval and streaming heads from the spectral geometry of query-key projections. AoH defines the kernel attention operator Mh=WKh⊤WQh and uses its effective-rank as a weight-space measure of head function: concentrated spectra indicate a small number of dominant query-key matching directions and are associated with retrieval heads, whereas diffuse spectra indicate the absence of a dominant global matching direction and are associated with streaming heads. We further derive an efficient dhead-dimensional computation that avoids constructing the full dmodel×dmodel matrix. We conducted extensive experiments across models demonstrating that at 50% sparsity, AoH retains 96.5% of Full Attention performance on average while reducing prefill and decode latency by up to 41.4% and 66.0%, respectively, and KV-cache memory by 50.0% at 256K tokens.
Yehan Yang, Junyuan Shang, Yang Li +3
Institute of Computing Technology, Chinese Academy of Sciences · University of Chinese Academy of Sciences · Baidu Inc. +1
Due to the nature of quadratic attention, Large Language Models (LLMs) consume a lot of memory and energy: every new token costs more than the previous one, and its keys and values must be stored in memory indefinitely, which is unsustainable. Two main lines of work address this: compressing the KV cache, e.g., by evicting or quantizing keys and values, and retrofitting LLMs to use Linear Attention, which replaces the KV cache with a fixed-size state. Retrofitting has attracted a lot of attention, given its promise to solve the quadratic scaling problem with state-of-the-art performance at low cost. However, it has not been properly compared to the simplest form of KV-cache eviction: Sliding Window Attention (SWA) with attention sinks. In this work, we show that SWA with sinks performs as well or better than most retrofitted Linear Attention models across multiple LLMs and downstream tasks, with the largest gains on long-context and generative tasks. On long-context reasoning tasks (Needle-in-a-Haystack and BABILong), SWA achieves massively higher performance (2 to 10 times higher than linear attention). SWA requires no additional training, is extremely fast, and requires little memory, making it an extremely cheap and reliable solution. When the training budget is limited, switching to SWA is a much more effective way to reduce inference memory cost than retrofitting linear attention. Linear attention models have shown promise, but they require training from scratch or extensive retrofitting to reap their architectural benefits and come close to SWA.
Long-context inference in large language models is bottlenecked by Key--Value (KV) cache loading during the decoding stage, where the sequential nature of generation requires repeatedly transferring the KV cache from off-chip High-Bandwidth Memory (HBM) to on-chip Static Random-Access Memory (SRAM) at each step. While Multi-Head Latent Attention (MLA) significantly reduces the total KV cache size, it suffers from a sharding bottleneck during distributed decoding via Tensor Parallelism (TP). Since its single latent head cannot be partitioned, each device is forced to redundantly load the complete KV cache for every token, consuming excessive memory traffic and diminishing TP benefits like weight sharding. In this work, we propose Multi-Head Low-Rank Attention (MLRA), which enables partitionable latent states for efficient 4-way TP decoding. Extensive experiments show that MLRA achieves state-of-the-art perplexity and downstream task performance, while also delivering a 2.8× decoding speedup over MLA. Code is available at https://github.com/SongtaoLiu0823/MLRA. Pretrained weights, along with the training and evaluation data, are available at https://huggingface.co/Soughing/MLRA.
Songtao Liu, Hongwu Peng, Zhiwei Zhang +2
The Pennsylvania State University · University of Connecticut · Carnegie Mellon University +1