56 results available
Sign in
Skills directory

nemo-mbridge-perf-megatron-fsdp

nvidia

·

Last changed
Hardened

This skill has been hardened by Chainguard

Last changed

This version passed the hardening gate. Hardening applied 7 targeted changes and preserved all other text. Classified findings before hardening: 1. Classified findings closed: 0. Classified findings remaining: 1. Unclassified scanner findings remaining: 0. Review findings closed: 11. Review findings remaining: 0.


Open before hardening

1

Medium
Open after hardening

1

Medium

Expand
File
Group
Subtype
Severity
Status
BENCHMARK.md

Sensitive Data & Secret Exposure

Agent snooping

Medium
Open

1 finding


SKILL.md

Megatron FSDP Skill

For stable background and recommendation level, see:

  • @docs/training/megatron-fsdp.md
  • @skills/nemo-mbridge-perf-megatron-fsdp/card.yaml

card.yaml ships with this skill. The docs path exists only inside a trusted Megatron-Bridge checkout. If that doc is missing, continue with this file and card.yaml and tell the user the doc was unavailable.

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 = None

The save directory above is only an example. Point checkpoint save at a private directory that you own and that other users on the machine cannot write to, rather than a shared temporary folder.

Performance harness note:

Add this flag to an existing performance launch script invocation that already sets the model and recipe arguments. Ask the user for any missing arguments.

python scripts/performance/launch.py --use_megatron_fsdp true

Code Anchors

The line ranges below were captured on the validated branch recorded in card.yaml and may drift. Locate each snippet by its content, such as the _ddp_wrap function, and confirm it against the current source before relying on or editing it.

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 = None

Pitfalls

  1. Public recipes often expose use_megatron_fsdp but still default to ckpt_format="torch_dist". If save/load is enabled, switch to fsdp_dtensor.
  2. use_torch_fsdp2 exists, but on the validated branch recorded in card.yaml Bridge still failed before training because _ddp_wrap passes pg_collection. Check _ddp_wrap again in the current source before ruling FSDP2 in or out.
  3. CPU offloading is only valid when pipeline_model_parallel_size == 1 and activation recomputation is disabled.
  4. Upstream warns that FSDP and TP/CP can want different CUDA_DEVICE_MAX_CONNECTIONS settings on Hopper and earlier.
  5. Megatron FSDP and FSDP2 are mutually exclusive.
  6. Load checkpoints only from directories you created or otherwise trust, with access limited to your user, because loading a checkpoint deserializes its contents.

Verification

Use the existing 2-GPU functional smoke test:

Run this from a trusted Megatron-Bridge checkout whose committed lockfile is already synced, so uv uses only the locked dependencies. Run it on a single trusted host that is not shared with other jobs, because the default rendezvous port accepts unauthenticated connections.

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

Success criteria:

  • Pytest reports 1 passed
  • The log shows finite loss at the last iteration
  • The run finishes without a checkpoint format assertion

Install

Install with chainctl
chainctl skill install public/nvidia/nemo-mbridge-perf-megatron-fsdp:latest
Get started with chainctl
View source

Harden your own skills

Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.

Provenance

Upstream sourcehttps://github.com/nvidia/skills
Upstream commitbc0beba39212e30de490dcd0f1c7eeb8d58d03cd
OCI reference

skills.chainreg.biz/public/github.com/nvidia/skills/nemo-mbridge-perf-megatron-fsdp:latest

License

Apache-2.0

Files

BENCHMARK.md

HARDENING.md

SKILL.md

card.yaml

evals/evals.json

skill-card.md

skill.oms.sig


The trusted source for open source

Talk to an expert
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsChainguard OS PackagesChainguard ActionsChainguard Agent SkillsIntegrationsPricing
© 2026 Chainguard, Inc. All Rights Reserved.
Chainguard® and the Chainguard logo are registered trademarks of Chainguard, Inc. in the United States and/or other countries.
The other respective trademarks mentioned on this page are owned by the respective companies and use of them does not imply any affiliation or endorsement.