Skip to content

test(fsdp): verify optimizer CUDA graphs in v2 - #6498

Merged
wujingyue merged 2 commits into
NVIDIA:mainfrom
wujingyue:optimizer-cuda-graph-mfsdp
Aug 14, 2026
Merged

wujingyue merged 2 commits into
NVIDIA:mainfrom
wujingyue:optimizer-cuda-graph-mfsdp

Conversation

@wujingyue

Copy link
Copy Markdown
Contributor

Summary

Enable optimizer_cuda_graph for MFSDP v2 by removing its configuration guard.

Extend the MCore adapter optimizer integration test to exercise eager execution plus optimizer-step CUDA-graph warmup, capture, and replay against the existing unsharded reference.

Capturable Transformer Engine FusedAdam requires main gradients to use the configured main-weight dtype. The CUDA-graph test derives that dtype from the MFSDP configuration; the eager variant retains its default bf16 main gradients. See NVIDIA/TransformerEngine#3358.

Validation

  • python -m torch.distributed.run --nproc-per-node 2 -m pytest -q tests/unit_tests/distributed/mfsdp_v2/test_mcore_adapter.py::TestMcoreAdapter::test_build_train_and_step
    • 2 passed: eager and optimizer CUDA-graph variants.
  • python -m black --check tests/unit_tests/distributed/mfsdp_v2/test_mcore_adapter.py
  • python -m isort --check-only tests/unit_tests/distributed/mfsdp_v2/test_mcore_adapter.py

@copy-pr-bot

copy-pr-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@wujingyue wujingyue changed the title feat(fsdp): support optimizer CUDA graphs in v2 test(fsdp): verify optimizer CUDA graphs in v2 Aug 12, 2026
@wujingyue
wujingyue requested a review from skyw August 12, 2026 23:28
@wujingyue
wujingyue marked this pull request as ready for review August 12, 2026 23:28
@wujingyue
wujingyue requested review from a team as code owners August 12, 2026 23:28
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/31737737376

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/31745334721

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/31746289164

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/31752937667

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/31755638967

Merged via the queue into NVIDIA:main with commit 3d0956f Aug 14, 2026
185 checks passed
@wujingyue
wujingyue deleted the optimizer-cuda-graph-mfsdp branch August 14, 2026 02:13
@wujingyue wujingyue linked an issue Aug 26, 2026 that may be closed by this pull request
wujingyue added a commit to wujingyue/Megatron-Bridge that referenced this pull request Sep 1, 2026
…ware optimizer, HSDP, and optimizer CUDA graphs

Megatron-LM landed dedicated MFSDP v2 support for these, each with its own commits and
tests, after this validation function was written:

- clip_grad: MFSDP v2 gradient clipping across dense and expert meshes (NVIDIA/Megatron-LM#6489)
- use_precision_aware_optimizer: mixed-precision optimizers in MFSDP v2 (NVIDIA/Megatron-LM#6506)
- num_distributed_optimizer_instances / outer_dp_sharding_strategy (HSDP): expose HSDP and
  HFSDP through the MFSDP v2 adapter (NVIDIA/Megatron-LM#6873); the adapter itself now enforces
  the correct paired constraint, so no replacement check is needed here
- optimizer_cuda_graph: verified for MFSDP v2 (NVIDIA/Megatron-LM#6498)

Verified end-to-end against Megatron-LM main + Megatron-Bridge with the DeepSeek-V3 MFSDP
v2 + EP proxy config (clip_grad=1.0): 20/20 iterations, finite decreasing loss, no skipped
or NaN iterations.
wujingyue added a commit to wujingyue/Megatron-Bridge that referenced this pull request Sep 1, 2026
…ware optimizer, HSDP, and optimizer CUDA graphs

Megatron-LM landed dedicated MFSDP v2 support for these, each with its own commits and
tests, after this validation function was written:

- clip_grad: MFSDP v2 gradient clipping across dense and expert meshes (NVIDIA/Megatron-LM#6489)
- use_precision_aware_optimizer: mixed-precision optimizers in MFSDP v2 (NVIDIA/Megatron-LM#6506)
- num_distributed_optimizer_instances / outer_dp_sharding_strategy (HSDP): expose HSDP and
  HFSDP through the MFSDP v2 adapter (NVIDIA/Megatron-LM#6873); the adapter itself now enforces
  the correct paired constraint, so no replacement check is needed here
- optimizer_cuda_graph: verified for MFSDP v2 (NVIDIA/Megatron-LM#6498)

Verified end-to-end against Megatron-LM main + Megatron-Bridge with the DeepSeek-V3 MFSDP
v2 + EP proxy config (clip_grad=1.0): 20/20 iterations, finite decreasing loss, no skipped
or NaN iterations.

Signed-off-by: Jingyue Wu <wujingyue@gmail.com>
ksivaman pushed a commit to ksivaman/Megatron-LM that referenced this pull request Sep 1, 2026
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
wujingyue added a commit to wujingyue/Megatron-Bridge that referenced this pull request Sep 11, 2026
…ware optimizer, HSDP, and optimizer CUDA graphs

Megatron-LM landed dedicated MFSDP v2 support for these, each with its own commits and
tests, after this validation function was written:

- clip_grad: MFSDP v2 gradient clipping across dense and expert meshes (NVIDIA/Megatron-LM#6489)
- use_precision_aware_optimizer: mixed-precision optimizers in MFSDP v2 (NVIDIA/Megatron-LM#6506)
- num_distributed_optimizer_instances / outer_dp_sharding_strategy (HSDP): expose HSDP and
  HFSDP through the MFSDP v2 adapter (NVIDIA/Megatron-LM#6873); the adapter itself now enforces
  the correct paired constraint, so no replacement check is needed here
- optimizer_cuda_graph: verified for MFSDP v2 (NVIDIA/Megatron-LM#6498)

Verified end-to-end against Megatron-LM main + Megatron-Bridge with the DeepSeek-V3 MFSDP
v2 + EP proxy config (clip_grad=1.0): 20/20 iterations, finite decreasing loss, no skipped
or NaN iterations.

Signed-off-by: Jingyue Wu <wujingyue@gmail.com>

This branch was previously deployed

2 inactive deployments
public — c98aecde Deployed Aug 13, 2026 by copy-pr-bot[bot] via finalize / publish-docs #6027
test — c98aecde Deployed Aug 13, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #18931
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved All necessary approvals have been made complexity: low Run tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CUDA graph support for MFSDP v2

5 participants