Subscribe
AI
6 min read

What Is a Residual Connection? The Addition That Let Neural Networks Get Deep

Residual connections add a layer's input back to its output, enabling the training of extremely deep networks like those in GPT and Claude by simplifying gradient flow.

Diagram showing a residual connection where input x is added to layer output F(x) to produce y = F(x) + x in a neural network
Diagram showing a residual connection where input x is added to layer output F(x) to produce y = F(x) + x in a neural network

A residual connection is a direct pathway that adds an earlier layer's input x directly to the output of a later block, computing y = F(x) + x. Popularized by ResNet in 2015, it allows deep networks with hundreds of layers to train reliably by ensuring gradients have a clear path for backpropagation.

Every modern large language model is built on a trick that fits in one line of algebra. Take what a layer computed, and add back what went in. That is a residual connection, and without it the deep networks behind GPT, Claude, Gemini and Llama would not train at all. This explainer covers what the trick is, where it came from, and why researchers are still modifying it a decade later.

The problem: more layers made networks worse

The conventional story says deep networks failed because of vanishing gradients, and normalization plus better initialization fixed that. By 2015 those fixes worked, and a stranger problem took their place. Kaiming He, Xiangyu Zhang, Shaoqing Ren and Jian Sun reported it in Deep Residual Learning for Image Recognition (CVPR 2016): a 56-layer plain network trained on CIFAR-10 had higher training error than a 20-layer plain network. The deeper model could not even fit its own training data. That rules out overfitting. It is an optimization failure. The authors noted the contradiction directly: a 56-layer network could at minimum copy the 20-layer solution and initialize its 36 extra layers as no-ops, so it should never be worse. In practice, solvers could not find that solution. Making a stack of nonlinear layers behave like an identity mapping turned out to be hard.

The fix: stop asking layers to start from scratch

The ResNet reformulation changes what each block is asked to learn. If the desired mapping is H(x), the block instead learns F(x) = H(x) - x and outputs:

y = F(x) + x

The block now only has to learn the correction to its input. If doing nothing is the right answer, the block drives F(x) toward zero, which is easy: zero weights produce zero output. The shortcut that carries x forward is a plain addition. As the paper puts it, identity shortcuts "add neither extra parameter nor computational complexity." No gates, no memory, nothing to tune.

He's team tested the hypothesis by inspecting trained models and found learned residual functions generally have small responses, meaning blocks really do operate as small edits on top of what they received. A follow-up paper, Identity Mappings in Deep Residual Networks (2016), showed that with identity skips and activation after the addition, forward and backward signals can travel from one block to any other without vanishing. That let them train a 1001-layer ResNet on CIFAR-10 to 4.62% error. The original 152-layer ResNet won the ILSVRC 2015 classification task with 3.57% top-5 error, eight times deeper than the VGG networks it beat.

One important footnote: the idea was not entirely new. Highway Networks by Srivastava, Greff and Schmidhuber appeared months earlier and did the same job with learned gates that mix a transform branch and a carry branch. The ResNet paper acknowledged it as concurrent work. The difference mattered: highway gates have parameters and can close, while the identity shortcut always passes information through and never costs anything. ResNets also demonstrated gains at depths in the hundreds, which highway networks had not.

What transformers inherited

Diagram of a residual block: input splits into a transform path and a bypass path, rejoining at an addition node

When the Transformer paper arrived in 2017, it adopted the pattern wholesale: each sublayer (attention, then feed-forward network) is wrapped as LayerNorm(x + Sublayer(x)). Every LLM architecture since has kept it. A model with 60+ layers runs the input through more than a hundred of these add-backs.

Mechanistic interpretability turned the same line into a mental model. In Anthropic's Mathematical Framework for Transformer Circuits (Elhage et al., 2021), the running value x is called the residual stream, and it behaves like a shared workspace: every layer reads from it and writes to it, and once information is added it persists in its subspace unless another layer actively deletes it. The authors describe residual stream dimensions as something like memory or bandwidth for the model's circuits. Under this view, layers do not transform the input into a new representation; they annotate a running document.

The addition that stayed still for ten years, and then did not

Residual connections changed less than anything else in LLM architecture. That stability hid a flaw the Kimi team named in its March 2026 paper Attention Residuals: PreNorm residuals accumulate every layer's output with fixed weight 1, so the hidden state grows with depth and each new layer's contribution gets diluted. Their analysis shows the hidden-state norm climbing from 1.0 to 3.45 over just six layers under standard residuals. AttnRes replaces the fixed sum with a learned softmax attention over preceding layer outputs, so each layer chooses which earlier layers to read from, keeping magnitudes bounded. The cheaper Block AttnRes variant groups layers and attends over block summaries. On a 48B-parameter Kimi Linear mixture-of-experts model trained on 1.4T tokens, the team reported GPQA-Diamond up 7.5 points, math up 3.6 and HumanEval up 3.1, with under 2% inference latency overhead.

Two earlier works pointed the same direction. Value Residual Learning (ResFormer) argues hidden-state residuals fail to carry initial token information to deep layers and adds a second residual, this one on attention value vectors from the first layer; the authors report matching baseline validation loss with 16.11% fewer parameters and 20.3% less training data. LayerSkip (Meta, 2024) goes the other way, training models so shallow layers can exit early and the rest can be skipped at inference, reaching up to 2.16x speedups. If a model can run with layers missing, the fixed chain of add-backs was never the only option.

Abstract flow illustration: one straight bold line with side branches rejoining it at intervals

Why it matters practically

Three consequences worth keeping in mind:

  • It explains why depth is cheap to attempt and expensive to question. Residual connections make adding layers trainable, but they also make each layer a small edit, which is exactly why researchers can prune, skip or reweight layers without the model collapsing.
  • It shaped how we debug models. The residual stream framing is the reason interpretability work talks about features being "written" and "read" by different layers rather than information flowing through a pipeline of transformations.
  • It is currently being rewritten. The weight-1 addition survived a decade; softmax-learned and value-level variants are now published with scaling-law and large-model evidence. Expect the default block to keep changing.

The short version: a residual connection is an addition. The layer computes a correction, and the network adds it back to the input. That single choice is what made 100-layer networks trainable, became the backbone of every Transformer, and is now the last unmodified piece of 2015-era deep learning under active revision.

Sources

Frequently asked questions

How do residual connections help train deep neural networks?

They allow blocks to learn only the difference (residual) from their input rather than starting from scratch. If no change is needed, weights can drive toward zero, making identity mapping easy and preventing degradation in deeper models.

Why are residual connections important in Transformer architectures?

Transformers use LayerNorm(x + Sublayer(x)) to wrap attention and feed-forward sublayers. This pattern creates a 'residual stream' that acts as a shared workspace, allowing information to persist across many layers without vanishing.

What is the difference between ResNet and Highway Networks residuals?

Highway Networks use learned gates to mix transform and carry branches, adding parameters and computational cost. ResNet uses plain identity shortcuts that add neither extra parameters nor complexity, making them more efficient for very deep networks.

What are Attention Residuals in modern LLMs?

Attention Residuals replace the fixed weight-1 addition of standard residuals with learned softmax attention over preceding layer outputs. This keeps hidden-state magnitudes bounded and has been shown to improve performance on models like Kimi.

AILLMEducation