Depth-Attention: Cross-Layer Value Mixing for Language Models

Boyi Zeng, Yiqin Hao, Zitong Wang, Shixiang Song, He Li, Feichen Song, Yifan Liu, Ziwei He, Xinbing Wang, Zhouhan LinarXiv 2026

TL;DR

Depth-Attention introduces an elegant, parameter-free mechanism that allows Transformer layers to selectively reuse information from earlier layers. By performing depth-wise attention inside the attention module and storing the mixed values directly in the existing KV cache, it significantly boosts LLM performance with virtually zero extra memory or computational overhead at inference.

What Problem Does This Paper Address?

Standard Transformers excel at mixing information across the sequence dimension via self-attention, but their information flow across depth (layer-to-layer) is rigid. Information is passed primarily through residual connections, which collapses the entire computational history into a single hidden state. Consequently, deeper layers cannot selectively retrieve representations from specific earlier layers.

While recent cross-layer architectures (like DenseFormer or Attention Residuals) attempt to fix this by storing and aggregating previous hidden states, they introduce massive memory overheads during inference—requiring gigabytes of extra storage on top of the already large Key-Value (KV) cache. This problem is exacerbated in modern LLMs that use techniques like Grouped-Query Attention (GQA) to shrink the KV cache, making hidden-state-based cross-layer overhead unacceptable.

Methods

The authors propose Depth-Attention, which moves cross-layer selection inside the attention module itself. Before a layer performs standard sequence-level self-attention, the current layer's query attends along the depth dimension over the keys of earlier layers at the same token position. It then computes a softmax-weighted sum to mix these historical values into an updated, depth-mixed value state ($\tilde{V}$).

This depth-mixed value then replaces the original value state in standard causal self-attention, while keeping the queries, keys, and causal mask completely unchanged. Crucially, because $\tilde{V}$ has the exact same shape as the original value state, it is stored in-place within the standard V-cache slot.

To keep the mechanism highly efficient, Depth-Attention uses a sparse depth source via stride (typically a stride of $s = L/2$, where $L$ is the total number of layers), meaning a layer only looks back at a small subset of previous layers. Furthermore, it integrates seamlessly with Grouped-Query Attention (GQA) by averaging queries within a group to match the key-value head resolution.

Overview of Depth-Attention architecture combining sequence-level and depth-level mixing.

Datasets

The models were pretrained from scratch for 32 billion tokens on The Pile, a diverse 800GB dataset for language modeling. Evaluation was conducted across eight standard downstream benchmarks: LAMBADA, PIQA, WinoGrande, SciQ, HellaSwag, ARC-Easy, ARC-Challenge, and RACE.

Key Insights and Ideas

  • Value-Level vs. Hidden-State Interaction: Interacting at the value-state level inside the attention block is structurally superior to hidden-state mixing because it reuses existing KV cache slots, avoiding any extra persistent inference state.
  • More is Not Better (The Power of Sparsity): Ablation studies revealed that a sparse lookback (stride $s = L/2$) actually achieved lower validation loss than a full lookback (stride 1) or quarter lookback. Overly dense source lists introduce redundancy and noise rather than helpful context.
  • Value-Only Dominance: Mixing keys or key-value pairs across depth actually degraded performance compared to mixing values alone. Preserving current-layer keys ensures temporal attention remains sharp.
  • Recurrent Depth Compatibility: Depth-Attention works not just for stacked layers but also for looped Transformers (where parameters are shared across recurrent steps), proving its generalizability.

Key Results

  • Performance Boost: On Qwen3-style decoders at 1.5B and 3B parameters, Depth-Attention achieved the lowest perplexity and highest average downstream accuracy, outperforming the vanilla Transformer by up to 2.3 accuracy points and beating strong baselines like DenseFormer and Attention Residuals.
  • Zero Extra Inference Memory: For a 128K context prefill, Depth-Attention requires 0 GiB of extra persistent memory, whereas DenseFormer requires 24.0 GiB and Attention Residuals requires 4.0 GiB.
  • Negligible Compute Overhead: It adds fewer than 0.01% extra arithmetic FLOPs ($2.42 \times 10^5$ FLOPs/token for a 3B model) and introduces only a +1.18% latency overhead during inference.
Scaling behavior showing Depth-Attention consistently shifting the validation-loss curve downward.
Downstream task performance comparison under five-shot evaluation settings.

Limitations and Future Work

  • Kernel Fusion: The current implementation is written in standard PyTorch without custom CUDA kernels, leading to a modest training wall-clock overhead (+9.1% to +11.2%). Fusing Depth-Attention into the main attention kernel would likely eliminate this gap.
  • Scale Constraints: The method has only been validated up to 3B parameters and 32B tokens due to academic resource limits; testing on 7B+ models and trillion-token datasets remains future work.
  • Heuristic Stride: The depth sources are currently selected using a fixed, heuristic stride. Exploring learned or dynamic source selection could yield further improvements.

Summary updated

BibTeX
@misc{zeng2026depth,
  author = {Boyi Zeng and Yiqin Hao and Zitong Wang and Shixiang Song and He Li and Feichen Song and Yifan Liu and Ziwei He and Xinbing Wang and Zhouhan Lin},
  title = {{Depth-Attention: Cross-Layer Value Mixing for Language Models}},
  year = {2026},
  eprint = {2606.05014},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.05014},
}
Figure