Deep Residual Networks: Rethinking Residual Connections with Depth Attention
This article examines a new architectural approach that applies attention mechanisms to the depth dimension of large language models, replacing standard element-wise residual addition. It explains the analogy between time and depth, diagnoses how pre-normalization causes residual dilution in deep networks, and outlines the core design of learnable depth-wise retrieval with gating and memory optimizations. The article also offers practical advice on ablation testing, training stability metrics, and inference cost evaluation for teams exploring this direction.
1. Introduction: The Overlooked “Law of Physics”
Over the past few years, the industry has re-engineered nearly every fundamental component of the standard Transformer architecture to improve the feature extraction and generation capabilities of large models. In sequence modeling, multi-head attention has been continuously compressed and optimized, evolving from multi-query to grouped-query attention, and even to linear-complexity variants. In feature transformation, feed-forward networks have been replaced by sparse Mixture-of-Experts structures. In positional awareness, Rotary Position Embedding has become the mainstream. In normalization, Root Mean Square Normalization has gradually replaced traditional Layer Normalization.
However, one component has barely been challenged in nearly a decade: the residual connection. Since deep convolutional networks introduced “identity mapping” into deep structures, adding the previous layer’s output directly to the current layer’s output has been treated as the default rule for stabilizing gradients in deep networks. Recently, a research team proposed a new architectural idea regarding the depth dimension, sparking widespread discussion, including from well-known industry entrepreneurs. Their core argument is sharp: the fixed, element-wise additive residual is becoming a bottleneck for further improving the expressive power of deep networks.
2. Core Insight: The Duality of Time and Depth
To understand this breakthrough, we first need to establish an analogy: the duality of time and depth.
Looking back at the evolution of sequence modeling, the fundamental flaw of Recurrent Neural Networks is that they try to compress all historical information into a hidden state of fixed dimension. As sequences grow longer, early information is repeatedly overwritten, making long-range dependencies hard to maintain. The victory of attention is essentially replacing “stateless compression” with “retrieval on demand”: the representation at the current position can directly and selectively access any historical position in the sequence, rather than being forced through a fixed-capacity bottleneck.
Switching to the depth dimension, standard residual connections do something strikingly similar. The input to layer L of the network is an indiscriminate sum of all previous layers’ outputs. Every layer, regardless of its contribution size or relevance, stuffs its result into the same ever-expanding hidden state. The deeper the network, the more irrelevant information accumulates, and the genuinely useful shallow features are diluted.
The resulting inference is this: since “fixed compression” in the time dimension has been solved by attention, “fixed addition” in the depth dimension deserves a similar reconstruction. The depth direction also needs a mechanism that lets each layer retrieve the historical layer information it truly needs on demand, rather than passively accepting the full accumulated sum. This is the soul of the new architecture’s design philosophy.
3. Problem Diagnosis: Information Dilution Under Pre-Normalization
To understand the necessity of this redesign, we need to see the pathological mechanism of the current mainstream architecture. Most large models today use a pre-normalization design: normalize the input first, then pass it into the attention and feed-forward sublayers, and finally perform residual addition. This design is training-stable, but it introduces a long-underestimated side effect: residual dilution.
Consider a 64-layer network. The output of layer 1 accounts for only about 1/64 of the total accumulated amount in the input to the final layer 64. Even if a layer contributes critical syntactic or factual information, its magnitude is drowned out by the outputs of the subsequent dozens of layers. The following pseudocode illustrates this dilution effect:
# Standard residual: all layers contribute with equal weighth = embedding(x)for layer in layers: # N layers in totalh = h + layer(norm(h)) # layer i contributes roughly 1/N
As depth N increases, the marginal impact of any single layer approaches zero. This leads to two consequences: first, fine-grained features learned in shallow layers struggle to propagate effectively to the top layers; second, deep layers must amplify their output magnitudes to “make their voices heard,” which exacerbates instability in early training and forces engineering reliance on learning rate warmup and gradient clipping as compensation.
4. The Solution: Giving the Depth Dimension Retrieval Capability
Addressing the above problems, the core modification of the new architecture can be summarized as: replacing indiscriminate addition with learnable depth-wise attention. The design has three key aspects.
First, maintain a key-value collection along the depth direction. Project the outputs of historical layers into keys and values and cache them. The current layer no longer directly inherits the accumulated sum; instead, like processing a sequence, it computes relevance weights over historical layer representations and aggregates its own input through weighted summation.
Second, introduce gating and learnable scaling. To prevent the retrieval mechanism from introducing noise in early training, a learnable scalar or per-channel gate is typically configured for the aggregation result, allowing the model to adaptively decide “how much to retrieve and how much to retain,” balancing stability and expressiveness.
Third, control computational and memory overhead. A naive implementation requires caching all historical layer representations, which is costly. In practice, compromise solutions such as grouped retrieval, local windows, low-rank projection, or opening retrieval to only some layers can be used to balance expressive power and engineering feasibility. The logic can be illustrated as follows:
# Depth attention: retrieve historical layers on demand, not full additioncache_k, cache_v = [], []for layer in layers:q = proj_q(norm(h))k, v = proj_k(h), proj_v(h)cache_k.append(k); cache_v.append(v)attn = softmax(q @ stack(cache_k).T / scale)h = h + gate * (attn @ stack(cache_v))
5. Engineering Implementation and Evaluation Recommendations
For teams looking to validate this kind of idea, a progressive path is recommended. First, conduct ablation experiments on small-to-medium scale models, comparing three configurations: fixed residual, top-layer-only retrieval, and full-layer retrieval, observing changes in perplexity and downstream task metrics. Second, monitor training stability metrics, including gradient norm distribution and variance of per-layer output magnitudes, to confirm whether the dilution problem is alleviated. Finally, evaluate inference cost: depth-wise caching grows memory usage linearly, requiring a combined trade-off with batching strategies and memory optimization techniques.
At the infrastructure level, such experiments place high demands on elastic compute, distributed training frameworks, logging services, and monitoring/alerting capabilities. Using mature container platforms and object storage to manage checkpoints and datasets can significantly reduce reproduction and iteration costs. If using general compute and data management capabilities provided by Baidu AI Cloud, teams can focus their energy on the structural innovation itself rather than environment maintenance.
6. Conclusion
Residual connections stabilized deep networks, but at the cost of information dilution in exchange for training convenience. Migrating the attention idea from the time dimension to the depth dimension is essentially a dimensional elevation of the modeling perspective: moving from “unconditionally inheriting all history” to “selectively retrieving key history.” This idea reminds us that parts of a structure treated as default settings are often precisely the innovation space most worth re-examining.
