Model and Inference EngineeringTraining execution and recoveryStaff
How can a stale FP8 scaling factor corrupt a training update, and how would you locate the first error?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A BF16 training run switches selected matrix multiplications to an FP8 recipe. Ordinary batches pass comparison, but a rare high-activation batch causes lasting loss degradation. Explain the scaling mechanism and design a replay that finds the first incorrect tensor. Include forward and backward paths, checkpointed scaling history, saturation and recovery after an update has already committed.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
BF16, or bfloat16, and FP8 are floating-point formats using 16 and 8 bits respectively. A scaling factor maps a tensor into the numerical range of the selected low-precision format before a matrix multiplication. The tensor’s amax is its largest absolute value. In a hypothetical quantizer with a maximum representable magnitude of 448, a scale of 44.8 maps a previous maximum of 10 onto that limit. A new value of 100 maps to 4,480 and saturates under clipping conversion, reconstructing near 10 rather than 100. Actual FP8 formats and recipes differ, but the lost magnitude explains how unchanged high-precision optimizer code can receive a corrupted gradient.
FP8 has a small representable range and limited precision. To use it for a tensor, a training recipe chooses a scale that maps values into that range. If the scale was estimated from earlier batches, an unusual current batch can arrive before the scale adapts. Some values may saturate or become too coarse. The next matrix product, gradient and optimizer update can then change even if optimizer state itself stays in higher precision. NVIDIA Transformer Engine's delayed-scaling documentation describes scales derived from an amax history. That is one recipe, so first confirm this run actually uses it.
I would replay the offending batch from the last clean checkpoint, with the same token IDs, masks and sequence positions. Compare BF16 and FP8 after each boundary where quantization occurs. Log the current tensor amax, the scale used, FP8 format, saturation count, underflow distribution and output error for each quantized matrix multiplication, often called GEMM, including its input and weight paths. Inspect forward and backward separately. If the first large difference appears before attention, do not spend days tuning the optimizer. If the FP8 tensors remain close but the gradient becomes nonfinite later, examine accumulation precision, reduction, loss scaling where applicable and the exact fused kernel. The batch itself may be corrupt, so inspect its labels and lengths too.
An amax chart for an entire model is too broad. A single projection in one layer can have a different distribution from its neighbors, and rare language or code sequences may populate the tail. Check whether scales are per tensor, per block or another granularity in the chosen recipe, and whether a scale history was restored consistently from checkpoint. Compare the scale immediately before and after the outlier. A spike in amax can also cause later ordinary values to be represented more coarsely until the history moves on. That is a different failure from the outlier itself saturating.
For a fix, I would try a more suitable scaling recipe, granularity or format, or leave the sensitive operation in a higher precision path if the throughput cost is acceptable. Change one variable at a time and rerun the same hard batches and representative training pilot. Hold a rare-cohort validation set so an overall loss average cannot approve a bad trade. If the bad step already updated weights and optimizer moments, resume from a known clean checkpoint after correcting the recipe. A later finite loss does not prove the contaminated step was harmless.
This is different from an FP8 KV cache at serving time. Here the quantized training computation changes the gradients and therefore the learned weights. The thing to locate is the first tensor whose scaled representation no longer supports the intended update, not just the first dashboard point where loss finally rises.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux