Skip to main content
skill CX Codex

nemo-mbridge-perf-moe-comm-overlap — Claude Code skill for MoE comm

A skill for MoE expert-parallel communication overlap in Megatron Bridge: dispatch/combine, flex dispatcher backends, expert wgrad scheduling.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add NVIDIA/skills --skill nemo-mbridge-perf-moe-comm-overlap -a claude-code
Open on GitHub

What nemo-mbridge-perf-moe-comm-overlap does

The skill covers turning on MoE communication overlap in Megatron Bridge and tracing a throughput regression back to a comm-overlap config change. It ships a quick decision check, the prerequisite list, notes on how overlap interacts with recompute and CUDA graphs, and measured runs on Qwen3 30B-A3B.

Enablement is config work: cfg.comm_overlap.overlap_moe_expert_parallel_comm = True, optionally cfg.comm_overlap.delay_wgrad_compute = True, and cfg.model.moe_shared_expert_overlap set to False. You need expert_model_parallel_size > 1, num_moe_experts > 1, a dispatcher type of "alltoall" or "flex", and BF16 or FP16 precision. With pipeline parallelism active, VPP is required. Setting moe_flex_dispatcher_backend on its own does nothing — flex dispatch also needs moe_token_dispatcher_type = "flex".

Full recompute pairs badly with this path, so selective recompute is the safer choice. Validation is straightforward: the check in comm_overlap.py raises when prerequisites are not met, so a clean startup means the feature is live. A 16-H100 run cut step time by 15.059% and raised throughput by 17.729%, though the authors note the gain is workload-dependent and a small or lightly loaded EP run may see nothing.

What it helps with

  • turn on dispatch and combine overlap for expert-parallel MoE
  • trace a throughput drop back to a comm-overlap config change
  • work out why flex dispatch stays off after setting the backend flag
  • pair overlap with a recompute plan and CUDA-graph scopes
  • check prerequisites before committing to a full run

Example prompts for the agent

  • Enable overlap_moe_expert_parallel_comm and verify the prerequisites hold
  • Throughput dropped after my config change — check whether comm overlap is involved
  • Why is flex dispatch not active when I set moe_flex_dispatcher_backend

How to install nemo-mbridge-perf-moe-comm-overlap

1Skills CLI (Vercel)

npx skills add NVIDIA/skills --skill nemo-mbridge-perf-moe-comm-overlap -a claude-code

2Manually: put the files in place

~/.claude/skills/nemo-mbridge-perf-moe-comm-overlap/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/nemo-mbridge-perf-moe-comm-overlap/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about nemo-mbridge-perf-moe-comm-overlap

How do I install nemo-mbridge-perf-moe-comm-overlap in Claude?

Run npx skills add NVIDIA/skills --skill nemo-mbridge-perf-moe-comm-overlap -a claude-code. The skill then lives at ~/.claude/skills/nemo-mbridge-perf-moe-comm-overlap/SKILL.md.

What does nemo-mbridge-perf-moe-comm-overlap do?

It walks through MoE expert-parallel communication overlap in Megatron Bridge: dispatch and combine overlap, flex dispatcher backends, expert wgrad scheduling. Useful both for enabling overlap and for diagnosing a regression that came with a config edit.

What are the prerequisites for MoE communication overlap?

expert_model_parallel_size > 1, num_moe_experts > 1, a dispatcher type of "alltoall" or "flex", and BF16 or FP16 precision. When pipeline parallelism is active, VPP must be set.

Source text

SKILL.md · Apache-2.0
---
name: nemo-mbridge-perf-moe-comm-overlap
description: MoE expert-parallel communication overlap in Megatron Bridge. Covers dispatch/combine overlap, flex dispatcher backends, and expert wgrad scheduling.
license: Apache-2.0
when_to_use: Tuning MoE communication overlap, or tracing a MoE throughput regression to a comm-overlap config change; 'overlap_moe_expert_parallel_comm', 'MoE dispatch overlap', 'flex dispatcher', 'DeepEP overlap', 'expert wgrad scheduling'.
---

# MoE Communication Overlap

For the higher-level overview, see:

- @docs/training/communication-overlap.md
- @skills/nemo-mbridge-perf-moe-comm-overlap/card.yaml

## Quick Decision

Use MoE communication overlap when:

- `EP > 1`
- token dispatch or combine time is visible in the profile

Avoid turning it on as an early bring-up step. It is easier to validate after
the dispatcher, routing mode, and recompute plan are already stable.

## Enablement

```python
cfg.comm_overlap.overlap_moe_expert_parallel_comm = True

# Optional: delayed wgrad for additional overlap
cfg.comm_overlap.delay_wgrad_compute = True

# IMPORTANT: disable shared expert overlap when using dispatch overlap
cfg.model.moe_shared_expert_overlap = False
```

### Prerequisites

- `expert_model_parallel_size > 1`
- `num_moe_experts > 1`
- `moe_token_dispatcher_type` must be `"alltoall"` or `"flex"`
- Precision: BF16 or FP16
- If PP is used, VPP (`virtual_pipeline_model_parallel_size`) must be set (non-`None`)

### Flex dispatcher activation

Setting `moe_flex_dispatcher_backend` alone does **not** activate flex dispatch.
You must also set `moe_token_dispatcher_type = "flex"`.

## Recompute And CUDA Graph Interaction

- Full recompute is not a good companion for the overlap path.
- `delay_wgrad_compute` adds further constraints if CUDA-graph scopes include
  attention or MoE-router work.
- In practice, selective recompute is the safer pairing when overlap is enabled.

## Measured Evidence

### HybridEP production-shape validation

A 2026-07-25 controlled Qwen3 30B-A3B pretraining comparison used 16 H100
GPUs, BF16, sequence length 4096, `TP=1`, `PP=1`, `CP=1`, `EP=16`,
`MBS=1`, `GBS=1024`, forced-balanced routing, HybridEP, and Transformer
Engine CUDA-graph scopes `moe_router` and `moe_preprocess`. The only
performance change was plain EP overlap; delayed wgrad stayed disabled.

| Case | Steady window | Step time | Model TFLOPS/GPU |
|---|---:|---:|---:|
| EP overlap off | iterations 5-20 | 24.7138s | 244.039 |
| EP overlap on, search run | iterations 5-20 | 21.0725s | 286.208 |
| EP overlap on, independent validation | iterations 41-50 | 20.9920s | 287.305 |

The independent result reduced step time by 15.059% and increased throughput
by 17.729% over the reproduced baseline. Loss remained finite, no iterations
were skipped or NaN, and rank-0 peak allocated memory was 62.166 GiB.

A same-method rank-0 Nsight Systems comparison captured 463,348 kernels in
each case:

| Profile metric | Overlap off | Overlap on |
|---|---:|---:|
| Communication concurrent with GEMM/attention | 9.079ms | 3,958.997ms |
| Communication time hidden by compute | 0.11% | 36.55% |
| GPU-active interval union | 22.821s | 21.221s |
| HybridEP dispatch-with-permute NVTX | 4.253s | 1.767s |
| HybridEP metadata-preprocess NVTX | 3.109s | 0.670s |

This is direct evidence that the gain came from hiding exposed HybridEP
dispatch/combine work, not from changing the dispatcher, routing, graph
scopes, batch shape, or parallel layout.

### Correctness-first alltoall smoke

A 2026-05-18 current-main H100 x16 smoke on Qwen3 30B-A3B mock pretraining
used `EP=16`, `alltoall`, global batch size 1024, CUDA graphs disabled, and
`moe_permute_fusion=false` because the PyTorch 25.11 / TE / Triton stack failed
in Transformer Engine fused permutation in prior bring-up.

Results were directional rather than release-grade:

- no EP overlap: 41.25s steady-state mean over iterations 3-8
- EP overlap: 31.31s steady-state mean over iterations 3-8
- EP overlap plus `delay_wgrad_compute`: 31.20s steady-state mean over
  iterations 3-8

Treat this as evidence that EP overlap can help an inter-node `alltoall` MoE
shape when communication is exposed. It is not proof that delayed wgrad is a
separate win, and it does not validate the fused permutation path. An earlier
2026-05-16 short smoke on the same shape showed the same pattern.

## Code Anchors

- Overlap validation: `src/megatron/bridge/training/comm_overlap.py`
- Flex dispatcher backend: `src/megatron/bridge/training/flex_dispatcher_backend.py`
- Config: `src/megatron/bridge/training/config.py`
- Unit tests: `tests/unit_tests/training/test_comm_overlap.py`
- DeepEP tests: `tests/unit_tests/training/test_deepep.py`

## Pitfalls

