Generated banner for Nemo Mbridge Perf Moe Optimization Workflow
Generated logo for Nemo Mbridge Perf Moe Optimization Workflow

Nemo Mbridge Perf Moe Optimization Workflow

NVIDIAOfficialPublished by NVIDIA

  • Skill
  • Guidelines
  • Software development
  • Apache-2.0
  • Medium risk

From the author

Evidence-gated workflow for MoE performance optimization in Megatron Bridge. Covers measurement contracts, the Three Walls framework, parallel folding, profiling, matched A/B tuning, and final validation.
— the description by NVIDIA

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a rigorous, iterative methodology for tuning MoE training performance. It centers on the Three Walls framework (memory, communication, compute-efficiency) to diagnose bottlenecks and mandates a strict measurement contract to ensure valid A/B testing. The workflow guides users through fitting the model, scaling parallelism, profiling bottlenecks, and applying targeted optimizations like dispatcher tuning, overlap, and precision adjustments, concluding with a validation phase to confirm performance gains.

What it does

  • Defines a measurement contract to ensure consistent, valid performance comparisons.
  • Provides a step-by-step sequence for fitting, scaling, and tuning MoE models.
  • Categorizes performance bottlenecks into memory, communication, host, and compute walls.
  • Offers guidance on Parallel Folding to decouple attention and MoE parallelism.
  • Details how to validate optimizations using matched A/B profiles and steady-state metrics.
  • Outlines best practices for dispatcher selection, overlap, and precision tuning.

When to use it

  • When performing a full MoE throughput tuning sweep.
  • When diagnosing a throughput regression after a configuration or code change.
  • When needing to resolve memory, communication, or compute bottlenecks in MoE training.
  • When preparing evidence for performance optimization claims.

Advantages

  • Reduces trial-and-error by enforcing a logical, evidence-based optimization order.
  • Prevents invalid comparisons through strict measurement contract requirements.
  • Provides specific strategies for complex MoE-specific challenges like Parallel Folding.
  • Helps distinguish between training-equivalent and benchmark-only optimizations.

Usage examples

“How do I start optimizing the throughput of my MoE model?”
The agent will guide you to first freeze your measurement contract, then ensure the model fits in memory, scale parallelism, and finally profile the dominant bottleneck.
“My MoE training run is hitting a communication wall. What should I do?”
The agent will suggest investigating dispatcher backends like DeepEP or HybridEP, and testing overlap configurations based on your specific topology.
“How do I validate that my MoE performance optimization actually worked?”
The agent will instruct you to run at least 50 steps, verify that the intended kernels were active, and compare steady-state metrics against a matched baseline.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/nvidia/nemo-mbridge-perf-moe-optimization-workflow/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip nemo-mbridge-perf-moe-optimization-workflow.zip -d .agents/skills

Documentation by NVIDIA

MoE Training 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

Quick Reference

Start with the paper's Three Walls:

  • memory wall

  • communication wall

  • compute-efficiency wall

For operational diagnosis, split the compute-efficiency wall into compute and host/launch bottlenecks. They need different evidence and different fixes. MoE tuning is iterative, so use this order:

freeze the measurement contract -> fit -> scale -> profile -> retune -> validate

First Answer Checklist

For MoE optimization workflow prompts, present the response in this order:

  1. Freeze the measurement contract: record the exact model and task, hardware and topology, container and commits, data and routing semantics, precision, sequence and batch shape, parallelism, graph scopes, and the steady-state metric window. Label each candidate as training-equivalent or benchmark-only.

  2. Fit: make the model memory-feasible first. Use the smallest model 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.

  3. Scale: maximize DP after the model fits, keep hot communication inside 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.

  4. Profile: identify the dominant wall: memory, communication, host overhead, or compute.

  5. Retune: change one variable at a time based on the profiled bottleneck. Dispatcher, overlap, lower precision, CUDA graphs, and recompute are candidates, not hardware defaults.

  6. Validate: use short matched screens to reject candidates, then run the winner for at least 50 steps. Verify the requested backend or graph replay actually ran, time a declared post-warmup window, and report loss health, skipped/NaN iterations, memory, step time, and model TFLOPS/GPU.

  7. Include the exact Parallel Folding meshes: Attention: TP x CP x DP x PP and MoE: ETP x EP x EDP x PP.

  8. Use alltoall for safe bring-up, then A/B flex + deepep and flex + hybridep when their packages and target topology support them. Start from BF16 and eager execution; introduce lower precision or the narrowest useful CUDA-graph scope only after profiling justifies it.

