Skip to content

03 · C · Block

The pre-norm Transformer block

Residual highways, RMSNorm, and the two sublayers that every modern decoder stacks.

Pre-norm residual block

Modern decoder LLMs stack identical pre-norm blocks. Each block writes a residual delta into the stream, twice: once from attention, once from the MLP.

(3.1)
layer index, 1 … n
residual stream after layer ℓ, T×d
stream after the attention residual

Why it mattersResiduals are the highway that lets gradients travel through dozens of layers (He et al., 2016). The skip has Jacobian I, so there is always a path that does not vanish.

PRE-NORM BLOCKH⁽ℓ−1⁾RMSNormthen Attn+ → Zskip J = IRMSNormthen MLPH⁽ℓ⁾Two residual adds. Each skip contributes a Jacobian of I, which is why depth trains.

RMSNorm

RMSNorm scales a vector by its root-mean-square and a learned gain (Zhang and Sennrich, 2019). It does not subtract the mean and has no bias. Llama-style models use it.

(3.2)
one residual-stream vector
small constant, e.g. 10^{-6}
(3.3)
learned scale
elementwise multiply

Why it mattersNorms keep residual-stream scale stable so attention scores and MLP activations do not explode as depth grows.

LayerNorm

LayerNorm also subtracts the mean and usually has a bias. GPT-2 uses it. The extra projection orthogonal to is the only structural difference.

(3.4)
mean of u
variance of u
learned bias