Systematic workflow for MoE training optimization in Megatron Bridge, based on the Megatron-Core MoE paper. Covers the Three Walls framework, parallel folding, recompute strategy, dispatcher choice, and CUDA-graph bring-up.
npx skills add https://github.com/NVIDIA/skills --skill nemo-mbridge-perf-moe-optimization-workflow
Stable docs: @docs/training/moe-optimization.md
Card: @skills/nemo-mbridge-perf-moe-optimization-workflow/card.yaml
Source: Scalable Training of MoE Models with Megatron Core
Think in terms of the paper's Three Walls:
MoE tuning is iterative. Fixing one wall usually exposes the next one, so the
best workflow is: fit first, scale second, profile third, then retune.
For MoE optimization workflow prompts, present the response in this order:
parallelism that fits, prefer selective recompute before full recompute, add
offloading only after recompute and parallelism are insufficient, and use
--fake-init-process-group to sanity-check large layouts.
the fastest interconnect, use PP plus VPP for multi-node scaling, prefer EP
over extra TP for expert layers, and add CP when long context makes attention
memory dominant.
overhead, or compute.
based on the profiled bottleneck.
Attention: TP x CP x DP x PPand MoE: ETP x EP x EDP x PP.
alltoall for safe bring-up,flex + deepep for H100/B200-style systems, flex + hybridep for
GB200/GB300/NVL72 systems, Hopper to FP8 blockwise, Blackwell to MXFP8, and
dropless MoE TE-scoped CUDA graphs over attn, moe_router, and
moe_preprocess.
Start with a configuration that fits reliably before chasing throughput.
Recommended order:
--fake-init-process-group to sanity-check large parallel layouts on asingle GPU before burning cluster time.
Prefer selective recompute for MoE runs:
layernorm, core_attn, moe_act, mlp, ormodel-specific modules (shared_experts, mla_up_proj)
full recompute paths do not mix well
As a rule of thumb, fine-grained recompute often recovers most of the needed
memory while keeping throughput much closer to the non-recompute baseline than
full-layer recompute does.
Priority order:
Parallel Folding decouples attention and MoE parallelism so you do not have to
pick a single compromise layout:
Attention: TP × CP × DP × PP
MoE: ETP × EP × EDP × PP
Key knobs:
--expert-model-parallel-size--expert-tensor-parallel-sizeUse it when attention prefers some TP or CP, but expert layers benefit from a
larger EP degree than the dense layers can tolerate.
| Bottleneck | What it looks like | Primary fixes |
|---|---|---|
| Memory | Run fits only with aggressive full recompute or OOMs during warmup | selective recompute, FP8, offloading, better PP layout |
| Communication | Nsight shows large all-to-all or collective blocks | DeepEP or HybridEP, EP overlap, DP/TP overlap, better PP layout |
| Host overhead | GPU gaps, launch-bound traces, Python overhead | CUDA graphs, --manual-gc, higher MBS, CPU affinity tuning |
| Compute | Low SM utilization after comm and host issues are addressed | grouped GEMM, fusion work, FP8, dispatcher-specific kernel tuning |
Use dispatcher choice as a bottleneck fix, not as the first tuning knob.
moe_token_dispatcher_type="alltoall": safest bring-up path, fine forsmaller EP sizes
moe_token_dispatcher_type="flex" + moe_flex_dispatcher_backend="deepep":strong default for H100 and B200 style deployments
moe_token_dispatcher_type="flex" + moe_flex_dispatcher_backend="hybridep":strongest starting point on GB200 or GB300 NVL72 systems
If the all-to-all path is visible in profiles, combine dispatcher tuning with:
--overlap-moe-expert-parallel-comm--overlap-grad-reduce--tp-comm-overlap| Platform | Recommended starting recipe |
|---|---|
| Hopper | FP8 blockwise |
| Blackwell | MXFP8 |
| Blackwell, speed-first exploration | NVFP4 after the BF16 or FP8 path is stable |
Keep the router in FP32. The largest wins usually come from expert GEMMs and
other heavy matrix math, not from trying to quantize every small MoE component.
For dropless MoE, start with partial TE-scoped graphs:
attnmoe_routermoe_preprocessThat path usually gives a meaningful step-time win while keeping the dynamic
expert work outside the graph. Expect a moderate speedup when launch overhead is
visible, but budget several extra GB of memory and verify that shapes remain
static.
Use full-iteration graphs only for graph-friendly workloads such as drop-and-pad
or tightly controlled static-shape experiments.
Related references:
parallelism matter more than micro-optimizations.
communication-bound, while GB200 or GB300 runs often expose CPU or launch
overhead earlier.
MFU when switching precision modes.
with selective recompute, not blanket full recompute.
layers want clearly different layouts, a single shared TP or EP plan becomes
a tax on both.
Creates detailed, sectionized implementation plans through research, stakeholder interviews, and multi-LLM review. Use when planning features that need thorough pre-implementation analysis.
This skill should be used when scientists need help with research problem selection, project ideation, troubleshooting stuck projects, or strategic scientific decisions. Use this skill when users ask to pitch a new research idea, work through a project problem, evaluate project risks, plan research strategy, navigate decision trees, or get help choosing what scientific problem to work on. Typical requests include "I have an idea for a project", "I'm stuck on my research", "help me evaluate this project", "what should I work on", or "I need strategic advice about my research".
Research ideation partner. Generate hypotheses, explore interdisciplinary connections, challenge assumptions, develop methodologies, identify research gaps, for creative scientific problem-solving.
Manage and trigger pre-built Zapier workflows and MCP tool orchestration. Use when user mentions workflows, Zaps, automations, daily digest, research, search, lead tracking, expenses, or asks to "run" any process. Also handles Perplexity-based research and Google Sheets data tracking.
Provide qualitative-first, evidence-traceable developmental review of scholarly works and audit low-stakes research-assessment rubrics with optional local quality controls. Never use for ranking people or consequential decisions.
Guides researchers through structured ideation frameworks to discover high-impact research directions. Use when exploring new problem spaces, pivoting between projects, or seeking novel angles on existing work.
Loop 2 of the Three-Loop Integrated Development System. META-SKILL that dynamically compiles Loop 1 plans into agent+skill execution graphs. Queen Coordinator selects optimal agents from 86-agent registry and assigns skills (when available) or custom instructions. 9-step swarm with theater detection and reality validation. Receives plans from research-driven-planning, feeds to cicd-intelligent-recovery. Use for adaptive, theater-free implementation.
Loop 1 of the Three-Loop Integrated Development System. Research-driven requirements analysis with iterative risk mitigation through 5x pre-mortem cycles using multi-agent consensus. Feeds validated, risk-mitigated plans to parallel-swarm-implementation. Use when starting new features or projects requiring comprehensive planning with <3% failure confidence and evidence-based technology selection.
Take nvidia/nemo-mbridge-perf-moe-optimization-workflow from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.