Phase 0: Freeze The Measurement Contract

A comparison is valid only when the following stay fixed unless they are the single variable under test:

  • Bridge, MCore, Transformer Engine, container, CUDA, and NCCL versions

  • GPU count, SKU, node topology, and launcher/environment settings

  • model, task, data path, sequence length, MBS, GBS, and optimizer settings

  • TP, PP, VPP, CP, EP, ETP, and DP layout

  • routing semantics, precision, recompute, dispatcher, overlap, and graph scope

  • warmup and steady-state timing windows

Separate two acceptance classes:

  • Training-equivalent changes preserve the intended routing, loss, data, optimizer, and checkpoint/resume behavior.

  • Benchmark-only changes such as forced load balancing are useful for controlled kernel studies, but cannot establish production-training correctness or convergence.

Phase 1: Make The Run Memory-Feasible

Start with a configuration that fits reliably before chasing throughput.

Recommended order:

  1. Use the smallest amount of model parallelism that still fits.

  2. Turn on selective recompute before falling back to full recompute.

  3. Add offloading only when recompute and parallelism are still insufficient.

  4. Use --fake-init-process-group to sanity-check large parallel layouts on a single GPU before burning cluster time.

Recompute guidance

Prefer selective recompute for MoE runs:

  • good first choices: layernorm, core_attn, moe_act, mlp, or model-specific modules (shared_experts, mla_up_proj)

  • use full recompute only when the run still does not fit

  • revisit recompute after enabling CUDA graphs, because some graph scopes and 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.

Phase 2: Choose Parallelism For Scale

Priority order:

  1. Maximize DP once the model fits.

  2. Keep the hot communication path inside the fast interconnect when possible.

  3. Use PP, plus VPP if needed, for multi-node scaling.

  4. Prefer EP over extra TP for expert layers.

  5. Add CP for long context once sequence length makes attention memory dominant.

Parallel Folding

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-size

Use it when attention prefers some TP or CP, but expert layers benefit from a larger EP degree than the dense layers can tolerate.

Phase 3: Profile The Dominant Bottleneck

BottleneckWhat it looks likePrimary fixes
MemoryRun fits only with aggressive full recompute or OOMs during warmupselective recompute, FP8, offloading, better PP layout
CommunicationNsight shows large all-to-all or collective blocksDeepEP or HybridEP, EP overlap, DP/TP overlap, better PP layout
Host overheadGPU gaps, launch-bound traces, Python overheadCUDA graphs, --manual-gc, higher MBS, CPU affinity tuning
ComputeLow SM utilization after comm and host issues are addressedgrouped GEMM, fusion work, FP8, dispatcher-specific kernel tuning
Profile overlap without misreading it

Use unprofiled steady iterations for the acceptance metric and a matched profile for causal explanation:

  1. Change one overlap or dispatcher variable at a time; keep routing, graph scopes, parallelism, batch shape, and runtime fixed.

  2. Build interval unions for communication kernels and compute kernels, then measure their intersection to quantify hidden communication.

  3. Do not add kernel durations and call the result wall time. Concurrent kernels may run longer because of SM or bandwidth contention even while the exposed GPU-active union and end-to-end step time fall.

  4. Corroborate the trace with dispatch/combine NVTX ranges, steady step time, model TFLOPS/GPU, loss finiteness, skipped/NaN counts, and peak memory.

On a controlled 16×H100 Qwen3 30B-A3B HybridEP run, plain EP overlap increased communication hidden by GEMM/attention from 0.11% to 36.55%. The unprofiled step fell from 24.7138s to 20.9920s and throughput rose from 244.039 to 287.305 model TFLOPS/GPU. delay_wgrad_compute remained disabled.

Phase 4: Retune From Evidence

Choose the smallest candidate that targets the profiled bottleneck and change one variable at a time.

Dispatcher And Overlap Guidance

Use dispatcher choice as a bottleneck fix, not as a hardware lookup table.

  • moe_token_dispatcher_type="alltoall": safest bring-up path, fine for smaller EP sizes

  • moe_token_dispatcher_type="flex" + moe_flex_dispatcher_backend="deepep": candidate when DeepEP is installed and communication is exposed

  • moe_token_dispatcher_type="flex" + moe_flex_dispatcher_backend="hybridep": topology-sensitive candidate on both NVL8 and NVL72 systems when HybridEP is installed

