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 FF, pre-norm uses

y=x+F(N(x)),y=x+F(N(x)),

whereas post-norm uses

y=N(x+F(x)).y=N(x+F(x)).

The same words—normalization, branch, residual addition—can therefore describe two different computation graphs.

Calculate Both Orders

Take x=[1,3]x=[1,3], let F(z)=0.5zF(z)=0.5z, and use LayerNorm with unit gain, zero bias, and epsilon omitted for this hand calculation. Then N(x)=[1,1]N(x)=[-1,1].

Pre-norm gives

x+F(N(x))=[1,3]+[0.5,0.5]=[0.5,3.5].x+F(N(x))=[1,3]+[-0.5,0.5]=[0.5,3.5].

Post-norm first gives x+F(x)=[1.5,4.5]x+F(x)=[1.5,4.5] and then normalizes it:

N([1.5,4.5])=[1,1].N([1.5,4.5])=[-1,1].

The outputs differ even though xx, FF, and NN are unchanged.

A Complete Block Has Two Placements

This subject implements the pre-norm block

u=x+Attention(N1(x)),y=u+MLP(N2(u)).u=x+\operatorname{Attention}(N_1(x)),\qquad y=u+\operatorname{MLP}(N_2(u)).

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: N(x+F(x))N(x+F(x)) or x+F(N(x))x+F(N(x))?

Answer it first, then check.

Hint
Ask whether normalization happens before the branch function.
Solution
x+F(N(x))x+F(N(x)) is pre-norm. The other expression is post-norm.
Not attempted
Review

Not marked done.

References

Pause and reflect

In your own words, note what you understood, what remains unclear, or what you want to revisit. The note stays with this lesson.

0 of 1 exercises marked done

Review

Not marked done.

LLM PrimerPre-Norm and Post-Norm Change Computation Orderhttps://llmprimer.com/transformers/inside-a-transformer-block/pre-norm-and-post-norm-change-computation-order© 2026 LLM Primer