Pre-norm versus post-norm: which placement makes deep stacks stable?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Pre-norm puts LayerNorm inside the residual branch so the residual path is never normalized. Gradients flow cleanly back, deep stacks train without warmup, and every modern decoder LLM uses it.
Imagine a long telephone game played across 80 people. Post-norm is like having each person whisper to the next but a referee retunes the volume after every pair speaks. The retuning makes early whispers fade away because every retune slightly attenuates what came before. Pre-norm is like setting the volume once before each person speaks but leaving the original whisper untouched in a backchannel. The backchannel carries the original message clean across all 80 people; the retuning only affects what each person says into the channel. The second setup lets messages survive long chains, which is exactly what gradients need to do in deep networks.
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.
Compare the formulas, explain the gradient-flow argument for pre-norm's residual identity path, walk the historical transition from Vaswani 2017 to GPT-2 to modern LLMs, address the variance-growth concern and the final-LayerNorm fix, and close with DeepNorm and RMSNorm as related variants.
| Property | Post-norm | Pre-norm |
|---|---|---|
| Formula | x_out = LN(x_in + f(x_in)) | x_out = x_in + f(LN(x_in)) |
| Residual path through LN? | Yes (every layer) | No (identity path) |
| Gradient stability at depth | Poor without warmup | Stable with standard init |
| Used by GPT-1, BERT, Vaswani 2017 | Yes | No |
| Used by GPT-2+, Llama, Mistral, modern LLMs | No | Yes |
| Needs final LN before LM head | No | Yes (variance grows) |
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.
Believing the original Vaswani layout (post-norm) is what modern LLMs use. GPT-2 already switched to pre-norm in 2019 and every frontier LLM since has followed.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.