The whole story in one plot. KV sharing keeps 21% of the KV cache. It wins clearly with AdamW on FineWeb, ties under a recipe built for deep models, and loses on Dolma 3.
The idea
Monea et al. share the KV cache across loops [1]
The Surprising Effectiveness of Shared Memory in Looped Transformers
G. Monea, K. Ramji, Y. El-Kurdi, L. Lastras, Y. Artzi, N. Godey, R. Astudillo, (2026)
arXiv:2610.02383
. In a 12-layer Transformer looped 5 times, the later loops read the first loop’s keys and values (layer $i \bmod 12$) next to a 64-token window of their own, and train to a lower loss than loops with a full cache each.
I tested the same trick without the loop. The model is a plain 60-layer, width-768 Transformer with separate weights. Layers 1–12 are ordinary full-attention layers and serve as the memory. Layer $12k + j$ reads layer $j$’s keys and values plus its own 64-token window, in one softmax.
KV sharing. Every deep layer $12k+j$ reads layer $j$’s keys and values and its own last 64 tokens.
The deep layers only cache their windows. At 4,096 tokens the cache is $(12 + 48 \times 64/4096)/60 \approx$ 21% of full attention’s.
Setup. 605M parameters (12 heads, SwiGLU 3,072, RoPE, pre-RMSNorm), FineWeb [2]
The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale
G. Penedo, H. Kydl\'i\vcek, L. allal, A. Lozhkov, M. Mitchell, C. Raffel, L. Werra, T. Wolf, (2024)
arXiv:2406.17557
with the GPT-2 tokenizer, 4,096-token sequences, 393K tokens per step, 5B and 20B tokens. AdamW with a WSD schedule; the peak learning rate is tuned separately for each model and budget.
It works under AdamW
AdamW on FineWeb. Left: loss gap to full attention. Right: zero-shot accuracy at 20B tokens.
KV sharing beats full attention with a fifth of the cache: −0.030 nats at 5B tokens, −0.039 at 20B, and all four zero-shot benchmarks go up. The gap grows with the budget.
What the gain needs
Ablations, AdamW, 20B tokens. Full attention is 0.
The memory. With windows only, the model is 0.012 worse than full attention and loses five points on LAMBADA (43.3 vs. 48.5).
The gradient through the memory. Same forward pass, but no gradient from the deep layers into layers 1–12 through the shared keys and values: the gain disappears (+0.004). The memory works mainly as a training path into the early layers, not just as extra information for the late ones.
The source of the memory. Standard cross-layer sharing [3]
Reducing Transformer Key-Value Cache Size with Cross-Layer Attention
W. Brandon, M. Mishra, A. Nrusimha, R. Panda, J. Kelly, (2024)
arXiv:2405.12981
, where four layers reuse the layer right below, saves the same cache and only matches full attention (−0.002). Reading from the first 12 layers is what helps.
The window, a little. Giving every deep layer its full own cache back lowers the loss by only 0.010, for 5× the cache and 2× the keys per deep layer. Dropping the window costs 0.023.
Why it works. In a pre-LN Transformer, deep layers barely change their input (the curse of depth), so their keys and values are redundant with the shallow ones. Sharing removes the redundancy, and the gradient through the shared cache shapes the shallow layers for their deep readers.
Fix the depth problem, and the gain shrinks
If KV sharing helps by fixing the curse of depth, a recipe that fixes it directly should take the gain away. I reran both models with a recipe built for deep models: NorMuon [4]
NorMuon: Making Muon more efficient and scalable
Z. Li, L. Liu, C. Liang, W. Chen, T. Zhao, (2025)
arXiv:2510.05491
, QK-norm, CompleteP-style depth-scaled residuals [5]
Don’t be lazy: CompleteP enables compute-efficient deep transformers
N. Dey, B. Zhang, L. Noci, M. Li, B. Bordelon, S. Bergsma, C. Pehlevan, B. Hanin, J. Hestness, (2025)
arXiv:2505.01618
, and zero-initialized output projections.
The two now tie: 2.804 for KV sharing vs. 2.809 for full attention at 20B tokens. KV sharing still wins 3 of 4 benchmarks (HellaSwag 47.3 vs. 46.1, ARC-Easy 51.9 vs. 51.2, PIQA 70.1 vs. 69.5, LAMBADA 45.0 vs. 45.9). A tie at 21% of the cache is still a cheap win; the free lunch is gone.
Change the data, and it loses
On Dolma 3 [6]
Olmo 3
Team Olmo, (2025)
arXiv:2512.13961
, KV sharing is 0.012 nats worse than full attention under the same recipe. FineWeb has little long-range dependency, so early-layer keys plus a 64-token window are enough. Dolma 3 is closer to real-world pretraining data and has much more long-range dependency, so deep layers need their own long-range keys.
Each dataset is evaluated on its own validation set. Only the gap within a dataset is meaningful, and the relative gap is the fairer measure.
Shape matters too. A large aspect ratio (width over depth) amplifies KV sharing’s weaknesses.
Lessons
Data is a first-class citizen. A KV-cache trick has to be tested on data that needs the cache.
There is no free lunch. With $\varnothing$ a plain baseline, $A$ a trick such as KV sharing, and $B$ a recipe that fixes the same problem directly, the usual ordering is
$$ \varnothing \ll A + \varnothing \le A + B + \varnothing \le B + \varnothing. $$Beating $\varnothing$ says little. Test against $B$.
Gaps of 0.01 are real at this scale. Seed-to-seed variance at 20B tokens is about 0.001 in validation loss, so −0.039 and +0.012 are well outside noise. A second seed for the key runs is the next check.
Open questions
- Is the loop what makes KV sharing work? Hidden states of different loops are similar, which leaves more room for sharing than separate weights do.
- Why does a smaller cache train better? Attention sinks [7]
Efficient Streaming Language Models with Attention Sinks
G. Xiao, Y. Tian, B. Chen, S. Han, M. Lewis, (2023)
arXiv:2309.17453 and the value-bank behavior of deep layers are the first suspects. - What do deep layers read from the early layers’ keys and values?
- Which abilities get worse with a fifth of the cache?
- Does it stack with attention residuals or hyper-connections?
References
- [2]The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale
G. Penedo, H. Kydl\'i\vcek, L. allal, A. Lozhkov, M. Mitchell, C. Raffel, L. Werra, T. Wolf, (2024)
arXiv:2406.17557 - [3]Reducing Transformer Key-Value Cache Size with Cross-Layer Attention
W. Brandon, M. Mishra, A. Nrusimha, R. Panda, J. Kelly, (2024)
arXiv:2405.12981 - [4]NorMuon: Making Muon more efficient and scalable
Z. Li, L. Liu, C. Liang, W. Chen, T. Zhao, (2025)
arXiv:2510.05491 - [5]Don’t be lazy: CompleteP enables compute-efficient deep transformers
N. Dey, B. Zhang, L. Noci, M. Li, B. Bordelon, S. Bergsma, C. Pehlevan, B. Hanin, J. Hestness, (2025)
arXiv:2505.01618 - [6]
- [7]Efficient Streaming Language Models with Attention Sinks
G. Xiao, Y. Tian, B. Chen, S. Han, M. Lewis, (2023)
arXiv:2309.17453
Cited as
Use the plain citation or copy the BibTeX entry below.
Benhao Huang. (Nov 2026). KV Sharing in Deep Transformers, and Why Data Is a First-Class Citizen. Husky's Log. https://huskydoge.github.io/husky-blog/posts/recursive_models/kv-sharing/
@article{huang2026kv,
title = "KV Sharing in Deep Transformers, and Why Data Is a First-Class Citizen",
author = "Benhao Huang",
journal = "Husky's Log",
year = "2026",
month = "Nov",
url = "https://huskydoge.github.io/husky-blog/posts/recursive_models/kv-sharing/"
}