nemo-automodel-distributed-training
Guide for selecting and configuring distributed training strategies in NeMo AutoModel, including FSDP2, Megatron FSDP, DDP, and parallelism settings.
Install / Use
npx skills add NVIDIA/skills --skill nemo-automodel-distributed-trainingInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of nemo-automodel-distributed-training
nemo-automodel-distributed-training scores 95/100 on our quality scale, 363rd of 3,356 Development & Engineering skills we index (top 11%).
Its SKILL.md is 19 KB long, well organised into 43 sections with 30 code examples: a thorough specification that gives an agent plenty to work with.
With 3,421 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 5 days ago, so nemo-automodel-distributed-training is actively maintained.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands.
Automated pattern scan on 2026-09-29. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
nemo-automodel-distributed-training compared with similar skills
All 4 of these similar skills score higher than nemo-automodel-distributed-training; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| nemo-automodel-distributed-training (this skill)by NVIDIA | 95 | 3.4k | 5d ago | SKILL.md |
| ai-job-searchby MadsLorentzen | 100 | 44.4k | today | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.7k | 2d ago | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 6d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 6d ago | SKILL.md |
Frequently asked questions
- How do I install nemo-automodel-distributed-training?
- Run
npx skills add NVIDIA/skills --skill nemo-automodel-distributed-training. The install tabs above show the steps for each supported agent. - Which AI agents does nemo-automodel-distributed-training work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is nemo-automodel-distributed-training safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. It is Apache-2.0-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is nemo-automodel-distributed-training still maintained?
- The repository was last updated 5 days ago, so nemo-automodel-distributed-training is actively maintained.
Skill content
View source on GitHubname: nemo-automodel-distributed-training description: Guide for selecting and configuring distributed training strategies in NeMo AutoModel, including FSDP2, Megatron FSDP, DDP, and parallelism settings. when_to_use: Adding or modifying distributed training strategies (FSDP2, HSDP, DDP), debugging multi-GPU or multi-node failures, configuring context or tensor parallelism, or tuning sharding settings. license: Apache-2.0 metadata: author: NVIDIA tags: - nemo-automodel - distributed-training
Distributed Training in NeMo AutoModel
Purpose
NeMo AutoModel uses PyTorch-native distributed training.
All parallelism is orchestrated through a single MeshContext object that
holds device meshes, strategy configs, and axis names.
Instructions
For conceptual distributed-training questions, answer directly from the quick patterns in this skill without inspecting the repository. Start with the strategy choice, then list only the YAML fields and constraints relevant to the question.
Use direct action verbs in the final answer: recommend the strategy, show the minimal YAML, state the sizing constraint, and name the unsupported strategies. Do not discuss model onboarding, recipes, Slurm, SkyPilot, or checkpointing unless the user asks.
Examples
TP plus PP for a large multi-node model
Recommend strategy: fsdp2. Mention tp_size, pp_size, cp_size,
ep_size, and the pipeline sub-config. State that dp_size is inferred from
world_size / (tp_size * pp_size * cp_size).
distributed:
strategy: fsdp2
tp_size: 8
pp_size: 4
cp_size: 1
ep_size: 1
pipeline:
pp_schedule: interleaved1f1b
pp_microbatch_size: 1
MoE expert parallelism
Recommend strategy: fsdp2 with ep_size > 1. Say this creates a separate
moe_mesh; include the moe sub-config when relevant; state that ep_size
must divide dp_size * cp_size. Do not recommend megatron_fsdp or ddp.
distributed:
strategy: fsdp2
ep_size: 8
moe:
reshard_after_forward: false
MegatronFSDP limitations
Say no for pipeline parallelism, expert parallelism, and sequence_parallel.
Recommend fsdp2 for PP, EP, or sequence_parallel; mention that DDP is only
simple data parallelism.
Strategy Selection
Three strategies are available, selected via the distributed.strategy YAML key:
| Strategy | YAML value | Best for |
|---|---|---|
| FSDP2 | fsdp2 | General use, recommended default. Supports TP, PP, CP, EP, HSDP. |
| MegatronFSDP | megatron_fsdp | NVIDIA Megatron-style FSDP. No PP, no EP, no sequence_parallel. |
| DDP | ddp | Simple data parallelism only. No TP, PP, CP, or EP. |
Decision tree:
- Single GPU: no distributed config needed (FSDP2Manager skips parallelization when world_size=1).
- Multi-GPU single node:
fsdp2(default). Useddponly if you need the simplest possible setup. - Multi-node:
fsdp2with appropriate TP/PP sizing. - MoE models with expert parallelism:
fsdp2withep_size > 1(creates a separatemoe_mesh). - Large models (70B+):
fsdp2with PP + TP. - Long sequences (8K+): add CP (
cp_size > 1).
When answering strategy-selection questions, state the chosen distributed.strategy
first, then enumerate the YAML fields the user must set.
Quick TP + PP answer:
- Use
strategy: fsdp2; do not usemegatron_fsdpwhen pipeline parallelism is required. - Set
tp_sizefor tensor parallelism andpp_sizefor pipeline parallelism. - Add a
pipeline:sub-config withpp_scheduleandpp_microbatch_size. - Leave
dp_sizeunset ornone; it is inferred asworld_size / (tp_size * pp_size * cp_size). - Keep TP inside a fast intra-node domain when possible, and use PP across model depth for 70B+ models.
Quick MoE expert-parallel answer:
- Start with
strategy: fsdp2andep_size > 1. - Include a
moe:sub-config only whenep_size > 1; it maps toMoEParallelizerConfig. - Expect a separate
moe_meshfor expert parallelism in addition to the maindevice_mesh. - Do not recommend
megatron_fsdporddpfor expert parallelism;megatron_fsdphas no EP support. - Before finishing an MoE EP answer, explicitly state that
ep_sizemust dividedp_size * cp_sizeand thatmegatron_fsdpdoes not support EP, PP, orsequence_parallel.
YAML Config Structure
The distributed section in the recipe YAML maps directly to
parse_distributed_section() in recipes/_dist_utils.py:
distributed:
strategy: fsdp2 # fsdp2 | megatron_fsdp | ddp
dp_size: none # auto-calculated from world_size / (tp * pp * cp)
dp_replicate_size: none # FSDP2-only, for HSDP
tp_size: 1
pp_size: 1
cp_size: 1
ep_size: 1
# Strategy-specific flags (forwarded to the strategy dataclass):
sequence_parallel: false
activation_checkpointing: false
defer_fsdp_grad_sync: true # FSDP2 only
# Sub-configs (optional):
pipeline:
pp_schedule: 1f1b
pp_microbatch_size: 1
# ... see PipelineConfig fields
moe:
reshard_after_forward: false
# ... see MoEParallelizerConfig fields
The dp_size is always inferred:
dp_size = world_size / (tp_size * pp_size * cp_size)
Infrastructure Flow
initialize_distributed() [components/distributed/init_utils.py]
-> initializes torch.distributed process group and returns DistInfo
YAML distributed section + DistInfo.world_size
-> parse_distributed_section() [recipes/_dist_utils.py]
-> create_distributed_setup_from_config() [recipes/_dist_utils.py]
-> DistributedSetup.build() [components/distributed/config.py]
-> instantiate_infrastructure() [_transformers/infrastructure.py]
-> _instantiate_distributed() -> FSDP2Manager / MegatronFSDPManager / DDPManager
-> _instantiate_pipeline() -> AutoPipeline (if pp_size > 1)
-> parallelize_fn -> MoE parallelizer (if ep_size > 1) or PP wrapper
-> apply_model_infrastructure() [_transformers/infrastructure.py]
-> _shard_pp() or _shard_ep_fsdp() (applies sharding to the model)
FSDP2 Configuration
Basic FSDP2 (data parallelism only)
distributed:
strategy: fsdp2
tp_size: 1
cp_size: 1
This auto-calculates dp_size = world_size and applies fully_shard() per
transformer block via DTensor-based sharding.
FSDP2 with Tensor Parallelism
Keep TP within a single NVLink domain (typically one node):
distributed:
strategy: fsdp2
tp_size: 4 # 2, 4, or 8 -- must divide GPUs per node
sequence_parallel: true
The TP plan is auto-selected based on the model type. Pass a custom plan via the Python API if needed:
config = FSDP2Config(sequence_parallel=True, tp_plan=my_custom_plan)
FSDP2 with Pipeline Parallelism
distributed:
strategy: fsdp2
pp_size: 2
pipeline:
pp_schedule: interleaved1f1b # 1f1b, gpipe, interleaved_1f1b, etc.
pp_microbatch_size: 4
scale_grads_in_schedule: false
The model must have a _pp_plan attribute (set on the HF model class) for
AutoPipeline to know how to split layers across stages. Models without
_pp_plan are not compatible with PP.
FSDP2 with HSDP (Hybrid Sharded Data Parallel)
Intra-node full sharding + inter-node replication via a 2D DeviceMesh:
distributed:
strategy: fsdp2
dp_replicate_size: 2 # must divide dp_size
Constraint: dp_replicate_size < dp_size (pure replication with no sharding
is not supported by FSDP2).
Activation Checkpointing
Trades compute for memory by recomputing activations during backward:
distributed:
activation_checkpointing: true
This is a model-build/training behavior flag, not mesh topology. Dense strategies read it from the strategy config; EP/MoE paths pass the recipe-level flag directly into model infrastructure.
Gradient Sync Deferral
FSDP2 defers gradient sync to the final micro-batch by default for communication overlap:
distributed:
defer_fsdp_grad_sync: true # default
Mixed Precision
FSDP2Config defaults to bfloat16 for all three precision knobs via
MixedPrecisionPolicy(param_dtype=bf16, reduce_dtype=bf16, output_dtype=bf16, cast_forward_inputs=True). Override via the Python API:
from torch.distributed.fsdp import MixedPrecisionPolicy
config = FSDP2Config(
mp_policy=MixedPrecisionPolicy(param_dtype=torch.float16, reduce_dtype=torch.float32),
)
Pipeline Parallelism
Requirements
- Model class must define
_pp_plan(a dict mapping module FQNs to stages). pp_size > 1in the distributed section.- A
pipelinesub-config with schedule and microbatch size.
Supported schedules
Defined in PipelineConfig.pp_schedule:
1f1b(one-forward-one-backward, default)gpipeinterleaved_1f1b/interleaved1f1blooped_bfsdfsv_schedulezero_bubble
Example (8B model on 8 GPUs, PP=2 + DP=4)
distributed:
strategy: fsdp2
pp_size: 2
pipeline:
pp_schedule: interleaved1f1b
pp_microbatch_size: 4
scale_grads_in_schedule: false
checkpoint:
model_save_format: safetensors
save_consolidated: final
How it works
AutoPipeline.build() calls pipeline_model() which splits the model into
stages using the model's _pp_plan, creates PipelineStage objects, and
builds the schedule. During training, schedule.step() drives forward and
backward through the pipeline.
Context Parallelism
Use CP for long sequences (8K+). CP shards Q/K/V on the sequence dimension as DTensors.
Config
distributed:
strategy: fsdp2
cp_size: 2 # or 4, 8
Requirements
- SDPA (Flash Attention or Efficient Attention backend) or Transformer Engine attention. SDPBackend.MATH is not compatible with DTensor.
- Attention masks are automatically stripped;
is_causal=Trueis set via forward pre-hooks registered byattach_context_parallel_hooks().
How it works
- After model sharding,
apply_model_infrastructure()callsattach_context_parallel_hooks()on each model part (for non-TE models). - At each training step,
make_cp_batch_and_ctx()creates a CP context manager that shards the batch along the sequence dimension and sets upcontext_parallel()fromtorch.distributed.tensor.experimental. - For TE attention models,
make_cp_batch_for_te()uses THD format and TE'sthd_get_partitioned_indicesfor sharding.
CP with Sequence Packing
CP works with packed sequences. The packed_sequence_size must be divisible
by cp_size. When using TE, chunks are sharded per-chunk via
_shard_thd_chunk_for_te().
Sequence Packing
Packing multiple sequences into a single training sample for efficiency.
Config
packed_sequence:
packed_sequence_size: 4096 # 0 = disabled
step_scheduler:
local_batch_size: 1 # must be 1 for packed sequences
When packed_sequence_size > 0, the dataset collator packs sequences up to
that length. local_batch_size must be 1 because each "sample" is already a
packed batch.
MoE Distributed Training
Expert Parallelism
Set ep_size > 1 to distribute experts across GPUs. This creates a separate
moe_mesh alongside the main device_mesh:
distributed:
strategy: fsdp2
ep_size: 8
activation_checkpointing: true
The moe_mesh shape is (pp_size, ep_shard_size, ep_size) with dimension
names ("pp", "ep_shard", "ep").
Constraint: dp_cp_size (= dp_size * cp_size) must be divisible by
ep_size.
MoE sub-config
distributed:
strategy: fsdp2
ep_size: 8
activation_checkpointing: true
moe:
reshard_after_forward: false
ignore_router_for_ac: false
wrap_outer_model: true
The moe sub-section maps to MoEParallelizerConfig and is only
instantiated when `ep
Truncated for display — read the full file on GitHub.
Related Skills
ai-job-search
44.4kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.7kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
