Analytics Legends logoAI & Analytics Legends Sign inSign up
Concept card

LayerNorm and RMSNorm

LayerNorm and RMSNorm — AI & Analytics Legends section illustration for the SAP AI & Analytics knowledge base (concepts, studies, Academy)

As of 2026-11-14

What is LayerNorm and RMSNorm?

RMSNorm keeps LayerNorm's re-scaling but drops its mean-centring and bias; Zhang and Sennrich measured comparable quality with running time cut by 7 % to 64 % depending on the model. Llama 3.x places it before each sublayer (pre-norm): two RMSNorm per decoder layer plus one final norm, which is the recipe that lets 80- and 126-layer models train without the warm-up that post-norm needs.

LayerNorm and RMSNorm rescale each token's feature vector before or after every sublayer of a transformer so that activations keep a stable magnitude as they pass through dozens of matrix multiplications. Which one a model uses, and where it sits, is fixed at pre-training and baked into the weights. A consultant never configures it on a hosted model, but it decides how a self-hosted open-weight model behaves under fine-tuning, low precision and quantisation.

Two formulas, one difference

LayerNorm (Ba et al., 2016) computes, over the d features of one token, γ ⊙ (x − μ) / √(σ² + ε) + β: it subtracts the mean μ, divides by the standard deviation, then applies a learned scale γ and a learned bias β, each a vector of d values. RMSNorm (Zhang and Sennrich, 2019) keeps only the re-scaling: γ ⊙ x / √(mean(x²) + ε). There is no mean subtraction and no bias. The authors argue that re-centring is dispensable and report comparable performance to LayerNorm with running time reduced by 7 % to 64 % on different models. The saving comes from doing less work per call — one reduction (the mean of squares) instead of two (mean, then variance) and no bias add — not from a smaller model.

Why it matters

  • Normalisation is fixed at pre-training: a self-hosted open-weight model brings its norm type, placement and ε with it, and a fine-tuning plan that ignores them inherits avoidable training-stability risk.
  • Placement decides the learning-rate schedule: post-norm needs a carefully designed warm-up (Xiong et al., 2020), while Llama-style pre-norm RMSNorm needs only a short one (Llama 3 still used a linear warm-up of 8,000 steps) — so a schedule copied from the wrong family wastes compute or diverges.
  • Normalisation is where fp16 overflow, bf16 imprecision and INT8 activation outliers show up first, so the precision and quantisation assumptions of a self-hosted deployment are tested here.

Key points

  • RMSNorm drops LayerNorm's mean subtraction and bias — comparable quality with running time reduced by 7–64 % depending on the model (Zhang & Sennrich, 2019).
  • Pre-norm (Norm before the sublayer) keeps gradients well-behaved at initialisation and trains without warm-up; post-norm, the 2017 original, needs a carefully designed warm-up (Xiong et al., 2020).
  • Llama 3.3 applies RMSNorm at 2 positions per decoder layer — input_layernorm (before attention) and post_attention_layernorm (before the FFN) — plus one final model.norm after the last layer: 80 × 2 + 1 = 161 norms in the 70B.
  • The parameter saving is negligible (161 × 8,192 = 1,318,912 γ values, ~0.002 % of Llama 3.3 70B); the real saving is one reduction pass instead of two on every token.
  • INT8 quantisation interacts with normalisation: γ is a per-channel vector, so a few large γ values create activation outliers in those channels, which need per-channel scaling or outlier handling (e.g. SmoothQuant, LLM.int8()).
  • bf16 stores only 7 mantissa bits and fp16 overflows above 65,504 (any |x| ≥ 256 when squared), so training stacks compute the RMSNorm or LayerNorm reduction in fp32 and cast back (Meta's Llama reference code does exactly this) — check that a self-hosted serving or fine-tuning image keeps that upcast.
  • Beyond standard depths, DeepNorm (a post-norm variant that up-weights the residual shortcut by α and scales initialisation by β) trained 1,000-layer transformers, and Gemma 2 normalises both the input and the output of each sublayer with RMSNorm.

Terms used on this page

LayerNorm
Normalisation layer (Ba et al., 2016) that subtracts the mean of each token's feature vector, divides by its standard deviation, then applies a learned scale γ and bias β.
RMSNorm
Root Mean Square normalisation (Zhang & Sennrich, 2019): divides by the root mean square only, without mean subtraction or bias; 7–64 % shorter running time than LayerNorm across the models of the original paper.
Pre-norm
Normalisation at the INPUT of each sublayer, inside the residual branch: x + Sublayer(Norm(x)). Used by Llama and Mistral; tolerates a much shorter learning-rate warm-up than post-norm (Llama 3 used 8,000 steps).
Post-norm
Normalisation after the residual addition: Norm(x + Sublayer(x)). The original 2017 Transformer design; needs a carefully designed learning-rate warm-up.
γ (gain)
The learned per-channel scale vector of a normalisation layer — one value per feature, shared by all tokens; large values create activation outliers that matter for INT8 quantisation.

Sources

  1. Ba, Kiros & Hinton 2016 — Layer Normalization
  2. Zhang & Sennrich 2019 — Root Mean Square Layer Normalization
  3. Xiong et al. 2020 — On Layer Normalization in the Transformer Architecture
  4. Meta — Llama 3.3 70B Instruct model card and configuration
  5. Dettmers et al. 2022 — LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale
  6. Xiao et al. 2022 — SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models
  7. Llama Team, Meta — The Llama 3 Herd of Models, arXiv:2407.21783 (2024)
  8. Meta — llama3 reference implementation, llama/model.py (RMSNorm, attention_norm, ffn_norm)
  9. Hugging Face Transformers — modeling_llama.py (LlamaRMSNorm, LlamaDecoderLayer, final norm)
  10. Wang et al. — DeepNet: Scaling Transformers to 1,000 Layers, arXiv:2203.00555 (2022)
  11. Gemma Team — Gemma 2: Improving Open Language Models at a Practical Size, arXiv:2408.00118 (2024)
  12. Mistral AI — Mistral-7B-v0.1 configuration (rms_norm_eps)
  13. SAP Help Portal — Generative AI Hub in SAP AI Core

Full card with the Consultant plan — €19.90/month. What the full card adds: the full decision framework · the SAP vs Snowflake / Databricks / Fabric comparison · the common pitfalls and their fix · the cheat sheet · the architecture schemas · the code blocks · the facts worth quoting.

Open in the app →

Open missions

SAP analytics jobs and contracts · freelance SAP contracts.