Skip to content

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.

Quick answer

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.
Training Stability#gradient-explosion#gradient-clipping#training-stability#rnn#transformer

What this failure is

Excessive gradient magnitude during backward computation, distinct from every other cause of a non-finite loss.

Live diagnosis, no signup

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.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free cloud diagnoses per day

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.

SymptomPossible explanation
Rapid growth in measured unscaled gradient normsUnconfirmed until the earliest invalid operation and relevant inputs, gradients and optimizer state are inspected.
Non-finite gradients, requiring investigation of the first invalid operationUnconfirmed 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.

Use your company email, for example alex@yourcompany.com.

Who qualifies?

Company email domains activate the free 30-day Team evaluation (up to 50 diagnoses a day) after an email and domain check, whatever mail provider you use. If we cannot verify your domain automatically, support reviews it: write to support@denpex.com. Free local diagnosis in the editor extension needs no account.

Using a personal email (Gmail, Outlook, Naver, QQ) or solo cluster? Create a free $0 account (no work email required) to save 7-day history and unlock AI fallback, or send a cluster crash log for a live walkthrough.
Already have an account? Sign in

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 logs

No 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 extension

Frequently asked questions

Questions engineers and on-call staff commonly ask about this failure.

Can clipping fix NaN gradients?
Do not treat clipping as a repair for non-finite state. Find the first invalid operation and validate any recovery checkpoint separately.

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.