Control activation scale without erasing the signal.

LayerNorm centers and rescales each token's features. RMSNorm rescales without subtracting the mean. Inject shifts and outliers, then compare the geometry, statistics, and residual behavior.

Open activation lab

Stable depth needs a reference scale.

Transformer residual streams repeatedly accumulate updates. Normalization makes each sublayer see a controlled activation magnitude, improving optimization across depth. The choice of centering, epsilon, learned gain, and placement affects what information survives.

Raw features · mean shift +1.5Drag to orbit · wheel to zoom
inputnormalizedoutlier
Output mean1.50

LayerNorm drives this toward zero; RMSNorm preserves shift.

Output RMS2.10

Root mean square after optional normalization and gain.

Peak magnitude5.20

Largest absolute feature after processing.

Residual cosine1.000

Directional similarity between input and output vectors.

LayerNorm centers and scales

Subtracting the feature mean makes the vector translation-invariant. Dividing by standard deviation gives unit variance before learned gain and bias restore useful scale and offset.

y = γ ⊙ (x − μ) / √(σ² + ε) + β

RMSNorm keeps the mean

RMSNorm removes the centering operation and normalizes only by root mean square. It is cheaper and preserves information carried as a common shift.

y = γ ⊙ x / √(mean(x²) + ε)

Placement shapes gradient flow

Pre-norm blocks normalize before attention or the MLP, leaving a direct residual path through depth. Post-norm blocks normalize after adding the sublayer output and can require more careful optimization.

pre-norm: xₗ₊₁ = xₗ + F(norm(xₗ))

Mean shifts

LayerNorm erases uniform offsets; RMSNorm retains their direction while controlling overall energy.

Choose based on what the residual stream encodes.

Outliers

A single large feature raises the denominator and compresses ordinary coordinates, even when global RMS is controlled.

Normalization is not clipping.

Tiny variance

Epsilon prevents division by nearly zero variance, but an oversized epsilon weakens scale normalization.

Numerical stability is part of the model.

Primary reading

Layer Normalization Ba et al.Root Mean Square Layer Normalization Zhang & SennrichOn Layer Normalization in the Transformer Architecture Xiong et al.DeepNet: Scaling Transformers to 1,000 Layers Wang et al.