The GradScaler implosion: how filtered-out NaN gradients became NaN weights

gilesthomas.com20 min read

The author investigates why PyTorch's GradScaler tool, which is designed to filter out non-finite gradients during mixed-precision training, can cause finite gradients to overwrite model weights with NaNs. The investigation reveals that when repeated non-finite losses cause the scaling factor to underflow to zero or effectively zero, subsequent finite gradients are divided by zero to produce NaNs. The author concludes that this failure mode is a downstream symptom of a training run that has already diverged and is failing. Open article →

More on this topic