HybridEP plus plain EP overlap is the current measured winner for the canonical 16×H100 Qwen3 30B-A3B shape, while the canonical 256×H100 Qwen3 235B recipe uses standard alltoall plus overlap. Benchmark backend compatibility and throughput in the target container; neither GPU name nor EP degree determines the winner by itself.

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

Test plain EP overlap, shared-expert overlap, and delayed weight-gradient compute as separate candidates first. A combination can regress even when one component helped on another model.

Lower-Precision Candidate Matrix

Start with a verified BF16 baseline. Hardware capability only determines which lower-precision candidates are legal; it does not guarantee a speedup.

PlatformCandidate after BF16 is stable
Hopperper-tensor, current-scaling, or blockwise FP8 supported by the target stack
BlackwellMXFP8 or another supported FP8 recipe
Blackwell, speed-first explorationNVFP4 after the BF16/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. Require logs or traces showing that the intended kernels ran, and judge the candidate by end-to-end steady step time rather than theoretical peak FLOPS.

CUDA Graphs For MoE

Use CUDA graphs only after a profile shows meaningful host/launch gaps. For dropless MoE, start with the narrowest partial TE-scoped graph candidate:

  • moe_router

  • moe_preprocess

Add attn only if it is supported for the model and improves the same matched stack. A successful capture is not evidence of a speedup, and a graph win can disappear after dispatcher, overlap, or precision changes.

This path keeps dynamic expert work outside the graph. Budget extra memory, verify that shapes remain static, confirm replay rather than capture alone, and time only post-capture iterations.

Use full-iteration graphs only for graph-friendly workloads such as drop-and-pad or tightly controlled static-shape experiments.

Related references:

  • @skills/nemo-mbridge-perf-cuda-graphs/SKILL.md

  • @docs/training/cuda-graphs.md

  • @docs/training/activation-recomputation.md

Phase 5: Validate And Package Evidence

Use 6–12 post-warmup iterations for inexpensive screening when the workload allows it. For the selected candidate, run at least 50 steps and report a fixed steady window such as steps 41–50. The final evidence bundle should contain:

  • exact command/config diff, commits, container, hardware, and topology

  • declared routing/data semantics and training-equivalent vs benchmark-only label

  • proof that the intended dispatcher, precision kernels, overlap, and graph replay were active

  • step time and model TFLOPS/GPU from the same unprofiled steady window

  • finite loss, skipped/NaN counts, peak memory, and checkpoint/optimizer-state validation when the production path requires it

  • matched A/B profile evidence for the claimed causal mechanism

Do not attribute the total gain of a final multi-change winner to one earlier A/B. For example, the Qwen3 overlap experiment isolated a rise from 244.039 to 287.305 TFLOPS/GPU; the later canonical recipe reached 299.352 after additional HybridEP tuning. They answer different questions.

Pitfalls

  1. Do not optimize in the wrong order: fitting the model and selecting sane parallelism matter more than micro-optimizations.

  2. Platform changes the limiting wall: H100-class runs often feel more communication-bound, while GB200 or GB300 runs often expose CPU or launch overhead earlier.

  3. FP8 MFU can look misleadingly low: compare absolute throughput as well as MFU when switching precision modes.

  4. CUDA graphs and recompute interact: TE-scoped graphs are usually paired with selective recompute, not blanket full recompute.

  5. Parallel Folding is not optional at large scale: once attention and expert layers want clearly different layouts, a single shared TP or EP plan becomes a tax on both.

  6. Summed kernel time is not exposed time: use interval unions and communication/compute intersection when validating overlap.

  7. Benchmark-only semantics are not production acceptance: forced routing, synthetic data, or disabled optimizer/checkpoint paths must be disclosed and validated separately from training-equivalent results.

  8. Feature activation needs evidence: a config dump is insufficient when a backend can fall back, a graph can capture without helping, or a lower- precision recipe can miss the intended kernels.

Last signature refresh: 2026-08-03.

Files

card.yaml

