Why it matters

Loss scaling critical for fp16 training. Understanding shapes precision management.

Advertisement

The architecture

Loss = actual_loss * S.

Backprop: gradients * S.

Unscale before optimizer.

Loss scalingMultiply lossby scale SBackpropgradients scaledUnscalebefore optimizerDynamic loss scaling adjusts S based on inf/nan detection; standard in AMP
Loss scaling.
Advertisement

How it works end to end

Fixed vs dynamic scaling.

Dynamic: increase S if no overflow; halve if overflow.

Check for inf/nan.

bf16 doesn't need loss scaling.