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
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.
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:
Multiple nodes with InfiniBand:
Limited network (Ethernet):
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
Combined Parallelism Enablement
3D parallelism (TP + PP + DP):
4D parallelism (TP + PP + CP + DP):
MoE with EP + PP (e.g. DeepSeek-V2 236B on 128 GPUs):
MoE with small TP + PP + EP (e.g. DeepSeek-V3 671B on 256 GPUs):
DP size is always implicit:
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:
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
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): denseDP = 8/2 = 4, MoEEDP = 8/8 = 1 - 16 GPUs: dense
DP = 8, MoEEDP = 2→ 2× global batch - 32 GPUs: dense
DP = 16, MoEEDP = 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 * ETPfull product - give both DP formulas: dense
world_size / (TP * PP * CP)and MoEworld_size / (PP * EP * ETP) - mention TP topology, SP, CP divisibility, and long-sequence CP guidance
Memory Estimation
Without parallelism (70B model, FP16):
With TP=4, PP=4, DP=4 (64 GPUs):
Code Anchors
Parallelism dimensions set in model provider:
DP size calculation:
Bridge initialization wires parallelism into process groups:
Pitfalls
-
TP across nodes destroys throughput. Always keep TP within a single NVLink domain.
-
PP without interleaving has large pipeline bubbles. Use
virtual_pipeline_model_parallel_sizewhen possible. -
SP requires
tensor_model_parallel_size > 1. Enabling SP alone without TP is a config error. -
CP requires
seq_length % (2 * context_parallel_size) == 0. -
EP is only for MoE models. Setting
expert_model_parallel_sizeon a dense model is a no-op or error. -
The model-size-to-parallelism table above is a starting heuristic. Always profile the first iteration to check memory and communication.
-
CUDA_DEVICE_MAX_CONNECTIONSand related env vars interact with overlap settings. See @skills/nemo-mbridge-perf-tp-dp-comm-overlap/SKILL.md. -
The minimum GPU count for an MoE config is
PP * max(TP*CP, EP*ETP), not the product of all dimensions. The denseTP*CP-mesh and MoEEP*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:
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
