Where the normalisation sits
- : the sublayer, either attention or the feed-forward block.
- : layer normalisation.
The original transformer normalised after adding the residual. Every model since about 2019 normalises before the sublayer instead.
The difference is one line and it decides whether a deep transformer trains at all.
Why the residual path must stay clean
Under pre-norm the residual stream runs from the input to the output with nothing applied to it, so every block writes into a shared, unmodified channel.
The gradient therefore reaches layer zero through a path that multiplies by the identity, whatever the depth.
Post-norm puts a normalisation on that path at every layer, so the gradient is rescaled times and the product can shrink geometrically again.
What that changes in practice
Post-norm transformers need a careful learning rate warmup, and without it the loss diverges in the first few hundred steps.
Pre-norm trains with a short warmup or none, tolerates a larger learning rate, and scales past a hundred layers where post-norm stalls near twenty.
The cost is that the residual stream grows as blocks keep adding to it, so activations at the last layer are much larger than at the first.
That is why a pre-norm stack ends with one final normalisation before the output projection. Without it the logits inherit the accumulated scale.
One block, in order
- Normalise the incoming residual stream.
- Run attention on the normalised copy.
- Add the result back into the unnormalised stream.
- Normalise again, run the feed-forward block, and add that back.
- After the last block, normalise once more before the language modelling head.
The refinements on top
RMSNorm drops the mean subtraction and keeps only the rescaling, which is cheaper and works as well, so most current models use it in place of layer norm.
Some large models scale each residual branch by a small factor at initialisation, so the stack begins close to the identity and the blocks learn to contribute gradually.
Post-norm has not disappeared entirely. It produces slightly better final quality when it can be trained, which is why a few models use hybrid schemes that normalise in both places.