Generated banner for Nemo Mbridge Perf Parallelism Strategies
Generated logo for Nemo Mbridge Perf Parallelism Strategies

Nemo Mbridge Perf Parallelism Strategies

NVIDIAOfficialPublished by NVIDIA

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

From the author

Operational guide for choosing and combining parallelism strategies in Megatron Bridge, including sizing rules, hardware topology mapping, and combined parallelism configuration.
— the description by NVIDIA

AutoGineer summary

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

This skill provides a structured approach to selecting and combining parallelism strategies (TP, DP, PP, CP, EP) within the Megatron Bridge framework. It covers sizing heuristics based on model size, hardware topology, and sequence length, while clarifying the critical distinction between dense and MoE parallelism meshes. It includes essential formulas for calculating minimum GPU requirements and data parallel sizes, alongside common pitfalls to avoid during configuration.

What it does

  • Provides recommended parallelism configurations for dense and MoE models based on parameter count.
  • Defines hardware topology constraints for TP, PP, and DP scaling.
  • Offers guidance on scaling strategies for long-sequence models using CP and SP.
  • Corrects common misconceptions regarding minimum GPU count calculations for MoE models.
  • Details the interaction between dense and expert parallelism meshes.
  • Lists configuration pitfalls and verification steps for combined parallelism.

When to use it

  • When determining the initial parallelism strategy for a new model training run.
  • When troubleshooting OOM errors or performance regressions related to parallelism settings.
  • When sizing infrastructure for large-scale dense or MoE model training.
  • When optimizing communication overhead by aligning parallelism with hardware topology.

Advantages

  • Prevents common over-allocation errors in GPU sizing.
  • Provides clear, actionable heuristics for complex MoE configurations.
  • Emphasizes performance-critical constraints like NVLink domain boundaries.
  • Includes specific formulas for calculating DP and EDP sizes.

Usage examples

“How do I calculate the minimum number of GPUs for a 355B MoE model with PP=8 and EP=16?”
The agent will apply the formula PP * max(TP * CP, EP * ETP) to provide the correct minimum GPU count, explicitly warning against the incorrect product-based calculation.
“What is the recommended parallelism strategy for a 70B dense model on 64 GPUs?”
The agent will suggest a starting configuration of TP=8, PP=4, and DP=2, while advising to profile the first iteration for memory and communication performance.

Install

  1. Download the skill as a ZIP:

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

    mkdir -p .agents/skills && unzip nemo-mbridge-perf-parallelism-strategies.zip -d .agents/skills

Documentation by NVIDIA

Parallelism Strategy Selection Skill

For stable background on each parallelism type, see:

  • @docs/parallelisms.md

  • @skills/nemo-mbridge-perf-parallelism-strategies/card.yaml

Decision by Model Size

Dense models
Model sizeGPUsRecommended starting point
< 1B1-8DP only
1-10B8-16TP=2-4 + DP
10-70B16-64TP=4-8 + PP=2-4 + DP
70-175B64-256TP=8 + PP=4-8 + DP
175-500B256-1024TP=8 + PP=8-16 + CP=2 + DP
MoE models

MoE parallelism differs from dense models. Because only a fraction of parameters are active per token, TP can often stay at 1 or 2 — the active parameter shard already fits on a single GPU. EP is the primary scaling dimension, with PP handling cross-node layer distribution.

Model (total / active)TPPPEPNotes
OLMoE 7B / 1B118EP only, fits single node
Moonlight 16B / 3B218small TP for shared layers
DeepSeek-V2 236B / 21B1432no TP at all
GLM-4.5 Air 106B / 12B148no TP at all
Qwen3 30B-A3B424
GLM-4.5 355B / 32B2816
Qwen3 235B-A22B4168CP=2 for pretrain
DeepSeek-V3 671B / 37B21664TP=2, not 8
Kimi-K2 1T21632

Key patterns:

  • TP is sized by active params, not total params. A 671B MoE with 37B active needs far less TP than a 70B dense model.

  • EP scales with expert count. Common: EP = num_experts or num_experts / experts_per_gpu.

  • PP handles depth. Large MoE models use PP=8-16 across nodes.

  • ETP (expert tensor parallelism) is rarely used. Llama 4 is an exception (ETP=4).

These are starting points, not hard rules. Always profile the first iteration to verify memory and communication.

Decision by Hardware Topology

Single node with NVLink:

cfg.model.tensor_model_parallel_size = 8

Multiple nodes with InfiniBand:

cfg.model.tensor_model_parallel_size = 8
cfg.model.pipeline_model_parallel_size = N

Limited network (Ethernet):

cfg.model.tensor_model_parallel_size = 4
cfg.model.pipeline_model_parallel_size = M

The stable rule is: keep TP within a single NVLink domain. Use PP or DP for cross-node scaling. TP across nodes is almost always a performance loss.

Decision by Sequence Length

Sequence lengthRecommendation
< 2Kstandard TP + PP + DP
2K-8Kadd SP (sequence_parallel=True)
8K-32Kadd CP=2
32K+add CP=4-8, consider a2a+p2p for large CP

Combined Parallelism Enablement

