DeepSpeed ZeRO-3 Stale Sync during Grad Clipping
In ZeRO Stage 3, parameters and gradients are partitioned. When computing the global gradient norm for clipping, all ranks must synchronize their local norms. If there is a communication timeout, or if some ranks process empty partitions in a specific mixed-precision context, a rank might send uninitialized or stale gradient buffers containing NaNs. The global all-reduce aggregates these NaNs, causing the entire step to fail.
In ZeRO Stage 3, parameters and gradients are partitioned.
- Symptom
AssertionError: Gradient clipping returned NaN- Root cause
- In ZeRO Stage 3, parameters and gradients are partitioned. When computing the global gradient norm for clipping, all ranks must synchronize their local norms. If there is a communication timeout, or if some ranks process empty partitions in a specific mixed-precision context, a rank might send uninitialized or stale gradient buffers containing NaNs.
- Recommended fix
- Adjust DeepSpeed Bucket Sizes and Prefetching { "zero_optimization": { "stage": 3, "stage3_prefetch_bucket_size": 0, "use_multi_rank_bucket_allreduce": false } } Disabling prefetch and multi-rank bucket allreduce simplifies the communication graph, preventing the sync issues that lead to uninitialized buffers being aggregated.
- How Denpex helps
- Denpex matches DeepSpeed ZeRO-3 Stale Sync during Grad Clipping across every rank in a distributed run and reports which rank failed first, so you act on the initiating node instead of the loudest one.
What this failure is
DeepSpeed ZeRO-3 Stale Sync during Grad Clipping is a Software failure seen during ML training runs. In ZeRO Stage 3, parameters and gradients are partitioned. When computing the global gradient norm for clipping, all ranks must synchronize their local norms. If there is a communication timeout, or if some ranks process empty partitions in a specific mixed-precision context, a rank might send uninitialized or stale gradient buffers containing NaNs. The global all-reduce aggregates these NaNs, causing the entire step to fail. Common tags: Gradient Explosion.
Is this what broke your run? Paste your log.
You're reading about DeepSpeed ZeRO-3 Stale Sync during Grad Clipping. Paste your own crash log or traceback below and get the real root cause for YOUR run, not this generic entry. No account, no card. Logs are masked at ingress and never saved to account history.
Want 14 days on the Scale plan?
Request an evaluation code. A verified workplace organization activates up to 50 diagnoses a day, alerts, history, and follow-up questions. No credit card or automatic subscription.
Why it happens (the mechanism)
It looks like the model itself exploded due to hyperparameter choices, but the NaNs actually originated from a distributed communication bug where empty or un-synced buffers were reduced.
What you'll observe
- AssertionError: Gradient clipping returned NaN
- DeepSpeed gradient norm is NaN
Common symptoms and what they mean
| Symptom | Why it happens |
|---|---|
| Training halts abruptly with a deepspeed internal error when calculating the gradient norm for clipping. | In ZeRO Stage 3, parameters and gradients are partitioned. When computing the global gradient norm for clipping, all ranks must synchronize their local norms. If there is a communication timeout, or if some ranks process empty partitions in a specific mixed-precision context, a rank might send uninitialized or stale gradient buffers containing NaNs. The global all-reduce aggregates these NaNs, causing the entire step to fail. |
| Only occurs on multi-node setups running ZeRO-3, whereas ZeRO-2 might train perfectly fine. | In ZeRO Stage 3, parameters and gradients are partitioned. When computing the global gradient norm for clipping, all ranks must synchronize their local norms. If there is a communication timeout, or if some ranks process empty partitions in a specific mixed-precision context, a rank might send uninitialized or stale gradient buffers containing NaNs. The global all-reduce aggregates these NaNs, causing the entire step to fail. |
Which systems are affected
- DeepSpeed
- ZeRO-3
- PyTorch
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.
- ✓Disable gradient clipping temporarily; if training continues without NaNs (though unstable), the issue lies in the clipping synchronization.
- ✓Check NCCL logs for asynchronous timeouts or errors on specific ranks.
Searchable error signature
AssertionError: Gradient clipping returned NaNUse this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.
The fix and the prevention pattern
The root cause is on this page and stays free. A free account adds the exact remediation steps, saved history, and the fix on every entry in the encyclopedia.
Sign up free. Unlock the full analysisNo credit card. Daily allowance follows verified trust tier. Instant access.
Diagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to see the initiating rank, collateral failures, exact fix, and verification command without uploading the log.
Install the free VS Code extensionDeepSpeed errors in context
DeepSpeed changes when parameters, gradients and optimizer state are created, partitioned, gathered and offloaded. The hub separates ZeRO, memory, checkpoint and pipeline failures by lifecycle phase.
Compare every deepspeed error side by sideRoot cause
- In ZeRO Stage 3, parameters and gradients are partitioned. When computing the global gradient norm for clipping, all ranks must synchronize their local norms. If there is a communication timeout, or if some ranks process empty partitions in a specific mixed-precision context, a rank might send uninitialized or stale gradient buffers containing NaNs. The global all-reduce aggregates these NaNs, causing the entire step to fail.
The fix and how to prevent it
Evaluate Denpex on your own logs
Request a Scale evaluation code. A verified workplace organization activates 14 days with up to 50 diagnoses a day. Every account keeps its current diagnosis allowance and gets a verification path. No card or automatic subscription.
References
Don't just read the fix, diagnose your run
The encyclopedia tells you what went wrong. Denpex tells you what went wrong in YOUR training run. With your logs, your config, and your stack.