MoE Pipeline Stage Asymmetry Hang
When using a custom `--pipeline-model-parallel-layout`, users may configure a pipeline stage to have zero MoE layers (e.g., placing all MoE layers in the middle stages). However, the logging/loss aggregation function `reduce_aux_losses_tracker_across_ranks` implicitly assumes all ranks in the pipeline group possess MoE layers and invokes an AllReduce across the entire pipeline group. The stage with 0 MoE layers bypasses the MoE loss logic and never joins the AllReduce, causing the other stages to hang forever waiting for it.
When using a custom `--pipeline-model-parallel-layout`, users may configure a pipeline stage to have zero MoE layers (e.
- Root cause
- When using a custom `--pipeline-model-parallel-layout`, users may configure a pipeline stage to have zero MoE layers (e.g., placing all MoE layers in the middle stages).
- Recommended fix
- Balance MoE Layers or Patch Reduction Group Ensure each PP stage has at least 1 MoE layer in your layout. If all stages participate in the MoE logic, the AllReduce will succeed. Alternatively, patch the Megatron code to use a custom NCCL communicator that only includes ranks containing MoE layers.
- How Denpex helps
- Denpex investigates MoE Pipeline Stage Asymmetry Hang 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
MoE Pipeline Stage Asymmetry Hang is a Model failure seen during ML training runs. When using a custom `--pipeline-model-parallel-layout`, users may configure a pipeline stage to have zero MoE layers (e.g., placing all MoE layers in the middle stages). However, the logging/loss aggregation function `reduce_aux_losses_tracker_across_ranks` implicitly assumes all ranks in the pipeline group possess MoE layers and invokes an AllReduce across the entire pipeline group. The stage with 0 MoE layers bypasses the MoE loss logic and never joins the AllReduce, causing the other stages to hang forever waiting for it. Common tags: Pipeline Configuration.
Is this what broke your run? Paste your log.
You're reading about MoE Pipeline Stage Asymmetry Hang. 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)
Users assume the layout is valid because the model builds and allocates memory without errors. The failure only hits during the specific synchronization point for auxiliary losses.
What you'll observe
- Process stuck in reduce_aux_losses_tracker_across_ranks
- NCCL timeout waiting on rank in pipeline group
Common symptoms and what they mean
| Symptom | Why it happens |
|---|---|
| Training initialization succeeds, but hangs indefinitely upon completing the first forward pass or when logging auxiliary losses. | When using a custom `--pipeline-model-parallel-layout`, users may configure a pipeline stage to have zero MoE layers (e.g., placing all MoE layers in the middle stages). However, the logging/loss aggregation function `reduce_aux_losses_tracker_across_ranks` implicitly assumes all ranks in the pipeline group possess MoE layers and invokes an AllReduce across the entire pipeline group. The stage with 0 MoE layers bypasses the MoE loss logic and never joins the AllReduce, causing the other stages to hang forever waiting for it. |
| Occurs specifically when using custom pipeline layouts with MoE models. | When using a custom `--pipeline-model-parallel-layout`, users may configure a pipeline stage to have zero MoE layers (e.g., placing all MoE layers in the middle stages). However, the logging/loss aggregation function `reduce_aux_losses_tracker_across_ranks` implicitly assumes all ranks in the pipeline group possess MoE layers and invokes an AllReduce across the entire pipeline group. The stage with 0 MoE layers bypasses the MoE loss logic and never joins the AllReduce, causing the other stages to hang forever waiting for it. |
Which systems are affected
- Megatron-LM
- Pipeline Parallelism
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.
- ✓Inspect the `--pipeline-model-parallel-layout` argument and cross-reference with where MoE layers are injected.
- ✓Use `py-spy` and check if ranks are blocked inside `reduce_aux_losses_tracker_across_ranks`.
- ✓Check if `--moe-router-load-balancing-type` implies aux loss calculation.
Root cause
- When using a custom `--pipeline-model-parallel-layout`, users may configure a pipeline stage to have zero MoE layers (e.g., placing all MoE layers in the middle stages). However, the logging/loss aggregation function `reduce_aux_losses_tracker_across_ranks` implicitly assumes all ranks in the pipeline group possess MoE layers and invokes an AllReduce across the entire pipeline group. The stage with 0 MoE layers bypasses the MoE loss logic and never joins the AllReduce, causing the other stages to hang forever waiting for it.
The fix and how to prevent it
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 extensionDon'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.