3D parallelism (TP + PP + DP):

cfg.model.tensor_model_parallel_size = 4
cfg.model.pipeline_model_parallel_size = 4
cfg.model.sequence_parallel = True

4D parallelism (TP + PP + CP + DP):

cfg.model.tensor_model_parallel_size = 8
cfg.model.pipeline_model_parallel_size = 8
cfg.model.context_parallel_size = 2
cfg.model.sequence_parallel = True

MoE with EP + PP (e.g. DeepSeek-V2 236B on 128 GPUs):

cfg.model.tensor_model_parallel_size = 1
cfg.model.pipeline_model_parallel_size = 4
cfg.model.expert_model_parallel_size = 32
cfg.model.sequence_parallel = False

MoE with small TP + PP + EP (e.g. DeepSeek-V3 671B on 256 GPUs):

cfg.model.tensor_model_parallel_size = 2
cfg.model.pipeline_model_parallel_size = 16
cfg.model.expert_model_parallel_size = 64
cfg.model.sequence_parallel = True

DP size is always implicit:

data_parallel_size = world_size / (TP * PP * CP)        # dense path
expert_data_parallel_size = world_size / (PP * EP * ETP) # MoE path

Minimum GPU Count

The minimum GPUs needed to run a config (i.e. with DP=1, EDP=1) is not the product of all parallelism dimensions. The dense path uses a TP*CP-mesh and the MoE path uses an EP*ETP-mesh, and within each PP stage these two meshes share the same set of GPUs — they overlap, they don't multiply. Only PP stages multiply (they're disjoint slices of the model). So:

min_gpus = PP * max(TP * CP, EP * ETP)

Common simplification (WRONG): PP * TP * CP * EP * ETP. This over-allocates GPUs and shows up in many READMEs and slurm sizing tables. Don't propagate it.

The decoupling of attention and MoE parallelism (different mesh shapes for the dense and expert paths sharing the same PP-stage GPUs) is detailed in Pangu Ultra MoE (arXiv:2504.14960).

Examples
ConfigWrong (PP·TP·CP·EP·ETP)Correct (PP·max(TP·CP, EP·ETP))
PP=1, TP=2, CP=1, EP=8, ETP=1168 (1 node)
PP=1, TP=4, CP=1, EP=8, ETP=1328 (max(4, 8))
PP=1, TP=2, CP=2, EP=8, ETP=1328 (max(4, 8))
PP=1, TP=2, CP=4, EP=8, ETP=1648 (max(8, 8))
PP=2, TP=2, CP=1, EP=8, ETP=13216 (2 · max(2, 8))
PP=1, TP=2, CP=1, EP=4, ETP=2168 (max(2, 8))
Scaling above the minimum

Adding GPUs scales DP and/or EDP (the world_size must satisfy both equations simultaneously). At min_gpus the larger-mesh side has DP (or EDP) = 1 and the smaller side absorbs the slack.

Example — TP=2, CP=1, EP=8, ETP=1, PP=1:

  • 8 GPUs (min_gpus): dense DP = 8/2 = 4, MoE EDP = 8/8 = 1

  • 16 GPUs: dense DP = 8, MoE EDP = 2 → 2× global batch

  • 32 GPUs: dense DP = 16, MoE EDP = 4 → 4× global batch

When sizing slurm scripts, compute --nodes from min_gpus (or a multiple of it for higher throughput via DP/EDP).

When answering MoE sizing prompts, include this checklist:

  • compute min_gpus = PP * max(TP * CP, EP * ETP) with the requested values

  • explicitly reject the wrong PP * TP * CP * EP * ETP full product

  • give both DP formulas: dense world_size / (TP * PP * CP) and MoE world_size / (PP * EP * ETP)

  • mention TP topology, SP, CP divisibility, and long-sequence CP guidance

Memory Estimation

Without parallelism (70B model, FP16):

parameters:       140 GB
gradients:        140 GB
optimizer states: 280 GB (Adam)
activations:       48 GB (batch=1, seq=4K)
total:            608 GB

With TP=4, PP=4, DP=4 (64 GPUs):

parameters:        8.75 GB per GPU
gradients:         8.75 GB per GPU
optimizer states: 17.50 GB per GPU
activations:       3.00 GB per GPU
total:           ~38    GB per GPU

Code Anchors

Parallelism dimensions set in model provider:

model_config = GPTModelProvider(
    tensor_model_parallel_size=2,
    # ... other model parameters
)

DP size calculation:

data_parallel_size = world_size / (tensor_model_parallel_size × pipeline_model_parallel_size × context_parallel_size)

Bridge initialization wires parallelism into process groups:

parallel_state.initialize_model_parallel(
    tensor_model_parallel_size=model_config.tensor_model_parallel_size,
    pipeline_model_parallel_size=model_config.pipeline_model_parallel_size,
    ...
    context_parallel_size=model_config.context_parallel_size,
    hierarchical_context_parallel_sizes=model_config.hierarchical_context_parallel_sizes,
    expert_model_parallel_size=model_config.expert_model_parallel_size,
    ...
)

