Nemo Mbridge Perf Megatron Fsdp
NVIDIAOfficialPublished by NVIDIA
- Skill
- Tool integration
- Software development
- Apache-2.0
- Medium risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a comprehensive reference for enabling and troubleshooting Megatron FSDP (Fully Sharded Data Parallel) in Megatron-Bridge. It covers essential configuration parameters, code migration paths, common pitfalls, and verification procedures to ensure stable training performance.
What it does
- Provides configuration snippets for enabling Megatron FSDP in training recipes.
- Details necessary adjustments for checkpoint formats and sharding strategies.
- Identifies code anchors for migrating legacy distributed configuration settings.
- Highlights common pitfalls regarding mutual exclusivity and hardware-specific settings.
- Outlines functional smoke testing procedures to verify successful implementation.
When to use it
- When transitioning from DDP to FSDP-based data parallelism.
- When debugging Out-of-Memory (OOM) errors related to data parallel configurations.
- When investigating performance regressions linked to FSDP settings.
- When setting up new training runs requiring specific sharding strategies.
Advantages
- Centralizes configuration requirements for Megatron FSDP.
- Reduces integration errors by highlighting mandatory checkpoint format changes.
- Provides clear validation steps to confirm correct deployment.
- Clarifies the relationship between different distributed training wrappers.
Usage examples
- “How do I enable Megatron FSDP in my Megatron-Bridge training config?”
- The agent provides the required configuration block, including setting use_megatron_fsdp to True, selecting the appropriate sharding strategy, and configuring the fsdp_dtensor checkpoint format.
- “I am getting an error when using Megatron FSDP, how do I verify my setup?”
- The agent directs you to run the functional smoke test using the provided pytest command and explains how to interpret the logs for finite loss and successful checkpointing.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/nvidia/nemo-mbridge-perf-megatron-fsdp/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip nemo-mbridge-perf-megatron-fsdp.zip -d .agents/skills
Documentation by NVIDIA
Megatron FSDP Skill
For stable background and recommendation level, see:
@docs/training/megatron-fsdp.md
@skills/nemo-mbridge-perf-megatron-fsdp/card.yaml
Enablement
Minimal Megatron FSDP override in Bridge:
cfg.ddp.use_megatron_fsdp = True
cfg.ddp.data_parallel_sharding_strategy = "optim_grads_params"
cfg.ddp.average_in_collective = False
cfg.checkpoint.ckpt_format = "fsdp_dtensor"Example recipe fixup:
cfg = llama3_8b_pretrain_config()
cfg.ddp.use_megatron_fsdp = True
cfg.ddp.data_parallel_sharding_strategy = "optim_grads_params"
cfg.ddp.average_in_collective = False
cfg.checkpoint.ckpt_format = "fsdp_dtensor"
cfg.checkpoint.save = "/tmp/fsdp_ckpts"
cfg.checkpoint.load = NonePerformance harness note:
python scripts/performance/launch.py --use_megatron_fsdp trueCode Anchors
Megatron-Core DDP configuration (exposed as cfg.ddp in Bridge):
from megatron.core.distributed import DistributedDataParallelConfig
ddp_config = DistributedDataParallelConfig(use_megatron_fsdp=True)DistributedInitConfig no longer accepts use_megatron_fsdp. Migrate existing
cfg.dist.use_megatron_fsdp overrides to cfg.ddp.use_megatron_fsdp.
Bridge validation:
if self.ddp.use_megatron_fsdp and self.dist.use_torch_fsdp2:
raise ValueError(...)
...
assert not self.dist.use_tp_pp_dp_mapping, "use_tp_pp_dp_mapping is not supported with Megatron FSDP"
...
assert self.checkpoint.ckpt_format == "fsdp_dtensor", (
"Megatron FSDP only supports fsdp_dtensor checkpoint format"
)Runtime wrapper selection:
if use_megatron_fsdp:
DP = FullyShardedDataParallel
elif use_torch_fsdp2:
DP = TorchFullyShardedDataParallel
else:
DP = DistributedDataParallel
...
DP(
config=get_model_config(model_chunk),
ddp_config=ddp_config,
module=model_chunk,
...
pg_collection=pg_collection,
)Perf harness overrides:
recipe.ddp.use_megatron_fsdp = True
recipe.ddp.data_parallel_sharding_strategy = "optim_grads_params"
recipe.ddp.keep_fp8_transpose_cache = False
recipe.ddp.average_in_collective = False
...
recipe.checkpoint.load = NonePitfalls
Public recipes often expose
use_megatron_fsdpbut still default tockpt_format="torch_dist". If save/load is enabled, switch tofsdp_dtensor.use_torch_fsdp2exists, but on the validated branch Bridge still fails before training because_ddp_wrappassespg_collection.CPU offloading is only valid when
pipeline_model_parallel_size == 1and activation recomputation is disabled.Upstream warns that FSDP and TP/CP can want different
CUDA_DEVICE_MAX_CONNECTIONSsettings on Hopper and earlier.Megatron FSDP and FSDP2 are mutually exclusive.
Verification
Use the existing 2-GPU functional smoke test:
CUDA_VISIBLE_DEVICES=0,1 uv run python -m torch.distributed.run --nproc_per_node=2 \
-m pytest tests/functional_tests/training/test_megatron_fsdp.py::TestMegatronFSDP::test_fsdp_pretrain_basic -v -sSuccess criteria:
Pytest reports
1 passedThe log shows finite loss at the last iteration
The run finishes without a checkpoint format assertion
Files
- ATTRIBUTION.mdAdded by AutoGineer861 B
- BENCHMARK.md9.3 KiB
- LICENSELicence file added by AutoGineer11.2 KiB
- SKILL.md3.7 KiB
- card.yaml2.0 KiB
- evals/evals.json1.4 KiB
- skill-card.md7.0 KiB
- skill.oms.sig4.7 KiB
evals/evals.json
[
{
"id": "megatron-fsdp-positive-enable-smoke",
"question": "Use the nemo-mbridge-perf-megatron-fsdp skill. Give the minimal Megatron Bridge Megatron-FSDP override, the required checkpoint format, and the pitfalls that distinguish Megatron FSDP from Torch FSDP2.",
"expected_skill": "nemo-mbridge-perf-megatron-fsdp",
"expected_script": null,
"ground_truth": "The answer should use the Megatron FSDP skill. It should set cfg.ddp.use_megatron_fsdp=True, cfg.ddp.data_parallel_sharding_strategy=\"optim_grads_params\", and cfg.checkpoint.ckpt_format=\"fsdp_dtensor\" when save/load is enabled. It should mention use_torch_fsdp2 is mutually exclusive with Megatron FSDP and is not the validated path, use_tp_pp_dp_mapping is not supported with Megatron FSDP, and Hopper or earlier may need attention to CUDA_DEVICE_MAX_CONNECTIONS because FSDP and TP/CP prefer different settings.",
"expected_behavior": [
"Read the nemo-mbridge-perf-megatron-fsdp skill before answering.",
"Identify the request as Megatron Bridge Megatron FSDP enablement.",
"List cfg.ddp.use_megatron_fsdp as the sole Megatron FSDP enablement flag.",
"List data_parallel_sharding_strategy=optim_grads_params and ckpt_format=fsdp_dtensor.",
"Mention FSDP2 mutual exclusion and use_tp_pp_dp_mapping incompatibility.",
"Include a Bridge-specific verification or test path."
]
}
]
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
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-megatron-fsdp · 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-megatron-fsdp.zip