Attention Residuals: Reconstructing Information Aggregation Along the Depth Dimension of Large Models

    This article examines Attention Residuals, an architectural exploration that applies attention-style, content-based weighting to the depth dimension of Transformers rather than relying on the standard fixed-weight residual connection. It explains the core idea of time-depth duality, diagnoses the "PreNorm dilution" problem, shows how dynamic layer aggregation can address it, and discusses the engineering tradeoffs involved. It also clarifies how this approach relates to and complements existing attention, MoE, and normalization techniques—offering a fresh perspective on components that are usually treated as settled.

    1. The “Frozen” Building Block

    Over the past few years, almost every component of the Transformer has been refined again and again. Attention has evolved from full attention to multi-query and grouped-query attention, and then to linear attention. The feed-forward network has moved from dense FFNs to sparse mixture-of-experts (MoE). Positional encodings have given way to rotary position embeddings (RoPE). Even the normalization layer has been repeatedly weighed between LayerNorm and RMSNorm. Yet one thing has stayed nearly untouched: the residual connection, which simply adds the previous layer’s output to the current layer.

    For nearly a decade since residual structures appeared, the formula h_l = h_{l-1} + f_l(h_{l-1})—which indiscriminately adds the previous results together—has been treated as an unshakable axiom. But a recent architectural exploration puts forward a sharp claim: this fixed, undifferentiated accumulation may be holding back the expressive power of deep networks.

    2. Core Insight: The Duality of Time and Depth

    To understand this argument, it helps to recall how the Transformer defeated recurrent neural networks.

    The problem with recurrent networks was that they tried to compress all historical information into a single fixed-size hidden state, so long-range dependencies were overwritten and forgotten through repeated iteration. The essential breakthrough of attention was “retrieval on demand” along the time dimension—at every step, the model could look back directly at any historical position, rather than passively receiving a compressed summary.

    The core insight of this exploration is to move that same logic onto the depth dimension: a standard residual connection indiscriminately accumulates information from all preceding layers into a steadily growing hidden state. Since the time dimension was already revolutionized by attention, shouldn’t the “fixed residual” along the depth dimension undergo the same kind of revolution? This is the “time-depth duality”—using attention to reconstruct information aggregation along the depth direction.

    3. Diagnosing the Root Cause: The PreNorm Dilution Effect

    Modern large models almost universally adopt the PreNorm structure: normalize first, then pass through the sub-layer, then add the result back onto the main trunk. Unrolled across multiple layers, it can be written as:

    1. h_L = h_0 + Σ_{l=0}^{L-1} f_l(Norm(h_l))

    Here, each layer’s contribution is added to the trunk with a fixed weight of 1. As the number of layers L grows, the magnitude of the hidden state keeps accumulating and growing, yet the proportion that any single layer’s new information occupies within the total sum is continuously diluted. The researchers call this phenomenon “PreNorm dilution”: the useful signal each deep layer learns becomes increasingly hard to express clearly and exploit within the massive accumulated result.

    It causes problems on three levels:

    • Information level: single-layer outputs are diluted, making it hard for deep layers to highlight key features;
    • Magnitude level: the scale of the hidden state grows monotonically with depth, putting pressure on numerical stability for training and low-bit quantization;
    • Expressiveness level: all historical layers are treated equally with a one-size-fits-all weighting, so the model cannot selectively depend on certain layers based on its current needs.

    4. The Solution: From Fixed Summation to Dynamic Weighting

    Since equal-weight accumulation is the problem, the natural idea is this: rather than passively accumulating all layers, let the model actively choose which layers to attend to. Attention is exactly the mechanism that provides this content-based, weighted aggregation.

    Conceptually, we can keep the outputs of previous layers as a form of “depth memory.” The current layer issues a query and performs attention against this memory, dynamically computing the weight of each layer and then aggregating them with those weights—instead of simply adding them up. Illustrative code:

    1. import math
    2. # Standard PreNorm residual: accumulation with fixed unit weights
    3. def standard_block(x, layer):
    4. return x + layer(rmsnorm(x))
    5. # Attention residual: dynamically weighted aggregation over historical layer outputs
    6. def attention_residual_block(x, depth_memory, attn):
    7. q = rmsnorm(x) # current state serves as the query
    8. keys = values = depth_memory # historical layer outputs serve as keys and values
    9. scores = (q @ keys.T) / math.sqrt(q.shape[-1])
    10. weights = softmax(scores) # per-layer dynamic weights, replacing the fixed 1
    11. aggregated = weights @ values # aggregate by weight rather than direct addition
    12. return x + aggregated # keep the identity shortcut to preserve gradient flow

    Two key engineering details are worth emphasizing here:

    First, an identity shortcut must be preserved (x + ...). Much of why standard residuals are training-friendly comes from the stable gradient flow provided by this identity path. Removing it entirely would significantly increase the difficulty of optimization when stacking many layers. So in practice, the more robust approach is to “keep the identity path while adding attention-based aggregation on top,” rather than replacing it outright.

    Second, the cost must stay controlled. Maintaining the depth memory requires caching historical layer outputs, which increases memory usage and memory-access overhead. In engineering practice, this extra cost is typically kept within an acceptable range through grouped aggregation, limiting the look-back window, or using lightweight scoring (such as low-rank scoring or shared projections).

    5. Relationship to Existing Techniques

    It is worth clarifying that attention residuals are not meant to replace attention itself, nor are they a redesign of the MLP or MoE. They target a specific dimension: how information flows across layers along the depth direction. This approach is orthogonal to existing attention optimizations, sparse experts, and normalization schemes, and can theoretically be combined with them: attention handles token-to-token retrieval along the time dimension, while attention handles layer-to-layer aggregation along the depth dimension, with each doing its job within a dual structure.

    6. Engineering Tradeoffs

    • Numerical stability: dynamic weighting changes the distribution of hidden-state magnitudes, so normalization and initialization strategies need to be recalibrated;
    • Memory and throughput: caching and accessing the depth memory is the main extra cost and requires tradeoffs based on model scale;
    • Observability: the routing behavior introduced by attention weights adds to the cost of observing and debugging training dynamics;
    • Verifying gains: any architectural change should be guided by ablation experiments, with gains validated on large-scale, long-context real-world tasks rather than extrapolated from small-scale results.

    7. Summary

    The most valuable aspect of this exploration is not any particular formula, but that it offers a new lens for examining the Transformer: the components we take for granted are not necessarily optimal. The residual connection has been used for nearly a decade, but when it exposes a structural weakness of “equal-weight dilution” along the depth dimension, attentionizing it becomes a natural transfer of ideas. For developers working on model architecture and training optimization, this is a reminder: true innovation often hides inside those basic components that “everyone assumes are fine.”