LearnQuestion bank

You are asked to move a pretraining run from FP8 to NVFP4 on Blackwell GPUs. Explain the NVFP4 format, what can go wrong numerically, and the recipe changes and monitoring you would put in place.

ML engineeringTechnicalHard

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • NVFP4: 4-bit E2M1 values in 16-element blocks, FP8 E4M3 block scale, per-tensor fp32 scale; unlike MXFP4’s 32-element blocks and power-of-two scales.
  • Numerical risks: in-block outliers crush small values, forward/backward can see differently quantised weights, and rounding can bias small gradient updates.
  • Recipe: random Hadamard transforms on weight-gradient inputs, 16x16 2-D scaling for weights, stochastic rounding for gradients; keep ~16% of linear layers (first two and last eight blocks in the 12B run) plus attention, embeddings, output head and norms in bf16.
  • Monitor loss gap vs FP8/bf16 reference and per-layer underflow; move to higher precision shortly before LR decay (the 12B, 10T-token run switched at 8.2T tokens and narrowed the gap).
  • Benefit: FP4 tensor cores give 2-3x FP8 math throughput (2x GB200, 3x GB300) and roughly halve operand memory, but the saving must be weighed against any quality gap.

In full

The core point is that NVFP4 is not just a narrower FP8: it uses 4-bit E2M1 values in 16-element blocks with an FP8 E4M3 block scale and a per-tensor fp32 scale, whereas MXFP4 uses 32-element blocks with power-of-two scales, so the block granularity and scale representation both change the error profile. The main numerical risks are that outliers inside a block can crush the other values, forward and backward passes can see differently quantised weights, and deterministic rounding can bias small gradient updates. My recipe would keep the sensitive parts in bf16: about 16% of linear layers (in NVIDIA’s 12B run, the first two and last eight blocks), plus attention, embeddings, the output head and norms, while applying random Hadamard transforms to weight-gradient inputs, 16x16 2-D scaling for weights, and stochastic rounding for gradients. I would track the loss gap against an FP8 or bf16 reference and per-layer underflow, and I would switch to higher precision shortly before learning-rate decay, since in NVIDIA’s 12B, 10T-token run switching late in training (at 8.2T tokens) narrowed the remaining loss gap. The upside is real: FP4 tensor cores give 2-3x FP8 math throughput (2x on GB200, 3x on GB300) and halve operand memory, but I would only adopt it if the measured quality gap stays small enough to justify the speed and memory win.

Corrected by an independent AI reviewer.

What a strong answer covers

  • NVFP4: 4-bit E2M1 values in 16-element blocks with an FP8 E4M3 block scale and a per-tensor fp32 scale, compared with MXFP4’s 32-element blocks and power-of-two scales.
  • Risks: outliers inside a block crush the other values, forward and backward passes can see differently quantised weights, and rounding biases small gradient updates.
  • Recipe: random Hadamard transforms on weight-gradient inputs, 16×16 2-D scaling for weights, stochastic rounding for gradients, and roughly a sixth of linear layers (mostly the last blocks) plus attention, embeddings and norms kept in bf16.
  • Monitors the loss gap against an FP8 or bf16 reference and per-layer underflow, and switches to higher precision shortly before learning-rate decay, which narrowed the gap in NVIDIA’s 10T-token run.
  • Benefit: FP4 tensor cores give 2–3× FP8 math throughput and halve operand memory, so the saving has to be weighed against any quality gap.

Common mistakes

  • Quantising every layer, including embeddings and the output head, to FP4.

Follow-ups

  • Which evaluation would you trust to detect quantisation damage early in a run?