Pitfalls

  1. TP across nodes destroys throughput. Always keep TP within a single NVLink domain.

  2. PP without interleaving has large pipeline bubbles. Use virtual_pipeline_model_parallel_size when possible.

  3. SP requires tensor_model_parallel_size > 1. Enabling SP alone without TP is a config error.

  4. CP requires seq_length % (2 * context_parallel_size) == 0.

  5. EP is only for MoE models. Setting expert_model_parallel_size on a dense model is a no-op or error.

  6. The model-size-to-parallelism table above is a starting heuristic. Always profile the first iteration to check memory and communication.

  7. CUDA_DEVICE_MAX_CONNECTIONS and related env vars interact with overlap settings. See @skills/nemo-mbridge-perf-tp-dp-comm-overlap/SKILL.md.

  8. The minimum GPU count for an MoE config is PP * max(TP*CP, EP*ETP), not the product of all dimensions. The dense TP*CP-mesh and MoE EP*ETP-mesh share the same GPUs in each PP stage. See "Minimum GPU Count" section above.

Verification

Quick sanity check that combined parallelism initializes correctly using the smallest available recipe with overridden parallelism:

CUDA_VISIBLE_DEVICES=0,1,2,3 uv run python -m torch.distributed.run --nproc_per_node=4 \
  scripts/training/run_recipe.py \
  --recipe llama32_1b_pretrain_config \
  model.tensor_model_parallel_size=2 \
  model.pipeline_model_parallel_size=2 \
  model.sequence_parallel=True \
  train.train_iters=3 train.global_batch_size=8 train.micro_batch_size=1 \
  scheduler.lr_warmup_iters=0 \
  validation.eval_iters=0 validation.eval_interval=0 \
  checkpoint.save_interval=0 \
  logger.log_interval=1

Success criteria:

  • exit code 0

  • finite loss at iteration 3 (e.g. lm loss: 1.003808E+01)

  • log shows TP=2 PP=2 DP=1 layout with 4 ranks

Files

skill-card.md

Description: <br>

Operational guide for choosing and combining parallelism strategies in Megatron Bridge, including sizing rules, hardware topology mapping, and combined parallelism configuration. <br>

This skill is ready for commercial/non-commercial use. <br>

Owner

NVIDIA <br>

License/Terms of Use: <br>

Apache 2.0 <br>

Use Case: <br>

Developers and engineers choosing, sizing, or debugging parallelism configurations (TP, PP, DP, CP, EP) for large-scale model training with Megatron Bridge. <br>

Deployment Geography for Use: <br>

Global <br>

Known Risks and Mitigations: <br>

Risk: Review before execution as proposals could introduce incorrect or misleading guidance into skills. <br> Mitigation: Review and scan skill before deployment. <br>

Reference(s): <br>

Skill Output: <br>

Output Type(s): [Configuration instructions, Shell commands] <br> Output Format: [Markdown with inline Python code blocks] <br> Output Parameters: [1D] <br> Other Properties Related to Output: [None] <br>

Evaluation Agents Used: <br>

  • claude-code <br>

  • codex <br>

Evaluation Tasks: <br>

Evaluated against 1 evaluation task (1 positive skill-activation case, 2 attempts per task). <br>

Evaluation Metrics Used: <br>

Reported benchmark dimensions: <br>

  • Security: Checks whether skill-assisted execution avoids unsafe behavior such as secret leakage, destructive commands, or unauthorized access. <br>

  • Correctness: Checks whether the agent follows the expected workflow and produces the correct final output. <br>

  • Discoverability: Checks whether the agent loads the skill when relevant and avoids using it when irrelevant. <br>

  • Effectiveness: Checks whether the agent performs measurably better with the skill than without it. <br>

  • Efficiency: Checks whether the agent uses fewer tokens and avoids redundant work. <br>

Underlying evaluation signals used in this run: <br>

  • security: Checks for unsafe operations, secret leakage, and unauthorized access. <br>

  • skill_execution: Verifies that the agent loaded the expected skill and workflow. <br>

  • skill_efficiency: Checks routing quality, decoy avoidance, and redundant tool usage. <br>

  • accuracy: Grades final-answer correctness against the reference answer. <br>

  • goal_accuracy: Checks whether the overall user task completed successfully. <br>

  • behavior_check: Verifies expected behavior steps, including safety expectations. <br>

  • token_efficiency: Compares token usage with and without the skill. <br>

Evaluation Results: <br>

DimensionNumclaude-codecodex
Security2100% (+0%)100% (+0%)
Correctness2100% (+0%)88% (+0%)
Discoverability2100% (+0%)62% (+0%)
Effectiveness299% (+0%)95% (+2%)
Efficiency292% (-0%)60% (-0%)

Skill Version(s): <br>

v0.2.0rc6 (source: git tag) <br>

Ethical Considerations: <br>

NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal team to ensure this skill meets requirements for the relevant industry and use case and addresses unforeseen product misuse. <br>

(For Release on NVIDIA Platforms Only) <br> Please report quality, risk, security vulnerabilities or NVIDIA AI Concerns here. <br>

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 Python, 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-parallelism-strategies · 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-parallelism-strategies.zip