Attention Residuals in Deep Models: Rethinking Inter-Layer Information Passing

    Modern large models have rapidly evolved through various attention mechanisms, feed-forward networks, and normalization techniques. Yet, the residual structures connecting these layers have remained largely unchanged. While traditional residual connections offer simple computation and stable training, their equal-weight accumulation of historical layer outputs leads to information dilution as networks grow deeper. This article explores "attention residuals," an architectural concept that applies dynamic retrieval across the depth dimension. We will examine the limitations of standard residuals, the mechanics of depth-wise attention, its potential benefits, and the key engineering challenges involved in its implementation.

    In modern large models, attention mechanisms, feed-forward networks, sparse experts, positional encodings, and normalization methods have undergone multiple rounds of evolution. However, the residual structure connecting different network layers has long maintained a relatively stable form.

    A traditional residual connection is typically expressed as:

    [
    hl=h{l-1}+Fl(\operatorname{Norm}(h{l-1}))
    ]

    Here, (h_l) represents the hidden state of the (l)-th layer, and (F_l) represents the current layer’s transformation module, which may consist of attention sublayers, feed-forward sublayers, or other structures. Its advantages are clear: simple computation, short gradient paths, stable training, and the ability to directly pass shallow information to deeper layers.

    However, as network depth continues to increase, this “direct addition” approach exposes a noteworthy issue: the outputs of all historical layers are continuously accumulated and implicitly assigned the same fusion weight. In other words, the model does not actively judge which layers’ information remains important and which has become outdated; it simply retains them all within the same state.

    This is the exact problem that “attention residuals” attempt to solve.

    1. The Core Assumptions of Traditional Residuals

    Assuming an initial input (h_0), after passing through a multi-layer network, the traditional residual structure can be expanded as:

    [
    hL=h_0+\sum{l=1}^{L}Fl(\operatorname{Norm}(h{l-1}))
    ]

    This expression shows that the final state is essentially the result of accumulating the initial representation and the increments from all intermediate layers.

    This design implies two assumptions:

    First, the information generated by all layers is worth long-term retention.
    Second, the current layer does not need to re-select historical information based on the task state.

    In shallower networks, these two assumptions rarely cause severe issues because the number of accumulated terms is limited, and the new information added by the current layer can still account for a significant proportion of the overall representation. But as depth increases, historical information grows, and the magnitude and complexity of the hidden state may also continuously rise.

    This can be likened to constantly appending content to the end of a document: without indexing, summarization, or filtering mechanisms, the document may store more information, but retrieving the most useful content becomes increasingly difficult.

    2. What is Pre-Norm Dilution?

    Many deep networks currently use a Pre-Norm structure, which normalizes the input before feeding it into the current transformation module:

    [
    hl=h{l-1}+Fl(\operatorname{Norm}(h{l-1}))
    ]

    Normalization controls the input distribution entering the sublayer, making training more stable, but it does not alter the structure of the residual accumulation itself. As the number of layers increases, (h_{l-1}) contains more and more historical components, and the new information generated by the current layer makes up only a small fraction of the overall state.

    This can be termed “Pre-Norm dilution”—the dilution of newly added information in pre-normalization architectures.

    It is important to note that this does not necessarily mean traditional residuals will lead to numerical divergence. Normalization, initialization strategies, scaling factors, and optimizers can all suppress magnitude growth. What truly deserves attention is the information contribution ratio: even if the overall numerical value remains stable, critical information just extracted by a certain layer may become less prominent after being superimposed with a large amount of historical representation.

    Therefore, the problem is not just that the “vector grows larger,” but rather “whether the current layer can still effectively control the final representation.”

    3. Analogy Between the Time and Depth Dimensions

    To understand attention residuals, we can first observe the evolution of sequence modeling.

    Early recurrent structures maintained a fixed-size hidden state across the time dimension. For each new input processed, the model compressed new information into the state. Due to limited state capacity, long-distance information was easily overwritten or compressed, and the model struggled to flexibly access content from long ago.

    The attention mechanism changed this. It no longer required all historical information to be compressed into a single fixed state. Instead, it allowed the current query to select relevant content from historical representations on demand:

    [
    \operatorname{Attention}(Q,K,V)
    =\operatorname{Softmax}\left(\frac{QK^\top}{\sqrt{d}}\right)V
    ]

    The key here is not just “weighted averaging,” but dynamic retrieval. Different positions and different task states can select different historical information.

    If we view network depth as another sequence dimension, the intermediate representations generated by each layer are analogous to historical states in a time series. Traditional residuals perform fixed accumulation in the depth direction, while attention residuals aim to allow the current layer to dynamically access representations from previous layers.

    This forms a heuristic analogy:

    • Time dimension: Shifting from fixed states to on-demand retrieval;
    • Depth dimension: Shifting from fixed residual accumulation to on-demand fusion.

    4. The Basic Form of Attention Residuals

    A straightforward design is to generate a query vector for the current layer and compute weights against the representations of historical layers.

    Assuming the representations of previous layers are retained:

    [
    H{<l}=[h_0,h_1,\ldots,h{l-1}]
    ]

    The current layer generates a query based on its existing state:

    [
    ql=W_q\operatorname{Norm}(h{l-1})
    ]

    The historical representations generate keys and values:

    [
    k_i=W_k\operatorname{Norm}(h_i), \qquad
    v_i=W_v h_i
    ]

    Next, the attention weights across the depth dimension are computed:

    [
    \alpha_{l,i}
    =
    \operatorname{Softmax}_i
    \left(
    \frac{q_l k_i^\top}{\sqrt{d}}
    \right)
    ]

    This yields a selected historical summary:

    [
    rl=\sum{i<l}\alpha_{l,i}v_i
    ]

    Instead of simply using (h_{l-1}) as the sole residual source, the current layer feeds the dynamic aggregation result into subsequent modules:

    [
    h_l=r_l+F_l(\operatorname{Norm}(r_l))
    ]

    Specific implementations can vary. For instance, the attention result can act as the residual branch, or it can be gated and fused with the current state:

    [
    \tilde hl=g_l\odot r_l+(1-g_l)\odot h{l-1}
    ]

    Here, (g_l) is dynamically generated by the current state. This allows the model to use the re-retrieved historical information while retaining the local updates from the most recent layer.

    5. How Does it Differ from Standard Inter-Layer Attention?

    Attention residuals are not simply adding another sequence attention module to the network. The two address different problems.

    Standard attention typically operates along the sequence length dimension, solving “which input positions should the current position focus on.” Attention residuals operate along the network depth dimension, solving “which historical layer representations should the current layer inherit.”

    Consequently, their tensor organizations differ:

    • Sequence attention: Establishes relationships between tokens or positions;
    • Depth attention: Establishes relationships between different network layers.

    Functionally, the former is more like content retrieval, while the latter is more like computational trajectory selection. The current layer can lean toward shallow lexical information, intermediate structural information, or deep semantic information, without defaulting to all layers contributing equally to the final state.

    6. Potential Benefits

    1. Reducing Historical Information Dilution

    In traditional residuals, information from earlier layers continuously participates in accumulation. Dynamic weights allow the model to reduce the influence of low-value historical representations, increasing the proportion of layers relevant to the current task.

    2. Improving Deep Network Controllability

    As layer count increases, the network doesn’t just continuously stack transformations; it can reorganize existing representations. This helps mitigate the issue where, at extreme depths, “new computations struggle to alter the overall state.”

    3. Establishing Hierarchical Information Routing

    Different layers often assume different functions. Shallow layers may capture local patterns, middle layers prefer composite structures, and deep layers focus on global semantics. Attention residuals provide an explicit hierarchical routing mechanism, enabling the model to select the appropriate computational stage results based on its current state.

    4. Providing More Flexible Gradient Paths

    In fixed residuals, gradients propagate along the layer-by-layer accumulation path. Dynamic residuals allow gradients to provide differentiated feedback to different historical layers, theoretically helping the optimization process identify more valuable intermediate representations.

    7. Key Issues in Engineering Implementation

    While conceptually clear, deploying attention residuals requires handling several engineering challenges.

    1. Computational Complexity

    If every layer computes attention against all historical layers, the number of depth-wise interactions may grow quadratically. For networks with dozens or even hundreds of layers, this incurs additional computation and memory overhead.

    Common optimization directions include:

    • Attending only to the most recent several layers;
    • Grouping or segmenting historical layers for summarization;
    • Using low-rank projections to compress keys and values;
    • Periodically establishing hierarchical summaries instead of accessing all history layer by layer;
    • Applying caching and incremental updates to attention weights.

    2. Memory Footprint

    Traditional residuals only need to save the current state, whereas depth attention requires access to historical representations. If every layer saves a complete high-dimensional tensor, memory pressure increases significantly.

    One can consider saving compressed representations, low-precision copies, or only retaining summaries used to generate keys and values. Note that over-compression may lose original layer information, so a trade-off between precision and resources is necessary.

    3. Training Stability

    Dynamic weights introduce new normalization and routing processes. If the attention distribution is too sharp, the model might rely on only a few layers long-term; if too uniform, it degrades back into standard accumulation.

    Therefore, practical designs may require temperature coefficients, weight scaling, gating initialization, or regularization techniques to keep the model smooth during early training and gradually learn to select.

    4. Causal Constraints

    In autoregressive generation scenarios, the current layer can only access computed historical layers and cannot use results from future layers. Depth-wise attention must adhere to this constraint; otherwise, it causes inconsistency between training and inference logic.

    8. A Simplified Pseudocode Illustration

    Below is a structured illustration independent of specific frameworks:

    1. history = [hidden]
    2. for layer in layers:
    3. query = make_query(history[-1])
    4. keys = [make_key(x) for x in history]
    5. values = [make_value(x) for x in history]
    6. scores = dot_product(query, keys)
    7. weights = softmax(scores)
    8. residual = weighted_sum(weights, values)
    9. hidden = residual + layer(norm(residual))
    10. history.append(hidden)

    Actual systems usually do not directly save all complete historical states. Instead, they adopt window, summarization, or grouping mechanisms. For example, a compressed state can be generated every few layers, and the current layer only computes attention against these summaries, thereby keeping extra overhead within acceptable limits.

    9. Boundaries and Risks That Cannot Be Ignored

    Attention residuals are not a complete negation of traditional residuals.

    Traditional residuals are widely adopted because they are structurally simple, numerically stable, hardware-friendly, and have clear gradient pathways. While dynamic routing increases expressive power, it also brings more parameters, more memory access, and a more complex debugging process.

    Moreover, theoretical information selection capabilities do not necessarily translate into actual task gains. The model might learn to depend on a few layers, causing uneven layer utilization; or the extra attention modules might alter the optimization path, making training more sensitive. Therefore, evaluation should not only look at training loss but also observe:

    • The frequency with which different layers are accessed;
    • The entropy and concentration of attention weights;
    • Differences between long-context and short-context tasks;
    • Inference latency and memory changes;
    • Whether performance continues to improve as depth increases;
    • The degree of performance degradation when dynamic residuals are removed.

    Only when model quality, training stability, and inference costs are reasonably balanced does this architectural modification hold practical significance.

    10. How to View This Direction

    From a more abstract perspective, attention residuals reflect a trend in large model architecture: models need to establish dynamic relationships not only between input data but also between their own computational processes.

    Past networks typically treated layers as a fixed pipeline: Layer 1 processes and passes to Layer 2, Layer 2 to Layer 3, and so on. Attention residuals further propose that whether the current layer should entirely inherit the previous layer’s results, or whether it should look back at earlier stages, should also be determined by data and task state.

    This does not mean fixed residuals are about to disappear. A more realistic direction may be a hybrid approach: retaining stable, low-cost base residuals while adding lightweight depth selection mechanisms, allowing the model to strike a balance between stability and flexibility.

    If this line of thinking continues to develop, future deep models may no longer just “stack more layers” but will be able to learn how to organize these layers, select historical computation results, and dynamically adjust information flow based on context. For architecture designers, what is truly worth noting is not the name of a specific implementation, but a more universal question:

    As network depth continuously increases, does the model possess a sufficiently effective mechanism to manage and retrieve its own historically generated representations?

    Attention residuals provide a representative answer and open up new research space for information flow design in deep networks.