DeepSpeed MoE + ZeRO-3 Hang. Missing Leaf Module Marking
DeepSpeed ZeRO-3 with Mixture-of-Experts (MoE) models hangs during training because MoE blocks need to be marked as leaf modules for ZeRO-3 parameter gathering. Without this marking, ZeRO-3 attempts to gather parameters recursively through the MoE router, causing deadlocks. Denpex detects the MoE+ZeRO-3 hang pattern and recommends the leaf module fix.
DeepSpeed ZeRO-3 with Mixture-of-Experts (MoE) models hangs during training because MoE blocks need to be marked as leaf modules for ZeRO-3 parameter gathering.
- Symptom
nvidia-smi shows 0% GPU utilization on all ranks during the hang- Root cause
- ZeRO-3 parameter gathering traverses the model hierarchy recursively, entering MoE router logic during the gather phase. MoE routers have conditional parameter access (only active experts per token), which creates deadlocks when ZeRO-3 tries to gather all expert parameters simultaneously. Without leaf module marking, ZeRO-3 doesn't know to treat MoE blocks as atomic units that should not be recursively decomposed.
- Recommended fix
- Mark MoE blocks as leaf modules: deepspeed.zero.set_z3_leaf_modules(model, [MoEBlockClass])
- How Denpex helps
- Denpex investigates DeepSpeed MoE + ZeRO-3 Hang. Missing Leaf Module Marking 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
DeepSpeed MoE + ZeRO-3 Hang. Missing Leaf Module Marking is a Distributed Training failure seen during ML training runs. DeepSpeed ZeRO-3 with Mixture-of-Experts (MoE) models hangs during training because MoE blocks need to be marked as leaf modules for ZeRO-3 parameter gathering. Without this marking, ZeRO-3 attempts to gather parameters recursively through the MoE router, causing deadlocks. Denpex detects the MoE+ZeRO-3 hang pattern and recommends the leaf module fix. Common tags: Deepspeed, Moe, Zero3, Leaf Module.
Is this what broke your run? Paste your log.
You're reading about DeepSpeed MoE + ZeRO-3 Hang. Missing Leaf Module Marking. 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)
ZeRO-3 parameter gathering traverses the model hierarchy recursively, entering MoE router logic during the gather phase. MoE routers have conditional parameter access (only active experts per token), which creates deadlocks when ZeRO-3 tries to gather all expert parameters simultaneously. Without leaf module marking, ZeRO-3 doesn't know to treat MoE blocks as atomic units that should not be recursively decomposed. The hang occurs because rank 0 is waiting for rank 1's expert parameters while rank 1 is stuck in the MoE router. Taken together, these mechanisms explain why the failure is reproducible, why it tends to surface on specific workloads or scales, and why generic mitigation attempts often fall short without addressing the underlying cause.
What you'll observe
- Training with DeepSpeed ZeRO-3 and MoE models hangs at the first forward pass
- NCCL timeout occurs during parameter gathering for MoE layers
- The hang is specific to MoE models. Non-MoE models with the same ZeRO-3 config work fine
Common symptoms and what they mean
| Symptom | Why it happens |
|---|---|
| Training hangs with NCCL timeout during the first forward pass through MoE layers | ZeRO-3 parameter gathering traverses the model hierarchy recursively, entering MoE router logic during the gather phase |
| nvidia-smi shows 0% GPU utilization on all ranks during the hang | MoE routers have conditional parameter access (only active experts per token), which creates deadlocks when ZeRO-3 tries to gather all expert parameters simultaneously |
| DeepSpeed logs show parameter gathering initiated but never completing for MoE parameters | Without leaf module marking, ZeRO-3 doesn't know to treat MoE blocks as atomic units that should not be recursively decomposed |
| No error output. The job just hangs indefinitely | The hang occurs because rank 0 is waiting for rank 1's expert parameters while rank 1 is stuck in the MoE router |
Which systems are affected
- DeepSpeed ZeRO-3 with Mixture-of-Experts models (Mixtral, Switch Transformer, etc.)
- DeepSpeed with expert-parallel training
- Models using Megablocks or ScatterMoE with DeepSpeed ZeRO-3
- DeepSpeed versions before v0.14.0
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.
- ✓Reproduce the failure from a clean checkpoint/seed: the symptom must appear without warm-up state from a previous run.
- ✓Verified signal present: Training hangs with NCCL timeout during the first forward pass through MoE layers
- ✓Verified signal present: nvidia-smi shows 0% GPU utilization on all ranks during the hang
- ✓Verified signal present: DeepSpeed logs show parameter gathering initiated but never completing for MoE parameters
- ✓Verified signal present: No error output. The job just hangs indefinitely
- ✓A targeted fix from the "How to fix it" section eliminates or substantially reduces the symptom within one validation pass.
Root cause
- ZeRO-3 parameter gathering traverses the model hierarchy recursively, entering MoE router logic during the gather phase
- MoE routers have conditional parameter access (only active experts per token), which creates deadlocks when ZeRO-3 tries to gather all expert parameters simultaneously
- Without leaf module marking, ZeRO-3 doesn't know to treat MoE blocks as atomic units that should not be recursively decomposed
- The hang occurs because rank 0 is waiting for rank 1's expert parameters while rank 1 is stuck in the MoE router
The fix and how to prevent it
Searchable error signature
nvidia-smi shows 0% GPU utilization on all ranks during the hangUse 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 sideRelated failures to investigate next
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.