← All questions
LLM FoundationsMedium· Transformer Architecture· Normalization· Training Stability

Where does the LayerNorm go in a modern transformer blo...

In modern transformer architectures, LayerNorm is placed before the sub-block, a configuration known as pre-norm. This approach is preferred because it maintains the residual stream as a clean gradient highway. By ensuring the gradient does not have to pass through the normalization layer at every step, it avoids the instability issues associated with post-norm architectures, effectively removing the requirement for complex warmup schedules during training.

Code playground (Python)