title: moe_optimization_workflow
validated_on: "2026-07-31"
summary: >
  Evidence-gated workflow for optimizing MoE training performance. It freezes
  a measurement contract, follows fit -> scale -> profile -> retune -> validate,
  operationalizes the paper's Three Walls as four diagnostic bottlenecks, and
  separates training-equivalent acceptance from benchmark-only experiments.

source: "https://arxiv.org/abs/2603.07685"
source_title: "Scalable Training of Mixture-of-Experts Models with Megatron Core"

validation_status:
  three_walls_framework:
    - documented
  optimization_workflow:
    - documented
  measurement_contract:
    - documented
  final_acceptance_gate:
    - documented
  parallel_folding:
    - documented
  memory_optimization_stack:
    - documented
  fp8_recipes:
    - documented
  cuda_graphs_moe:
    - documented
  dsv3_case_study:
    - measured
  qwen3_30b_h100_case_study:
    - measured
  overlap_profile_method:
    - measured

core_concepts:
  three_walls:
    memory:
      description: "All E experts stored but only K activate per token"
      key_metric: "GB per GPU"
      dsv3_example: "199.5 GB per GPU without optimization (PP4×VPP4×EP64, 256 GPUs)"
    communication:
      description: "EP all-to-all dispatches tokens across GPUs"
      key_metric: "% of step time"
      dsv3_example: "20-60% of step time depending on hardware topology"
    compute_efficiency:
      description: "Small expert GEMMs + host overhead"
      key_metric: "GPU SM utilization"
      dsv3_example: "GEMMs <50% of execution time vs ~70% in dense models"

  operational_bottlenecks:
    memory: "peak and reserved memory, OOM point, recompute/offload requirement"
    communication: "exposed collective intervals and communication/compute overlap"
    host_launch: "GPU gaps, launch rate, graph replay and CPU-side overhead"
    compute: "SM utilization and intended kernel/backend activation"

  parameter_compute_mismatch:
    description: >
      MoE total params scale with E (expert count) while per-token compute
      scales only with K (top-k). DSV3: 685B total, 37B active = 18× gap.
    implication: >
      More GPUs needed for memory, but per-token compute doesn't grow to
      match, leaving communication overhead exposed.

  parallel_folding:
    description: >
      Decouples attention and MoE parallelism. Attention uses TP×CP×DP×PP;
      MoE uses ETP×EP×EDP×PP. PP must match. Breaks EP≤DP constraint.
    key_benefit: "EP can exceed DP by folding across TP×CP groups"

optimization_phases:
  phase_0_contract:
    goal: "Freeze a comparable experiment and declare its semantic class"
    key_action: >
      Hold runtime, hardware, topology, task/data/routing, precision, batch
      shape, parallelism, graph scopes, and timing window fixed.
  phase_1_memory:
    goal: "Fit training in GPU memory"
    key_action: "Choose parallelism that keeps memory within GPU capacity"
    quick_test: "--fake-init-process-group for single-GPU emulation"
  phase_2_parallelism:
    goal: "Minimize communication overhead"
    guidelines:
      - "Minimize model parallelism, maximize DP"
      - "Keep EP×TP within NVLink domain"
      - "Use PP for multi-node scaling"
      - "Prefer EP over TP for experts (Parallel Folding)"
      - "Enable CP for sequences ≥ 8K"
  phase_3_bottleneck:
    goal: "Profile and apply targeted optimizations"
    approach: "Identify which wall dominates, apply targeted fix, re-profile"
  phase_4_retune:
    goal: "Screen one profile-driven variable at a time"
    candidates: "dispatcher, overlap, lower precision, CUDA graphs, recompute"
  phase_5_validate:
    goal: "Validate the complete winner"
    gate: >
      At least 50 steps, declared post-warmup window, actual backend/kernel/replay
      evidence, finite loss, skipped/NaN counts, memory, step time, and TFLOPS/GPU.

memory_techniques:
  - name: memory_efficient_permutation
    overhead: zero
    savings: "26 GB/GPU on DSV3"
    mechanism: "Absorbs routing weights into activations before FC2"
  - name: fp8_activations
    overhead: low
    savings: "16 GB/GPU on DSV3 (12% of activation budget)"
    mechanism: "Store linear layer inputs in FP8"
  - name: fine_grained_recompute
    overhead: "<5% compute"
    savings: "42 GB/GPU on DSV3"
    targets: "MLA up-proj (30.4 GB), LayerNorm (8.2 GB), SwiGLU (3.8 GB)"
  - name: fine_grained_offloading
    overhead: "1.6-2% throughput"
    savings: "10-18% memory"
    mechanism: "Module-level D2H/H2D with stream overlap"
  - name: optimizer_offloading
    overhead: "0.1-0.2s per iteration"
    savings: "15-20 GB/GPU on DSV3"
    best_on: "GB200 with NVLink-C2C"
  - name: fsdp_for_moe
    overhead: "communication"
    mechanism: "Dual DeviceMesh with zero-copy comms"

