Why does a deep transformer stack stop training if you remove the residual connections?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A 32-layer transformer trains fine with residual connections. A teammate removes them as a 'simplification'. Explain what specifically breaks during training and why.
Without residuals, the gradient through 32 stacked sublayers is a product of 64 Jacobians; that product vanishes or explodes long before it reaches the early layers.
Think about telling a message down a line of 64 people, where each person is allowed to change the message a little before passing it on. After 64 retellings, the original message is unrecognizable. Now imagine each person is also given a copy of the ORIGINAL message and is only asked to write a small correction next to it. After 64 people, you still have the original plus a stack of small corrections. That second setup is what a residual connection does. During training, the model has to send a correction signal BACK through the line so each person can learn how to do better next time. Without the original-message copy (the residual), that signal gets garbled and the people at the front of the line never hear what they did wrong. With residuals, the signal travels straight back to them.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: chain rule gives a product of 64 Jacobians + product vanishes or explodes + residuals make each Jacobian `I + J` + product behavior switches from exponential to linear + ResNet origin + pre-norm versus post-norm + empirical training collapse without residuals.
| Aspect | Without residuals | With residuals |
|---|---|---|
| Effective Jacobian per layer | `J_i` (arbitrary spectrum) | `I + J_i` (anchored near identity) |
| Gradient norm at depth 32 | Exponential in depth (vanish or explode) | Linear in depth |
| Max trainable depth | ~10-15 layers | 80+ layers in practice |
| Sensitivity to initialization | Extreme; needs orthogonal init + LR warmup | Robust; standard init works |
| What the early layers learn | Stays near random init | Fits the task normally |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Calling this 'just' a vanishing-gradient issue. The exploding-gradient case is equally real, and it is the geometric mean of the Jacobian singular values that controls which direction it fails in.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.