English · Español
05 — Why bf16 + RMSNorm became the modern default¶
🇪🇸 La pareja
bf16 + RMSNormno es moda. Es la respuesta cuantitativa a dos preguntas: "¿qué precisión necesito en cada tensor?" y "¿cuál es el camino más barato para mantener la varianza bajo control?". En esta página enseñamos los números — exponente vs. mantisa de bf16, FLOPs y memory traffic de RMSNorm vs. LayerNorm — y mostramos por qué se asentaron juntos en Llama/Mistral/Qwen.Anchors:
LYNX_CORTEX.md§4 / PHASE 10;LYNX_CORTEX_ADDENDUM.md§A13. Phase 2 §04 precision zoo; this phase §02 normalization variants.
The two questions¶
- Numeric format —
fp32is safe but expensive;fp16is cheap but its exponent range is narrow enough that activations under-/over-flow during training. What's the cheapest format that doesn't break training? - Normalization — LayerNorm works but costs 5 reads + 3 reductions + 1 affine. Can we drop the mean subtraction without hurting convergence?
The answers — bf16 and RMSNorm — landed in the open-source LLM stack around 2021–2022 and have not been displaced since.
bf16 vs fp16: same total bits, very different distribution¶
| Format | Sign | Exponent | Mantissa | Dynamic range | Smallest normal |
|---|---|---|---|---|---|
| fp32 | 1 | 8 | 23 | ~10^-38 … 10^38 |
~1.18e-38 |
| fp16 | 1 | 5 | 10 | ~6e-5 … 6.55e4 |
~6.1e-5 |
| bf16 | 1 | 8 | 7 | ~10^-38 … 10^38 |
~1.18e-38 |
The headline: bf16 has fp32's exponent range with only fp16's storage cost. The mantissa is shorter — 7 bits vs 10 — so it's less precise per number. But neural-network training does not need precision; it needs range.
Why range matters and precision doesn't¶
A gradient of magnitude 1e-7 flowing through a LayerNorm produces a denominator near 1e-3.5. The intermediate values can swing across 8 orders of magnitude in a single backward step. fp16's 6e-5 minimum means the bottom 3 orders silently underflow to zero — gradients vanish, training stalls. bf16's 1e-38 floor avoids this entirely.
Mantissa precision: a 7-bit mantissa gives ~3 decimal digits. That's enough to represent a unit gradient as 1.000 ± 0.004. Stochastic gradient descent is already a noisy estimator — ±0.4% quantization noise is in the same order as the SGD variance, so it doesn't hurt convergence.
This is the bf16 thesis in one sentence: trade mantissa bits you don't need for exponent bits you do.
Empirical evidence¶
- Kalamkar et al. 2019 ("A Study of BFLOAT16 for Deep Learning Training") show ResNet-50, BERT, GNMT train to the same accuracy in bf16 as fp32, while fp16 needs loss scaling (Micikevicius et al. 2018) to avoid divergence.
- Llama-2 (Touvron et al. 2023) trains in bf16 weights + bf16 activations + fp32 master grad accumulator. Phase 18's mixed-precision recipe copies this.
RMSNorm vs LayerNorm: the cost ledger¶
LayerNorm on a (B, L, d) tensor does, per element (i, j, k):
- compute
μ_{ij} = (1/d) Σ_k X_{ijk}— d reads, d-1 adds, 1 divide. - compute
σ²_{ij} = (1/d) Σ_k (X_{ijk} - μ_{ij})²— d reads, d-1 adds, d squares, 1 divide. (X - μ) / sqrt(σ² + ε)— d subs, d divs (effectively, after one reciprocal sqrt).· γ + β— d multiplies, d adds.
Total: ~5d FLOPs + 2 reductions + 5 reads of X.
RMSNorm:
r²_{ij} = (1/d) Σ_k X_{ijk}²— d reads, d squares, d-1 adds, 1 divide.X / sqrt(r² + ε) · γ— d divs, d multiplies.
Total: ~3d FLOPs + 1 reduction + 3 reads of X.
The asymptotic FLOP ratio is 3/5 = 60%. But normalization is memory-bound on every modern accelerator (it's one read for one FLOP). The memory-traffic ratio matters more:
- LayerNorm: 5 passes over X (μ-pass, σ-pass, normalize-pass, γ-pass, β-pass-fused).
- RMSNorm: 3 passes (r²-pass, normalize-pass, γ-pass-fused).
Memory traffic ratio: ⅗ = 60%. On Phase 1's roofline picture, this maps to ~40% wall-time saving for the norm op.
Does dropping the mean hurt?¶
The mean of x + f(x) after a residual block depends only on the mean of x (assuming E[f(x)] ≈ 0 at init, which holds for any GELU-after-Linear with zero-mean inputs). So the network's layerwise mean is already controlled — re-centering it every layer is redundant work.
Zhang & Sennrich 2019 ("Root Mean Square Layer Normalization") prove this empirically: on T5, RMSNorm trains 7–64% faster than LayerNorm with no quality loss on GLUE.
Llama (Touvron et al. 2023) adopted RMSNorm for the same reason. Every Llama-family model since uses it. PaLM, Qwen, Mistral, Gemma — all RMSNorm. The decade-long LayerNorm era ended.
What you get from the combination¶
bf16 saves the bottom of the loss-curve memory budget (no loss scaling, fewer underflows). RMSNorm saves the top (less compute, less memory traffic, no β parameter).
Together, they cut the per-step cost of one transformer layer by roughly 30% (rough rule of thumb on H100; Phase 23's GPU phase will measure it). For a 100B-param model at 1T tokens, 30% is millions of dollars and weeks of wall time.
The bf16 + RMSNorm lineage table¶
| Model | Year | Norm | Activation dtype |
|---|---|---|---|
| GPT-2 | 2019 | LayerNorm | fp16 |
| GPT-3 | 2020 | LayerNorm | fp16 |
| T5 | 2020 | RMSNorm | bf16 |
| GPT-NeoX | 2022 | LayerNorm | fp16 |
| Llama-1 | 2023 | RMSNorm | bf16 |
| Llama-2 | 2023 | RMSNorm | bf16 |
| Mistral 7B | 2023 | RMSNorm | bf16 |
| Qwen-1.5 | 2024 | RMSNorm | bf16 |
| Gemma | 2024 | RMSNorm | bf16 |
(Phase 36 will note that DeepSeek-V3 keeps RMSNorm and bf16, with MLA on top.)
What §A13 inherits¶
The §A13 grammar tutor is microscopic enough that the choice between fp32 LayerNorm and bf16 RMSNorm makes no difference to final accuracy. But Phase 10 still implements RMSNorm by default because:
- The mental model carries forward to Phase 17 (mini-GPT) and Phase 18 (training loop), where the choice does matter.
- Mixed-precision (bf16) is deferred to Phase 18 — but the norm is RMSNorm from day one. This is the kind of architectural decision we make on the cheap upfront because reversing it at Phase 25 is expensive.
Citations¶
- Kalamkar, D., Mudigere, D., et al. 2019. "A Study of BFLOAT16 for Deep Learning Training." arXiv:1905.12322.
- Zhang, B., Sennrich, R. 2019. "Root Mean Square Layer Normalization." arXiv:1910.07467.
- Touvron, H. et al. 2023. "LLaMA: Open and Efficient Foundation Language Models." arXiv:2302.13971.
- Micikevicius, P. et al. 2018. "Mixed Precision Training." arXiv:1710.03740 — the loss-scaling trick fp16 needs that bf16 doesn't.
One-paragraph recap¶
bf16 keeps fp32's 8-bit exponent (range ~10^±38) while trimming the mantissa to 7 bits — exactly the trade neural-network training wants because gradients need range, not precision. RMSNorm drops LayerNorm's mean subtraction (and the β bias parameter), cutting memory traffic to 60% and wall-time by ~40% on the norm op without quality loss. Together they cut a transformer layer's per-step cost by ~30% — millions of dollars at frontier scale. The §A13 model doesn't need either, but Phase 10 still uses RMSNorm because reversing the architectural choice in Phase 25 would be expensive.
Next: Phase 11 (tokenization).