From Fixed Additions to On-Demand Retrieval: Rethinking Residual Connections

    Residual connections have been a default component of deep networks for a decade, enabling stable training of hundred-layer models and appearing in nearly every Transformer block. As model parameter counts grow, however, the design assumptions behind this component are being re-examined. This article explains how standard residuals accumulate information, introduces an exploratory alternative based on learnable retrieval, and outlines the metrics you should measure before adopting such a change in production.

    Residual connections have been in use for a decade. They made it possible to train networks with hundreds of layers stably, and they appear in virtually every Transformer block. As model parameter counts keep growing, the design assumptions behind this default component are coming under scrutiny. This article first explains how standard residuals accumulate information, then introduces an exploratory alternative, and finally lists the metrics that matter when putting such a design into practice.

    1. How Standard Residuals Accumulate Information

    The residual connection takes the form y = x + F(x). In a Pre-Norm Transformer, both the attention sublayer and the feed-forward sublayer operate on the same backbone (the residual stream) in this way.

    1. # Pseudocode, for illustrating the data flow only
    2. def transformer_block(x): # x: [batch, seq, d_model]
    3. x = x + attention(layer_norm(x)) # output shape is still [batch, seq, d_model]
    4. x = x + feed_forward(layer_norm(x))
    5. return x

    The residual stream does not merely hold the previous layer’s output. Each sublayer’s increment is added onto x, so the stream at layer L can be written as x_L = x_0 + Σ F_l(·), where the sum runs over all preceding sublayers. Earlier information is preserved through accumulation, but there is no mechanism deciding which part of it later layers should read. This accumulation pattern raises three problems:

    1. Representation dilution: Features learned by early layers get overshadowed by later increments in the layer-by-layer additions. Deep layers struggle to precisely retrieve the original information from shallow layers.
    2. Continuously growing scale: The norm of the residual stream typically increases with depth. Pre-Norm normalizes the sublayer inputs, but the stream itself is never normalized, so its numerical range keeps expanding. Under low-precision training, this amplifies quantization error.
    3. No read/write division of labor: All layers share a single channel, and the model has no explicit mechanism for deciding which layers write and which layers read.

    2. An Exploratory Idea: Retrieving from Historical Outputs

    Existing research has explored turning the residual connection from a “fixed addition” into a “learnable retrieval.” The core idea: instead of reading only the current value of the residual stream, each sublayer performs a weighted aggregation over the outputs of all previous layers, with weights determined by attention scores.

    There are several ways to implement this. The pseudocode below shows one of the simpler forms. Each layer has a learnable query vector that scores the historical outputs, and the outputs are then aggregated by these scores. The query vector is a per-layer learned parameter, not derived from the current layer’s output.

    1. # Pseudocode; shape annotations are for illustration and may not run as-is
    2. # history: a list of tensors with shape [batch, seq, d_model],
    3. # containing the embedding output and all previous block outputs
    4. # w_query: shape [d_model], the learnable query vector for layer l
    5. def attention_residual_block(history, w_query):
    6. H = stack(history) # [l, batch, seq, d_model]
    7. keys = rms_norm(H) # normalize before use as keys, so no single layer's scale dominates the scoring
    8. logits = einsum("d,lbsd->lbs", w_query, keys) / sqrt(d_model)
    9. alpha = softmax(logits, dim=0) # normalize along the history-layer dimension l
    10. mixed = einsum("lbs,lbsd->bsd", alpha, H) # weighted aggregation, shape [batch, seq, d_model]
    11. out = mixed + attention(layer_norm(mixed)) # sublayers still receive normalized inputs
    12. out = out + feed_forward(layer_norm(out))
    13. return out # the caller appends out to history

    Compared with the standard residual, this formulation changes three things:

    • Addressable information: Each layer can directly retrieve the output of any preceding layer with a learned weight, without relying on layer-by-layer propagation.
    • Potential read/write division of labor: The query vectors and sublayer parameters are learned during training, so the model may develop a division of labor across layers. Whether a clear division actually emerges must be verified by inspecting the distribution of attention weights.
    • Constrained aggregation coefficients: The softmax guarantees non-negative coefficients summing to 1, so mixed is a convex combination of historical outputs. The stream will not grow monotonically through direct addition. This does not guarantee numerical stability, though—real measurements are still required.

    Note that designs of this kind are still in the research exploration stage. This article does not cite experimental numbers from a unified benchmark. If you intend to adopt a specific scheme, read the original paper or code first and reproduce the results on your own data.

    3. Under What Conditions Should the Benefits Be Verified?

    The value of an architecture change ultimately comes down to how much capability you get per unit of compute. The following are conditional, potential benefits—not established conclusions.

    • Parameter efficiency: At a fixed parameter budget, improved parameter efficiency can only be claimed if the same validation loss is reached with fewer parameters or fewer training steps.
    • Convergence behavior: Compare loss curves across different learning rates, and check whether oscillations and final loss are actually better.
    • Downstream performance: Evaluate on downstream tasks related to the pretraining objective, not just the training loss.
    • Engineering compatibility: Changes of this kind can usually still be implemented within the standard Transformer computation graph, and strategies such as tensor parallelism and pipeline parallelism can be reused. However, retaining and aggregating historical outputs changes the memory layout of activations and the communication volume, so new stress testing is required.

    Recommended measurement methodology: fix the data and evaluation sets, use at least three random seeds, and report mean and standard deviation. When computing equivalent compute, record FLOPs, peak memory, and per-step wall-clock time together. A single-run result cannot distinguish genuine gains from random variance.

    4. Engineering Trade-offs and an Adoption Checklist

    The table below compares the standard residual with the attention-based residual from the example above.

    Dimension Standard Residual Attention Residual (example above)
    Information access Only through layer-by-layer accumulation Directly reads any historical layer by learned weight
    Extra memory Essentially zero Historical outputs must be stored; grows with depth and sequence length
    Compute overhead One addition per layer Per-layer cost grows linearly with history length; total cost across the model grows quadratically with depth
    Numerical behavior Stream norm grows with depth Aggregation is a convex combination, so the stream does not inflate directly, but real testing is still needed
    Implementation difficulty Low Requires managing the history cache, parallel sharding, and gradient flow

    When adopting this approach, work through the following checklist:

    1. Memory estimation: The history cache is roughly depth × batch × seq × d_model × bytes per element. For example, with 32 layers, batch size 8, sequence length 4096, d_model 4096, and bf16 (2 bytes per element), the historical outputs alone occupy about 8.6 GB. Backpropagation also requires storing intermediate activations, so actual usage will be higher.
    2. Retention strategy: Keep only the most recent k layers plus a few anchor layers, or apply a low-rank projection to the history before storing it, to reduce memory.
    3. Sparse retrieval: Limit each layer’s retrieval window, or group historical layers so that the number of candidates per retrieval stays fixed, keeping compute growth under control.
    4. Learning rate and warmup: For a new architecture, start with half the baseline learning rate in the early phase, paired with sufficient warmup. Watch whether the loss in the first few thousand steps tracks the baseline.
    5. Output projection initialization: (to be continued in the original source)