RMSNorm › From LayerNorm to RMSNorm
Language AI HandbookAll chapters RMSNorm › From LayerNorm to RMSNormOne section · Sections in this chapter2 / 15 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
To appreciate what RMSNorm removes and why that removal works, we first need to understand what LayerNorm does and the distinct roles of its two operations. Normalization layers occupy a special position in the transformer architecture. They sit at the boundary between sub-layers, receiving activations that may have drifted to arbitrary scales during the computation just completed, and producing activations with a controlled distribution that the next sub-layer can work with reliably. Without normalization, deep networks become increasingly difficult to train as layers fight against each other's output distributions.
The standard transformer training story before normalization layers was challenging: different layers would settle into very different output scales, some producing values near zero and others producing large values, making it hard for gradient updates to flow uniformly through the network. Normalization layers solved this by enforcing a consistent statistical profile at key points in the computation. LayerNorm was the solution adopted for transformers precisely because it operated independently on each token's representation, without needing to aggregate statistics across the batch dimension.
The key insight motivating RMSNorm is that LayerNorm does two separate things, and those things serve different purposes. Once you see them as distinct operations, you can ask whether each one is necessary. Zhang and Sennrich asked that question and found that one of them could be dropped without hurting performance.
Decomposing LayerNorm: Two Operations, Two Purposes
When a vector of activations passes through a neural network layer, its values can drift to arbitrary scales. Some elements might be large and positive, others small and negative. This variability creates problems: gradients become uneven, the optimization problem changes during training, and networks become sensitive to initialization. LayerNorm addresses this by forcing activations into a consistent statistical profile.
Given an input vector with elements, LayerNorm performs two sequential transformations:
- Centering: Subtract the mean so values cluster around zero
- Scaling: Divide by the standard deviation so values have unit spread
After these operations, it applies learnable parameters to let the network recover any distribution it needs. The complete formula is:
where:
- : the input vector to normalize
- : the mean of the input elements
- : the variance of the input elements
- : learnable scale parameters (initialized to 1)
- : learnable shift parameters (initialized to 0)
- : a small constant for numerical stability (typically or )
- : element-wise multiplication
The numerator centers the data: every element is adjusted so the new mean is exactly zero. The denominator scales the data: it measures how spread out the values are and shrinks or expands them to unit variance. Together, these operations produce a standardized distribution, and the learnable parameters and then reshape it as the network sees fit.
The centering operation answers the question "where are these values located on the number line?" The scaling operation answers the question "how spread out are these values?" These are separate properties of a distribution, and in principle they could be handled separately or one could be dropped. LayerNorm handles both. RMSNorm drops the centering.
Zhang and Sennrich therefore asked whether the network needs both operations: does it?
The Hypothesis: Is Mean Centering Necessary?
The intuition behind centering is straightforward. Shifting activations to have zero mean creates a symmetric distribution around the origin. Optimization algorithms can work with positive and negative gradients more evenly. Activations don't accumulate bias through layers. It seems like a good idea.
But consider what happens after normalization. The learnable shift parameter can move the output to any mean value. If the network learns (setting the shift equal to the original mean), it completely undoes the centering we just performed. The network has the freedom to recover the original distribution entirely.
This observation reveals something subtle: centering is not a hard constraint. It's a soft regularization that the network can override if needed. The real question becomes whether the network benefits enough from the centering operation to justify its computational cost.
The cost is not trivial. Computing the mean requires summing all elements and dividing. Then we subtract this mean from every element. Only after that can we compute the variance (which requires another pass through the data). If we could skip the centering step entirely, we'd eliminate:
- One reduction operation (computing )
- subtraction operations (computing for each element)
- Dependency chains that limit parallelization on hardware accelerators
Zhang and Sennrich hypothesized that in transformer architectures with proper initialization, activations naturally stay roughly centered anyway. Residual connections add the original input back, preventing values from drifting too far from zero. If activations are already near-centered, explicitly centering them might be redundant.
The following visualization demonstrates this empirically. We simulate a 12-layer transformer with residual connections and standard initialization, collecting the per-sample mean of activations at each layer. The distribution of these means tells us how centered real transformer activations tend to be.

The histogram shows that the vast majority of per-sample activation means fall within a very small window around zero. This is the empirical foundation for RMSNorm: if the data is already nearly centered, we get very little benefit from explicitly subtracting the mean, and we can safely drop that step.
The RMSNorm Formulation: Keeping Only What Matters
RMSNorm tests this hypothesis by removing mean centering entirely. Instead of measuring spread around the mean (standard deviation), it measures spread around zero (root mean square). This single change eliminates the need to compute or subtract the mean.
The root mean square (RMS) of a vector captures its typical magnitude. Think of it as answering the question: "How big are these values, on average?" It squares each element (making everything positive), averages them, and takes the square root (returning to the original scale). Large values contribute more; small values contribute less. The result is a single number representing the typical magnitude of the vector.
where:
- : the root mean square of the input vector, a scalar measuring typical magnitude
- : the number of elements in the input vector
- : the -th element of the input vector
- : the mean of squared values (the "mean square"), which is then square-rooted
Why does this formula make sense? Notice that squaring each element before averaging removes the sign: negative values like and positive values like both contribute equally to the RMS (both contribute to the mean). This makes RMS a measure of magnitude independent of direction. If you have a vector where all values are large in absolute terms but some are positive and some negative, the RMS will be large even if the mean happens to be close to zero.
The root mean square (RMS) of a set of values is the square root of the arithmetic mean of their squares. Unlike standard deviation, which measures spread around the mean, RMS measures the magnitude of values around zero. For a zero-mean distribution, RMS equals standard deviation. The RMS has many applications outside machine learning: in physics it is used to characterize the amplitude of alternating current signals, and in statistics it provides an alternative to the mean absolute value for measuring typical magnitude.
Dividing by the RMS normalizes the vector to have unit RMS. Values that were large become order-1; values that were small stay small but in proportion. This is the core of RMSNorm:
Expanding the RMS definition:
where:
- : learnable scale parameters (initialized to 1), allowing the network to rescale each feature independently
- : a small constant for numerical stability (typically ), added to the RMS before division to prevent division by zero
Notice what's absent compared to LayerNorm:
- No mean subtraction (): We normalize around zero, not around the data's center
- No shift parameter: Since we don't center, we don't need a separate learned offset to un-center
RMSNorm is purely a scaling operation. Each input element is divided by the same scalar (the RMS), then multiplied by its corresponding learned scale factor. The operation preserves the relative relationships between elements while bringing everything to a consistent magnitude. The simplicity of this formulation is not a weakness: it is a feature that reduces computation while preserving the properties that matter.