1. **Shared expert overlap conflict**: `moe_shared_expert_overlap` and
   `overlap_moe_expert_parallel_comm` can conflict. Disable shared expert
   overlap when using the dispatch overlap path.

2. **PP without VPP**: MoE overlap requires VPP when pipeline parallelism is
   active. Without it, the overlap scheduling cannot interleave correctly.

3. **Flex != backend flag**: `moe_flex_dispatcher_backend="deepep"` alone
   does nothing if `moe_token_dispatcher_type` is still `"alltoall"`.

4. **Conservative recipe defaults**: Most public recipes leave MoE overlap
   disabled. You need to explicitly enable it via overrides.

5. **Performance gains are workload-dependent**: overlap helps most when dispatch
   communication is already a visible slice of step time. It is not guaranteed
   to help every small or lightly loaded EP run.

6. **Summed kernel time is not wall time**: concurrent kernels can run longer
   because they contend for SMs or bandwidth, so overlap may increase summed
   per-stream kernel duration while reducing the exposed interval union and
   end-to-end step time.

## Verification

Look for overlap-related log messages during initialization. The comm overlap
validation in `comm_overlap.py` will raise if prerequisites are not met, so a
clean startup confirms the feature is active.

For a short performance-harness smoke, keep the command shape explicit and vary
only one overlap knob at a time:

```bash
uv run python scripts/performance/run_script.py \
  -m qwen \
  -mr qwen3_30b_a3b \
  --task pretrain \
  -g h100 \
  -c bf16 \
  -ng 16 \
  -gn 8 \
  --max_steps 8 \
  --cuda_graph_impl none \
  --moe_flex_dispatcher_backend None \
  --moe_a2a_overlap false \
  --tokenizer_type NullTokenizer \
  comm_overlap.overlap_moe_expert_parallel_comm=true \
  comm_overlap.delay_wgrad_compute=false \
  model.moe_shared_expert_overlap=false
```

If fused MoE permutation fails during bring-up, add
`model.moe_permute_fusion=false` to separate overlap timing from runtime-stack
validation, then retest with the matched production container.

For performance validation, use an unprofiled steady window as the acceptance
metric. Use a matched Nsight A/B to establish causality:

1. Keep dispatcher, routing, CUDA graphs, batch shape, parallelism, and runtime
   fixed.
2. Toggle only `overlap_moe_expert_parallel_comm`; keep
   `delay_wgrad_compute=false` for the first isolation.
3. Compare communication and compute interval unions and their intersection,
   not only summed kernel durations.
4. Report steady step time, model TFLOPS/GPU, loss finiteness, skipped/NaN
   iterations, and peak allocated memory.

_Last signature refresh: 2026-08-03._

© NVIDIA · Apache-2.0 · NVIDIA/skills

Similar skills

Everything for AI and ML →

From the same set178

nemo-rl-docs This skill hands your agent the documentation rules for NeMo-RL: keeping docs/index.md current and writing docstrings in Google style. Useful when you touch the docs. CX Codex +1 1,800installs nemo-mbridge-resiliency A skill covering resiliency setup in Megatron Bridge: fault tolerance, straggler detection, preemption and re-run state machine. CX Codex +1 1,800installs nemo-mbridge-perf-hierarchical-context-parallel Configures hierarchical context parallelism in Megatron-Bridge. Useful for scaling long-sequence model training when context length exceeds KV head counts. CX Codex +1 1,800installs nemo-mbridge-perf-moe-hardware-configs A reference of MoE training starting configurations for H100, B200, GB200, and GB300. Use it when selecting a dispatcher, parallelism layout, or planning throughput checks. CX Codex +1 1,800installs nemo-mbridge-perf-moe-long-context Guides context parallelism sizing and selective recompute for long-context MoE training in Megatron Bridge. CX Codex +1 1,800installs nemo-mbridge-perf-expert-parallel-overlap A skill for enabling and validating MoE expert-parallel communication overlap in Megatron-Bridge, covering alltoall and flex dispatchers with DeepEP and HybridEP. CX Codex +1 1,800installs nemo-mbridge-perf-cpu-offloading A skill that validates and enables CPU offloading in Megatron Bridge: layer-level activation offloading and optimizer state offloading via HybridDeviceOptimizer. CX Codex +1 1,800installs nemo-mbridge-perf-moe-optimization-workflow Guides MoE throughput tuning and regression diagnosis in Megatron Bridge. Useful when diagnosing speed drops after commit or configuration changes. CX Codex +1 1,800installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor