The author investigates a perplexing issue with the GradScaler in PyTorch, which led to model weights becoming NaN during training, despite using Automatic Mixed Precision (AMP). The post explains the detailed mechanics of GradScaler and explores how it handles finite and non-finite gradients. It also recounts the author's personal experience of diagnosing the problem and finding that a chain of NaN losses resulted in the scaler underflowing to zero, which ultimately corrupted the model weights. The author concludes that while the GradScaler's behavior is insightful, the root issue lies in the model's hyperparameters and training setup, which must be addressed to prevent divergence.