Pre-Norm and Post-Norm Change Computation Order
Pre-norm applies normalization before a residual branch; post-norm applies it after branch addition. Calculate both on the same input and record the exact convention before comparing architectures.
The location of normalization changes the function calculated by a residual branch. For a branch , pre-norm uses
whereas post-norm uses
The same words—normalization, branch, residual addition—can therefore describe two different computation graphs.
Calculate Both Orders
Take , let , and use LayerNorm with unit gain, zero bias, and epsilon omitted for this hand calculation. Then .
Pre-norm gives
Post-norm first gives and then normalizes it:
The outputs differ even though , , and are unchanged.
A Complete Block Has Two Placements
This subject implements the pre-norm block
The original Transformer used post-norm residual sublayers. Later work studied why pre-norm variants often behave differently at initialization and during optimization. These results are useful evidence about specific assumptions; they do not establish one placement as universally best.
State the Convention Before Comparing Models
A reproducible architecture description should name:
- pre-norm or post-norm placement;
- LayerNorm, RMSNorm, or another operation;
- whether gain and bias are learned;
- epsilon and the axis being normalized;
- where dropout is applied relative to the branch and addition.
Without these details, two implementations called “the same Transformer block” may calculate different functions.
Q1. Identify a pre-norm branch
Which expression is pre-norm: or ?
Answer it first, then check.
Hint
Solution
References
- Ashish Vaswani et al., Attention Is All You Need, 2017.
- Ruibin Xiong et al., On Layer Normalization in the Transformer Architecture, 2020.