fp8_recipes:
  - name: per_tensor_fp8
    platform: "Hopper, Blackwell"
    granularity: "1 scale per tensor"
    use_for: "Starting point, migration to FP8"
  - name: blockwise_fp8
    platform: "Hopper"
    granularity: "128×128 blocks"
    use_for: "Candidate after a stable BF16 baseline; verify target kernels and step time"
  - name: mxfp8
    platform: "Blackwell"
    granularity: "1×32 elements"
    use_for: "High-priority candidate after a stable BF16 baseline"
  - name: nvfp4
    platform: "Blackwell"
    granularity: "16 elements, 2-level microscaling"
    use_for: "Maximum throughput on Blackwell"
    requires: "RHT, 2D scaling, stochastic rounding"

dsv3_case_study:
  gb200_config:
    gpus: 256
    parallelism: "TP1/PP4/EP64, VPP4"
    precision: MXFP8
    dispatcher: HybridEP
    cuda_graphs: enabled
    ep_overlap: disabled
    tflops: 1048
    dominant_bottleneck: "CPU overhead (after FP8 speeds up GEMMs)"
  h100_config:
    gpus: 1024
    parallelism: "TP2/PP8/EP64, VPP4"
    precision: FP8-Blockwise
    dispatcher: DeepEP
    cuda_graphs: disabled
    ep_overlap: enabled
    tflops: 368
    dominant_bottleneck: "Communication (cross-node EP all-to-all)"

qwen3_30b_h100_case_study:
  hardware: "16×H100"
  precision: BF16
  parallelism: "TP1/PP1/CP1/EP16"
  sequence_length: 4096
  batch: "MBS1/GBS1024"
  routing: force_balance
  dispatcher: HybridEP
  cuda_graph_scopes: "moe_router, moe_preprocess"
  delayed_wgrad_compute: false
  final_step_time_ms: 20147.290
  final_tflops: 299.352
  hybridep_num_sms: 32
  combine_chunk_tokens: 64
  earlier_overlap_ab:
    baseline_step_time_ms: 24713.800
    overlap_step_time_ms: 20992.030
    baseline_tflops: 244.039
    overlap_tflops: 287.305
    throughput_gain_percent: 17.729
    profile_comm_hidden_off_percent: 0.11
    profile_comm_hidden_on_percent: 36.55
  dominant_bottleneck: "Exposed HybridEP dispatch/combine communication"

key_lessons:
  - "Platform characteristics drive strategy, not just model architecture"
  - "Parallel Folding unlocks independent attention/MoE optimization"
  - "FP8 shifts bottleneck from memory/compute to CPU overhead"
  - "Optimization is iterative: solving one wall exposes another"
  - "Use unprofiled steady timing for acceptance and matched profiles for causality"
  - "Use interval unions and communication/compute intersection; summed concurrent kernel durations are not wall time"
  - "Hardware determines legal candidates, not the winning dispatcher or precision mode"
  - "Separate a one-variable causal A/B from the final multi-knob winner"
  - "Forced routing is benchmark-only and requires separate natural-routing validation"

evidence:
  - "arXiv:2603.07685 — Scalable Training of MoE with Megatron Core"
  - "Megatron-Core v0.16 benchmarks"
  - "DSV3 and Qwen3-235B empirical results"
  - "examples/model_verification_cards/qwen3-30b-a3b/card.yaml"
  - "src/megatron/bridge/perf_recipes/qwen/h100/qwen3_moe.py"

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Node.js

Security

What our scanner noticed· Medium risk

  • Large base64-encoded blobs

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
NVIDIA
Publisher
NVIDIA (Official)
Source
NVIDIA/skills · skills/nemo-mbridge-perf-moe-optimization-workflow · commit fce3cca
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE-APACHE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by NVIDIA or NVIDIA.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download nemo-mbridge-perf-moe-optimization-workflow.zip