Sam Babichenko

Reading notes / Low-precision training

Pretraining with NVFP4

NVIDIA, 2025

A linear layer
xxlayer input, TT tokens by KK features
wwweight, NN outputs by KK inputs
ggoutput gradient ∂L/∂y\partial L/\partial y, T×NT\times N
yylayer output xqwq⊤x_q w_q^\top
xqx_qforward NVFP4 input RN(x)\mathrm{RN}(x), blocked along KK
wqw_qNVFP4 weight, one scale per 16×1616\times16 tile
wbw_ba backward copy blocked down the columns (avoided)
Encoding
RN,\mathrm{RN}, QQNVFP4 encoding of a tensor with round to nearest, with stochastic rounding; RNE4M3\mathrm{RN}_{\rm E4M3} rounds to the nearest E4M3 number
viv_ia value before encoding
sks_kE4M3 scale of block or tile kk
α\alphaFP32 outer scale, one per tensor
a<ba\lt badjacent grid points around uu, step h=b−ah=b-a
δ\deltasmall excess in the MXFP4 example
Rotation
RRrotation of each run of 16 tokens by HDHD
HH16×1616\times16 Hadamard matrix, entries ±1/4\pm1/4 (32×3232\times32 in Thinking Machines' combine)
DDdiagonal matrix of random signs
MMsize of an outlier
Paper's symbols
wfprop,w_{\rm fprop}, wbpropw_{\rm bprop}what the paper writes for wqw_q and wbw_b
sdec,s_{\rm dec}, sdec,bs_{{\rm dec},b}what the paper writes for α\alpha and the block scale
SdS_dwhat the paper writes for DD
Fprop, Dgrad, Wgradthe forward, input-gradient and weight-gradient products

Context. On NVIDIA's GB300 Blackwell GPU, a general matrix multiplication, the product of two matrices; GEMMs account for most of the compute of training a transformer in the 4-bit format 4-bit E2M1 values qi∈{0,±0.5,±1,±1.5,±2,±3,±4,±6}q_i\in\{0,\pm0.5,\pm1,\pm1.5,\pm2,\pm3,\pm4,\pm6\}, one 8-bit E4M3 scale sks_k per block of 16 and one FP32 outer scale α\alpha, decoded as v^i=qi sk α\hat v_i=q_i\,s_k\,\alpha; a value below about 1/241/24 of its block's largest rounds to zero. Reading note: End-to-end 4-bit training peaks at 6 times the bfloat16: a 16-bit floating-point format with 8 exponent bits and 7 mantissa bits, the default for large-model training rate, compared with 2 times for 8-bit formats. Its operands also take about half the memory of 8-bit ones. That speed comes with rounding error at every layer and step. Over trillions of tokens, small systematic errors can compound, and a weight gradient summed over every token in a batch accumulates any rounding bias. NVIDIA (2025) trained a 12B-parameter a language model that mixes self-attention blocks with Mamba-2 blocks, state-space layers whose cost grows linearly with sequence length, and feed-forward blocks; here the Nemotron-H family on 10 trillion tokens with the forward product and both backward products of most linear layers in NVFP4. It was the longest publicly documented 4-bit training run when it appeared, and the paper compares it against the same model trained in 8-bit floating point; here E4M3 values with one scale per 128 by 128 block of a weight and per 1 by 128 block of an activation or gradient, as in DeepSeek-V3.

Four bits hold across both passes for 10T tokens when each tensor gets a safeguard matched to how its error hurts training. Weights use one scale per 16 by 16 tile so the forward and backward passes multiply by the same 4-bit weights. Gradients use unbiased rounding a value uu between adjacent grid points a<ba\lt b up to bb with probability (u−a)/(b−a)(u-a)/(b-a) and down to aa otherwise, so that E Q(u)=u\mathbb E\,Q(u)=u. Reading note: End-to-end 4-bit training, while every other tensor rounds to nearest for smaller error. The weight-gradient product, the only product without a weight operand, applies a multiplication of a run of values by HDHD, with HH a Hadamard matrix scaled to be orthogonal and DD a diagonal matrix of random signs; it keeps the norm and spreads an outlier evenly over the run. Reading note: End-to-end 4-bit training to both inputs to spread outliers. A small share of linear layers, mostly at the end of the network, stays in BF16. The 12B model finished with a loss slightly more than 1.5% above FP8's and matched it on most downstream tasks, including 62.58% against 62.62% on a harder, ten-option version of the MMLU multiple-choice benchmark of academic and professional questions. Removing any single safeguard at 12B worsened the loss. Most of the remaining gap comes from the forward pass, and switching that pass to BF16 around the start of learning-rate decay closes most of it.

Setting. The model follows the Nemotron-Nano-12B-v2-Base architecture with 62 blocks: 28 Mamba-2, 28 feed-forward, and 6 self-attention. Training uses a a learning-rate schedule that warms up, holds the rate constant, then decays it; here constant for the first 80% of training and decayed over the last 20%, holding the learning rate constant for the first 80% of tokens and decaying it over the last 20%. All NVFP4 matrix products accumulate in FP32. Embeddings, normalization layers, the output head, and attention's softmax and two batched products stay in BF16 or FP32, along with master weights, accumulated gradients, and optimizer states.

For a linear layer with input the input of a linear layer: TT tokens by KK features, weight the weight of the linear layer: NN output features by KK input features, and loss gradient the gradient ∂L/∂y\partial L/\partial y of the loss LL with respect to the layer's output yy, a T×NT\times N matrix (∂L/∂y\partial L/\partial y), training computes three matrix products, called Fprop, Dgrad, and Wgrad in the paper:y=xq wq⊤,∂L/∂x≈Q(g) wq,∂L/∂w≈Q(Rg)⊤ RN(Rx).\begin{aligned}y&=x_q\,w_q^\top,\\ \partial L/\partial x&\approx Q(g)\,w_q,\\ \partial L/\partial w&\approx Q(Rg)^\top\,\mathrm{RN}(Rx).\end{aligned}Here NVFP4 encoding with round to nearest: each value divided by its block scale and outer scale goes to the closest E2M1 value and NVFP4 encoding with stochastic rounding of each scaled value, unbiased: E Q(u)=u\mathbb E\,Q(u)=u denote NVFP4 encoding with round to nearest and with stochastic rounding, blocked in groups of 16 along the summed dimension. The forward input xqx_q=RN(x){}=\mathrm{RN}(x) is blocked along the KK features, Q(g)Q(g) along the NN outputs, and both weight-gradient operands along the TT tokens. The weight the NVFP4 weight, encoded from the FP32 master weight with one scale per 16 by 16 tile and round to nearest is encoded from the FP32 master weight in square tiles. The operator the rotation that multiplies each run of 16 consecutive tokens by HDHD; it is orthogonal, R⊤R=IR^\top R=I applies an orthogonal random Hadamard rotation to each run of 16 tokens, detailed below. Every tensor carries one FP32 outer scale α\alpha=max⁡i∣vi∣/(6⋅448){}=\max_i|v_i|/(6\cdot448) over its unquantized values viv_i, setting its largest block scale to 448, the top of an 8-bit floating-point format with 4 exponent bits and 3 mantissa bits; its positive values run from 2−92^{-9} to 448.

Square weight tiles make the backward pass use the same 4-bit weights as the forward pass. A the GPU unit that executes block-scaled matrix multiplications; it needs both operands blocked along the dimension that the product sums over requires both operands to be blocked along the summed dimension: KK in the forward product and NN in the input-gradient product. Under 1 by 16 blocks, the weight would need two encodings: along its rows as wqw_q, and down its columns as a different copy a backward copy of the weight encoded in 1 by 16 blocks down its columns; in general wb≠wqw_b\ne w_q≠wq{}\ne w_q. The product Q(g) wbQ(g)\,w_b would then compute the input gradient of x↦x wb⊤x\mapsto x\,w_b^\top, a layer the forward pass never ran. A 16 by 16 tile groups the same 256 weights in both orientations. Giving tile kk a single scale, rounded to the nearest E4M3 value,sk=RNE4M3(max⁡j∈k∣vj∣6α),s_k=\mathrm{RN}_{\rm E4M3}\Big(\frac{\max_{j\in k}|v_j|}{6\alpha}\Big),produces one wqw_q for both products. Replicating that scale across each of the tile's sixteen 1 by 16 rows keeps the tensor in standard NVFP4 for hardware, though the scale is coarser because it comes from 256 weights.

In a 1.2B-parameter ablation, weights encoded along different dimensions in the two passes trained worse than square tiles, despite the tiles' coarser scale. They also trailed a hardware-unsupported control that keeps 1 by 16 blocks oriented the same way in both passes to isolate consistency. The authors suggest that weights tolerate the coarser tile scale because they adapt to their 4-bit values during training. They also hypothesize that inconsistent backward weights hurt by injecting error into the activation gradient, which then propagates down to earlier layers. Activations keep 1 by 16 blocks and are encoded afresh for the weight gradient, so RN(Rx)\mathrm{RN}(Rx) differs from xqx_q. In the same ablation, that activation mismatch mattered only during learning-rate decay.

Stochastic rounding goes on the gradients only, because its unbiasedness costs error size. For a value uu between adjacent grid points the two grid values on either side of uu; h=b−ah=b-a is the grid step there, round to nearest has error min⁡(u−a, b−u)\min(u-a,\,b-u) with a fixed sign, while stochastic rounding removes bias at the cost of higher variance:E Q(u)=u,E (Q(u)−u)2=(u−a)(b−u)≥min⁡(u−a, b−u)2.\begin{aligned}\mathbb E\,Q(u)&=u,\\ \mathbb E\,(Q(u)-u)^2&=(u-a)(b-u)\\&\ge\min(u-a,\,b-u)^2.\end{aligned}For uu uniform over the cell of width h=b−ah=b-a, the mean squared error doubles from h2/12h^2/12 for round to nearest to h2/6h^2/6 for stochastic rounding (computed here). Weight gradients sum products across every token in a batch, so zero-mean noise partly cancels while bias adds up. Unbiasedness pays off there. Underflow causes the sharpest bias. A gradient at 1/301/30 of its block's peak scales to 0.2 on the 4-bit grid, so round to nearest sends it to 0 every time. Stochastic rounding maps it to 0.5 with probability 0.4 and preserves its mean.

Forward tensors benefit from the smaller error of round to nearest. In the 1.2B ablation, stochastic rounding converged on gradients, diverged on activations or weights, and added little when extended to every backward tensor. At 12B, gradients needed stochastic rounding in both backward products, and removing it caused the largest loss jump among the four 12B ablations. Blackwell GPUs perform stochastic rounding directly inside the conversion instruction.

The rotation goes on the weight-gradient product only, because it must act on both operands to cancel. The rotation RR multiplies each run of 16 consecutive tokens by HDHD. Here the 16×1616\times16 Hadamard matrix scaled to be orthogonal: entries ±1/4\pm1/4 and orthogonal rows is the 16×1616\times16 orthogonal Hadamard matrix with entries ±1/4\pm1/4, and a diagonal matrix of random signs ±1\pm1, one sign vector shared by all layers for the whole run is a diagonal matrix of random signs. Because RR is orthogonal along the summed token dimension,(Rg)⊤(Rx)=g⊤R⊤R x=g⊤x,(Rg)^\top(Rx)=g^\top R^\top R\,x=g^\top x,so both operands can be encoded after rotation without changing the product up to rounding. Rotating the forward or input-gradient product would rotate the weight along KK in one pass and along NN in the other, bringing back two incompatible weight encodings. Inside each 16-token run, RR spreads an outlier of size the magnitude of a single outlier among the 16 values of a run as ±M/4\pm M/4 across all 16 entries. In the 1.2B ablation, rotating the weight-gradient inputs lowered the loss, while rotating forward or input-gradient inputs raised it. The authors suggest that rotation adds more rounding error in those products than it removes from outliers. At 12B, shrinking the rotation from 16×1616\times16 to 4×44\times4 after 3.4T tokens raised the loss, while 128×128128\times128 lowered it slightly, so 16 stayed for its lower cost. The random signs in DD mattered at 12B, though not at 1.2B, and one sign vector shared across all layers for the whole run was enough.

The last layers stay in higher precision because they diverge in 4 bits. With every linear layer in NVFP4 and no other safeguards, the 1.2B model diverged early in training. Keeping its last four blocks in BF16 restored convergence, while keeping its first four did not. First blocks helped only alongside last ones. Because the authors measured larger weight-gradient quantization errors in the final layers, they suggest using those error measurements to choose which layers stay in higher precision. The 12B run kept its first two and last eight blocks in BF16, or 16% of its linear layers. An ablation keeping only the last four blocks stayed stable with a loss close to the full recipe's, showing that ten blocks was conservative. The paper recommends keeping why: an empirical rule from the 1.2B and 12B runs; every layer in 4 bits diverged, and the last blocks are the ones whose 4-bit weight gradients carry the most error of linear layers in higher precision, mostly at the end.

Switching the forward pass to BF16 during decay closes most of the remaining gap. On the 12B run, NVFP4's loss stayed within 1% of FP8's during the constant-learning-rate phase and widened during decay. Most of that gap comes from the forward pass. Switching the forward product to BF16 at 8.2T tokens, just after decay started at 8T, cut the gap to 0.5%. That switch put about 6% of total compute, one third of the final 18%, into higher precision. Switching both passes matched FP8's loss, while switching only the backward pass gave no gain, unlike in Chmiel et al. (2025). Switching both passes around 10T tokens, for under 1% of training, closed much of the gap but not all of it. The authors guess that the learning rate was already too low by then for the weights to move far. They recommend switching shortly before decay begins, or at the very end for a smaller gain at almost no cost.

NVFP4's finer scales and shorter blocks also carry part of the gain. a 4-bit microscaling format with the same E2M1 values and one power-of-two (E8M0) scale per block of 32 uses the same E2M1 grid with one power-of-two scale per 32 values, rounded up to prevent overflow. Rounding up can leave the top of the grid unused. A block whose largest magnitude is 3+δ3+\delta, for small a small positive amount, maps tos=3+δ6=0.5+δ6 → 1,3+δs=3+δ → 3.\begin{aligned}s&=\tfrac{3+\delta}{6}=0.5+\tfrac{\delta}{6}\ \to\ 1,\\ \tfrac{3+\delta}{s}&=3+\delta\ \to\ 3.\end{aligned}The first arrow rounds the scale up to a power of two, and the second rounds the scaled value to nearest. Codes 4 and 6 sit empty, restricting the block to log⁡2(3/0.5)≈2.58\log_2(3/0.5)\approx2.58 of the grid's log⁡2(6/0.5)≈3.58\log_2(6/0.5)\approx3.58 factors of two in magnitude; a range from 0.5 to 6 spans log⁡212≈3.58\log_2 12\approx3.58 of them. NVFP4's E4M3 scale lands the block peak close to 6 across blocks half as long. On an 8B hybrid model trained for 1T tokens with the same recipe, MXFP4 finished 2.5% above BF16's loss against 1.5% for NVFP4, and needed 36% more tokens to match NVFP4's loss.

Comparing the two NVFP4 recipes. Thinking Machines' recipe, which runs 4-bit forward products from pretraining through RL, faces the same transpose problem and solves it the opposite way. NVIDIA runs all three products in NVFP4 and enforces bit-for-bit weight equality with one scale per 256 weights. Thinking Machines keep 1 by 16 row blocks and put 4 bits only in the forward pass of their expert layers. To match the forward tensors in expectation during the backward pass, they decode xqx_q and wqw_q, transpose them, and re-encode them in an 8-bit microscaling format with E4M3 or E5M2 values and one power-of-two scale per 32 values, 8.25 bits per value with stochastic rounding. They tested square tiles and found the coarser scale cost more compute efficiency than they would accept. The two recipes handle activations differently too. NVIDIA's weight gradient re-encodes the BF16 input directly, so it is not strictly the gradient of the forward function, while Thinking Machines re-encode the decoded xqx_q.

The two results do not contradict each other. NVIDIA compared square tiles against inconsistent 1 by 16 blocks, never against re-encoded MXFP8 copies. The architectures also differ, with dense hybrid layers here and mixture-of-experts layers at Thinking Machines. So do the yardsticks. NVIDIA evaluates relative loss and benchmark parity, while Thinking Machines track compute efficiency. Going by the 8B comparison above, a single percentage point of relative loss is costly in compute efficiency. NVIDIA's run adds evidence that the backward pass itself can run in 4 bits over trillions of tokens.

Evidence and limits. The main comparison is a full-length run at realistic scale: the 12B model trained for 10T tokens tracked a matched FP8 run in loss and downstream accuracy throughout. To test each safeguard at scale, the 12B ablations branch from the 3.43T-token checkpoint for about half a trillion tokens, removing one safeguard at a time. Finer choices, such as which tensors get stochastic rounding or rotation and which layers stay in BF16, rest on 1.2B ablations. Because random signs and rotation size mattered at 12B but not at 1.2B, small-scale ablations can miss effects that emerge at scale. The paper reports one run per configuration. Downstream parity holds on most tasks, with code as the exception at 56.67% against 59.52%. The authors suspect that gap comes from a noisy evaluation of the final checkpoint. The FP8 baseline kept only its first block and last two blocks in BF16, compared with ten blocks for NVFP4, and no mixture-of-experts model was tested. Because the paper focuses on numerics, it reports no wall-clock training speeds. The GEMM speedups cited above are hardware peaks.

Terms

Three products
y=xqwq⊤y=x_qw_q^\top, ∂L/∂x≈Q(g)wq\partial L/\partial x\approx Q(g)w_q, ∂L/∂w≈Q(Rg)⊤RN(Rx)\partial L/\partial w\approx Q(Rg)^\top\mathrm{RN}(Rx), all in NVFP4
16 by 16 weight tiles
one scale per tile, the same in both orientations, so the forward and input-gradient products use the same 4-bit weights
Stochastic rounding
on gradients only: unbiased, but for a value uniform over a grid cell of width hh the mean squared error is h2/6h^2/6 against h2/12h^2/12 for round to nearest
Hadamard rotation
16×1616\times16, on the weight-gradient inputs only, where both operands can be rotated: (Rg)⊤(Rx)=g⊤x(Rg)^\top(Rx)=g^\top x
BF16 layers
about 15% of linear layers, mostly the last blocks; every layer in 4 bits diverges
Remaining gap
under 1% of FP8's loss in the stable phase, about 1.5% after the decay; mostly from the forward pass
Precision switch
forward pass to BF16 around the decay's start cuts the gap to 0.5% for about 6% of the compute
NVFP4 against MXFP4
MXFP4's rounded-up power-of-two scale can waste the codes 4 and 6; it needed 36% more tokens at 8B
Against Thinking Machines
bit-for-bit weights with coarse tiles and 4-bit backward, against fine blocks with MXFP8 backward copies equal in expectation
Result
12B, 10T tokens: MMLU-Pro 62.58% against 62.62% for FP8

Sources

Connected notes

  • SGD's expected loss is the gradient-descent loss plus a term from noise injected while the loss is still of order one, so SGD noise matters only when the kernel decays more slowly than the gradient-descent loss.

  • Dividing the numerator of softmax attention by its L2 norm, which fixes the output's length, follows the softmax loss curve, while dividing by the sequence length behind a gate, with scores clamped at 5 and gradients clipped, still gives loss spikes.

  • Under μ\muP the optimal learning rate, initialization scale and multipliers are nearly stable in width, so they can be tuned on a small proxy and copied, and a 40M proxy beat the published 6.7B GPT-3 at a tuning cost of 7% of its pretraining cost.

  • Smoothing the loss over a cap of radius λ\lambda shrinks gradient noise faster than the squared signal up to λ=d1/4\lambda=d^{1/4}, which lowers the sample cost from dk⋆−1d^{k^\star-1} to the correlational-query lower bound dk⋆/2d^{k^\star/2}.

Threads