Exploding Gradients: Trace Large Norms and Non-Finite Values
Investigate exploding gradients using unscaled norms, the first non-finite operation, loss inputs and optimizer state before changing clipping or learning rate.
Loss spikes or NaNs alone do not prove exploding gradients. Measure unscaled gradient norms and locate the first non-finite value. Check inputs, loss calculations and optimizer state before choosing a controlled change.
- Root cause
- Unconfirmed until the earliest invalid operation and relevant inputs, gradients and optimizer state are inspected.
- Recommended fix
- Preserve the first affected step, loss inputs, unscaled gradient measurements and optimizer settings.
- How Denpex helps
- Denpex investigates Exploding Gradients: Trace Large Norms and Non-Finite Values using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
What this failure is
Excessive gradient magnitude during backward computation, distinct from every other cause of a non-finite loss.
Is this what broke your run? Paste your log.
You're reading about Exploding Gradients: Trace Large Norms and Non-Finite Values. Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
Why it happens (the mechanism)
The responsible operation and state must be identified. Numerical overflow, invalid inputs and optimizer updates can produce similar symptoms.
What you'll observe
- Training becomes unstable while gradient magnitude or finiteness changes.
Common symptoms and what they mean
Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.
| Symptom | Possible explanation |
|---|---|
| Rapid growth in measured unscaled gradient norms | Unconfirmed until the earliest invalid operation and relevant inputs, gradients and optimizer state are inspected. |
| Non-finite gradients, requiring investigation of the first invalid operation | Unconfirmed until the earliest invalid operation and relevant inputs, gradients and optimizer state are inspected. |
Which systems are affected
- Gradient-based training workloads
How to confirm this is the problem
Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.
- ✓Check finiteness before and after backward and the optimizer update to narrow the failing stage.
- ✓Confirm representative steps remain finite and validation behavior is acceptable after the change.
Root cause
- Unconfirmed until the earliest invalid operation and relevant inputs, gradients and optimizer state are inspected.
The fix and how to prevent it
How to fix it
- Preserve the first affected step, loss inputs, unscaled gradient measurements and optimizer settings.
- Reproduce a bounded failing step with framework anomaly diagnostics where appropriate; account for their runtime overhead.
- For finite but excessive norms, evaluate recipe-appropriate clipping with correct AMP ordering. Clipping is not a repair for NaN or infinite state.
- Change one supported factor at a time and compare training and validation behavior. Resume only from independently validated compatible state.
How to prevent it
- Retain gradient and loss diagnostics around instability rather than assigning every NaN to a high learning rate.
Save this diagnosis and catch the next crash automatically
All root cause, fix, and prevention steps above are free to read. Create a free account with any email or GitHub to keep your saved diagnosis history across the encyclopedia and run cloud checks, or use a work email below for the 30-day Team evaluation. No card required.
Or start a 30-day free Team trial (work email)
Verified work email unlocks all 14 fleet diagnostic tools, Slack alerts, and team history for 30 days. No card and no automatic charge.
Diagnose your own log automatically
The root cause and fix steps above stay free. Create a free account to analyze full job logs, attribute the first failed rank, and keep saved incident history.
Sign up free. Analyze your cluster logsNo credit card. Daily allowance follows verified trust tier. Instant access.
Why the recommended fix works
Locating the first invalid computation supports a specific correction instead of hiding the symptom with an arbitrary clipping threshold.
Diagnostic note
“No universal gradient threshold or guaranteed convergence result is claimed.”
Diagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to inspect matched failure patterns, supporting evidence and next checks without uploading the log. Verify recommendations against your workload before changing production.
Install the free VS Code extensionRelated failures to investigate next
Frequently asked questions
Questions engineers and on-call staff commonly ask about this failure.
Can clipping fix NaN gradients?
Don't just read the fix, diagnose your run
The encyclopedia explains documented failure patterns. Denpex investigates your logs, configuration and stack, shows the supporting evidence, and asks for missing details when needed.