Deep transformers recompute nearly the same attention patterns layer after layer. Attention is the per-layer table saying how much each token looks at every other token. Many papers exploit this repetition after training by copying one layer's attention table into the next and patching the difference. These methods share a weakness. The repetition they exploit is an accident of training, not a property anyone asked for. As a result, copying works in some layers, fails badly in others (especially early ones), and needs hand-picked sharing spans plus extra training to repair the damage.
We propose to ask for the repetition directly. During pretraining we add a low-rank penalty on the stack of all attention tables across depth: the model pays a cost whenever a layer's attention cannot be written as a mix of attention patterns computed earlier in the network. After training, a simple selection procedure keeps only the few "anchor" heads that carry new patterns. Every other head reuses a learned mix of earlier anchors' tables, so its query-key products and softmax are never computed. The bet is that a soft penalty lets the data decide which layers may share and which must stay independent. Under that bet, a regularized model converted this way should lose less accuracy at a given attention compute budget than a normally trained model compressed by the best post-hoc sharing method. The penalty may also act as the noise filter that low-rank constraints are known to provide.
Core Claim
Cross-layer attention redundancy should be treated as a trainable, low-rank property of the whole network, not a fixed fact to be mined after the fact. Concretely, write $M \in \mathbb{R}^{LH \times m}$ for the matrix whose rows are the flattened, unit-normalized attention probabilities of every head in every layer. Here $L$ is depth, $H$ is heads per layer, and each row is restricted to a random sample of query positions giving $m$ entries. We penalize the share of $M$'s energy outside its top $r$ singular directions:
$$ \mathcal{R}_r(M) = \frac{\sum_{i>r} \sigma_i(M)^2}{\sum_i \sigma_i(M)^2}, $$
where $\sigma_i(M)$ is the $i$-th largest singular value. Training minimizes the language-modeling loss plus $\lambda \mathcal{R}_r(M)$. The penalty touches only the tail of the spectrum, which reflects the low-pass-filter view of low-rank regularization: dominant directions carry shared structure, and the tail carries layer-specific noise. It is cheap to compute. The $LH \times LH$ Gram matrix $MM^\top$ (144×144 for a 12×12 model) is formed from inner products of sampled attention rows and eigendecomposed, so the cost does not grow with sequence length beyond the sampled queries.
At conversion time, pivoted column selection is run in layer order. It greedily picks anchor heads such that every remaining head is well approximated by a mix of anchors at the same or earlier depth. Each non-anchor head's attention becomes a fixed learned combination of those anchor tables, with no query-key computation of its own. A short fine-tuning phase then fits the mixing weights.
Relation to Prior Work
Several papers supply the evidence that motivates this work. On Attention Redundancy: A Comprehensive Study builds a head-by-head redundancy matrix for BERT. It finds that redundancy appears even on gibberish input and is driven partly by post-attention dropout, a hint that much redundancy is a training artifact rather than something the task needs. Beyond KV Caching: Shared Attention for Efficient LLMs reports that middle-to-late attention becomes uniform across depth only after long pretraining. Revisiting Over-smoothing in BERT from the Perspective of Graph shows that the last 8 of 12 BERT layers can share one attention table. Both treat that structure as given; we shape it.
A second group supplies the sharing methods we compete with. Sharing Attention Weights for Fast Transformer shares attention tables across adjacent decoder layers using a divergence-based policy. Cross-layer Attention Sharing for Large Language Models (LiSA) is the closest existing work. After training, it shares attention across middle layers, uses tiny networks to re-align permuted heads, adds unconstrained low-rank query and key corrections, and keeps a fixed periodic schedule while leaving the first and last layers unshared. Our proposal differs in three ways. Low rank is a training-time regularizer on the attention tables themselves, not a post-hoc correction on weights. Head permutation stops being a separate problem, because any head may draw on any anchor through its mixing weights. And the sharing topology falls out of the learned spectrum rather than a fixed period.
A third group constrains the design. LoRC finds that compressing the first eighth of layers can cost up to 68% of performance, and LiSA calls shallow layers similarly fragile. This rules out any uniform rule that forces early layers to share. Our penalty is global and soft, and the layer-ordered anchor selection lets early layers become anchors themselves. Bian et al. find that early BERT heads are highly prunable, which seems to contradict LoRC. We treat that tension as something our learned anchor map can measure directly.
The remaining papers are related but take different approaches. xKV finds that the dominant singular directions of key-value caches align across layers and factors them jointly after training. That is the same low-rank-across-depth intuition applied post hoc to caches, where we apply it during training to attention tables. CR-Net and CrossSpectra show that differences between adjacent layers, or fine-tuning updates stacked over depth, are low-rank or low-frequency. Both operate on weights or activations and save nothing in the attention computation itself. Share Your Attention (MASA) builds every layer's projection weights from a shared dictionary of matrices. It shares weights, not input-dependent attention tables, so every layer still computes its own query-key products.
Research Program
The first stage is diagnostic and needs no new training. For public small and mid-size checkpoints, we compute the cross-layer attention spectrum of $M$ on held-out text and on random tokens. We measure how much energy lies beyond rank $r$ as $r$ varies, and which layers end up as anchors under ordered selection. This establishes the baseline compressibility that post-hoc methods inherit, and it gives a direct reading on the shallow-layer dispute.
The second stage trains decoder models from scratch at roughly 125M and 1B parameters on C4. For each size we use the same data, tokens, and optimizer settings, and sweep the penalty weight $\lambda$ and target rank $r$. We also study when the penalty is switched on, whether from the start or only in the final portion of training, because the Shared Attention paper suggests redundancy emerges late. Because only the tail is penalized, we expect perplexity of the unconverted model to be flat or slightly better at modest $\lambda$; a clear perplexity loss before any conversion would argue against the premise.
The third stage converts each model at several anchor budgets, for example 25%, 50%, and 75% of heads kept, and fine-tunes the mixing weights on a fixed small token budget. This produces accuracy-versus-attention-compute curves.
The fourth stage tests transfer to an existing large model. We apply the penalty during a short continued-pretraining run on LLaMA3-8B. Its token count matches the 4.2B uptraining tokens LiSA uses on RedPajama, so the comparison against LiSA is fair in data spent.
Baselines
The naive reference point is the same architecture trained identically without the penalty, then converted with the identical anchor-selection and mixing procedure. This is also the key ablation. Any gap between it and our model at equal anchor budget is attributable to the regularizer alone, since conversion, fine-tuning tokens, and evaluation are held fixed. Beating it means a consistently higher curve at every anchor budget, not just one.
The strongest existing competitor is LiSA (Cross-layer Attention Sharing for Large Language Models), because it is the only method that combines cross-layer attention sharing with low-rank correction and head alignment. On LLaMA3-8B it reports preserving 96.77% of original performance across 13 benchmarks, with a 6x compression of query and key projections. We will run LiSA's recipe on the unregularized model with the same uptraining tokens we spend on regularized continued pretraining plus conversion, matching its attention compute reduction. Beating it means retaining more than 96.77% of the base model's performance on the same benchmark suite at equal or lower attention compute. For our from-scratch scale, there is no reported LiSA result found on Lacuna, so we run it ourselves.
The hard-sharing baseline trains from scratch with attention copied over fixed layer spans. This follows Shi et al. (Revisiting Over-smoothing in BERT from the Perspective of Graph), who report a 44% FLOP reduction with almost no GLUE loss by sharing the last 8 layers, and SAN, which reports under 0.1 BLEU loss at 1.3x speedup. It is run with the same tokens and with spans chosen to match each anchor budget. It tests whether a soft, learned topology beats a fixed one.
A weight-space baseline is MASA trained from scratch at matched attention parameter count. It reports a 66.7% cut in attention parameters within 1% of original accuracy on a 729M model. We compare on both parameters and attention FLOPs, since MASA saves the former but not the latter.
Why not just…?
Why not just turn up weight decay? Weight decay induces low-rank attention layers reports that weight decay pushes attention weights toward low rank, but unsteadily and without aligning subspaces across layers. Low rank within each layer does not make layer 10's attention reusable from layer 6. We include a weight-decay sweep converted with the same procedure. If it matches our curves, the penalty adds nothing and we will say so.
Why not just train with hard sharing from the start? Fixed spans are cheaper and need no penalty. However, LoRC and LiSA both show that forcing early layers to share is catastrophic, so any fixed span must be tuned by hand per model. The hard-sharing baseline above settles this directly. If it matches our method once its spans are tuned with the same search budget we give $\lambda$ and $r$, the soft approach is unjustified.
Why not just apply LiSA-style repair after normal training? This is the real threat, because post-hoc alignment plus low-rank correction may already recover most of what regularization would have bought. The decisive test is the 8B comparison at matched tokens. We spend a fixed token budget either on LiSA uptraining or on regularized continued pretraining plus conversion. If LiSA wins or ties, the contribution shrinks to a diagnostic tool for choosing sharing layers.
Why not just share key-value caches across layers instead? MLKV and xKV cut cache memory, but every layer still computes its own query-key products and softmax. They address a different bottleneck, decoding memory rather than attention compute, so the two are complementary. We report both cache size and attention FLOPs so readers can see which one each method reduces.
Proposed Experiments
For from-scratch models, we report validation perplexity on C4 and WikiText-2, the datasets used by CR-Net and MASA. We also report zero-shot accuracy on ARC-easy, LAMBADA, PIQA, and SciQ, the suite MLKV uses, where MLKV-6 reaches 49.06% average against 49.43% for multi-query attention with 12 key-value heads. Results are given as curves over anchor budgets, measured in attention FLOPs and wall-clock prefill time.
For the 8B model, we use the commonsense and reasoning benchmarks in LiSA's 13-benchmark suite, including GSM8K. GSM8K matters because Shared Attention reports a drop from 0.1395 to 0.1243 when sharing final layers of Llama2-7B, which makes it the sensitive probe for reasoning. Each from-scratch configuration is trained with three seeds so that the gap over the naive baseline can be compared against seed variance.
Three checks decide the outcome. First, the regularized model, converted, must beat the unregularized model converted identically at every anchor budget by more than seed variance. Second, the regularized model before conversion must not lose perplexity. Third, the learned anchor map should keep early layers as anchors without being told to, which would show the penalty rediscovering the shallow-layer sensitivity on its own. On the 8B model, retaining more than LiSA's 96.77% at matched tokens and compute is the result that would justify the approach. Failing it while passing the from-scratch checks would mean the idea pays off only when applied from the start of training.
References
- On Attention Redundancy: A Comprehensive Study
- Beyond KV caching: Shared attention for efficient LLMs
- Revisiting Over-smoothing in BERT from the Perspective of Graph
- Sharing Attention Weights for Fast Transformer
- Cross-layer Attention Sharing for Large Language Models
- LoRC: Low-Rank Compression for LLMs KV Cache with a Progressive Compression Strategy
- xKV: Cross-Layer KV-Cache Compression via Aligned Singular Vector Extraction
- CR-Net: Scaling Parameter-Efficient Training with Cross-Layer Low-Rank Structure
- CrossSpectra: Exploiting Cross-Layer Smoothness for Parameter-Efficient Fine-Tuning
- Share Your Attention: Transformer Weight Sharing via Matrix-based Dictionary Learning
- Weight decay induces low-rank attention layers