Rethinking Residual Accumulation in Deep Networks: From Fixed Addition to Attention-Based Retrieval

    This article examines a long-overlooked component of modern large language models: the residual connection. While attention, feed-forward layers, positional encoding, and normalization have all been redesigned, the default practice of adding each layer's output with a fixed weight of one remains largely unchanged. The article explains how this design causes activation magnitude growth and information dilution in very deep networks, draws a duality between time and depth to motivate an attention-style residual mechanism, and outlines an illustrative implementation along with practical engineering considerations such as memory overhead, retrieval scope, inference cost, and compatibility with existing components.

    1. Introduction: The Overlooked Component

    Over the past few years, architectural innovation in large models has touched nearly every major module. Attention has been reshaped into multi-query or grouped-query forms, with linear attention variants also emerging. Feed-forward networks have been replaced by sparse mixture-of-experts structures. Positional encoding has largely converged on rotary schemes. Normalization layers are repeatedly weighed against one another, layer normalization versus root mean square normalization. Yet the residual connection that ties these modules together has stayed essentially the same.

    Since residual networks became widely adopted, “add the previous layer’s output directly to the current layer” has been treated as an unquestioned default. A recent architectural exploration by a research team drew attention precisely because it challenged this default: residual accumulation with fixed weights and unconditional addition may be weakening the effective expressive capacity of deep models. This article does not discuss any specific product; it focuses solely on this general technical question.

    2. What the Standard Residual Mechanism Actually Does

    Mainstream modern large models generally adopt a “normalize first, then compute” structure. A single layer can be abstracted as:

    1. # Standard PreNorm with unit-weight residual accumulation
    2. h = h + attn(norm(h))
    3. h = h + ffn(norm(h))

    The key feature of this code is that the weight of each new branch is always 1, and historical information is preserved intact in h. Unrolling L layers shows that the current hidden state equals the initial embedding plus a simple sum of all layer branch outputs.

    This design works very well in shallow networks. It ensures gradients can flow back along the identity path, alleviating the optimization difficulty of deep networks. But as the layer count grows from a few dozen to a hundred or more, problems begin to appear.

    3. Magnitude Growth and Information Dilution

    Because every layer performs addition, the magnitude of the hidden state grows roughly linearly with depth. The amount of new information introduced by a single layer does not grow at the same rate, so the proportion of newly added signal within the total keeps shrinking. This is the so-called “normalize-first dilution” effect.

    It leads to three direct consequences:

    • Lower effective signal-to-noise ratio: The relative contribution of deep branch outputs becomes smaller and can be drowned out by the accumulated history during optimization.
    • Heavier normalization burden: Continuously rising magnitude forces the normalization layer to take on stronger scaling duties, making numerical stability more sensitive to implementation details.
    • Rigid division of labor across layers: All historical layers are compressed into the same vector, so the current layer cannot choose “which layer to reference” on demand and can only passively accept the entire history.

    4. The Duality of Time and Depth

    The core idea of this work can be summarized as a duality. Along the time dimension, recurrent structures compress all history into a fixed-size state vector, while attention replaces this compression with on-demand retrieval. Along the depth dimension, compressing all preceding layers into a single ever-growing hidden state is likewise worth reforming through “retrieval.”

    Put differently, the depth direction also needs a query-key-value mechanism: the current layer actively issues a query, matches it against the outputs of historical layers, and then aggregates them with weights, rather than summing unconditionally. This is the basic motivation behind attention-based residuals.

    5. A Practical Implementation Approach

    The following is illustrative code, provided only to explain the mechanism and not representing any specific implementation:

    1. # Attention-based residual: the current layer performs weighted aggregation over historical layer outputs
    2. history = [h0] # store each layer's output
    3. for layer in layers:
    4. q = proj_q(norm(history[-1]))
    5. k = [proj_k(x) for x in history]
    6. v = history
    7. scores = [dot(q, ki) / scale for ki in k]
    8. weights = softmax(scores)
    9. h_new = sum(w * vi for w, vi in zip(weights, v))
    10. h = h_new + layer(norm(h_new))
    11. history.append(h)

    Three points need attention in implementation. First, the memory overhead of the history cache can be mitigated by limiting the number of retrievable layers or using segmented caching. Second, the extra parameters and computation from key-value projections require ablation studies on small models to confirm the benefit. Third, for numerical stability, it is advisable to retain the necessary scaling and normalization on the aggregation result.

    6. Engineering Practice Recommendations

    • Run small-scale ablations first: Verify whether the dilution effect exists on a baseline with fewer layers before deciding whether to introduce retrieval-based residuals.
    • Control the retrieval scope: Not all layers need global retrieval; a local window often captures most of the benefit.
    • Watch inference cost: Training-stage gains must be evaluated after deducting the caching and memory-access overhead in the inference stage.
    • Keep it decoupled from existing components: This modification acts on inter-layer connections and can be combined orthogonally with schemes such as grouped-query attention and sparse experts.

    7. Conclusion

    Migrating the attention idea from the time dimension to the depth dimension is a re-examination of a fundamental structure. It reminds practitioners that a default setting is not necessarily the optimal one, and the more widely a component is used and the less it is questioned, the more it deserves testing with quantifiable experiments. For teams seeking to improve the expressive capacity of deep models, a good starting point is to observe how the hidden state magnitude changes with depth, then evaluate whether retrieval-based residuals are worth introducing.