Skip to content

Refine MFSDP v2 configuration validation - #6333

Open
wujingyue wants to merge 1 commit into
NVIDIA:mainfrom
wujingyue:agent/mfsdp-v2-ignore-partial-distopt
Open

Refine MFSDP v2 configuration validation#6333
wujingyue wants to merge 1 commit into
NVIDIA:mainfrom
wujingyue:agent/mfsdp-v2-ignore-partial-distopt

Conversation

@wujingyue

@wujingyue wujingyue commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Accept legacy MFSDP v1 scheduling and buffering flags as MFSDP v2 no-ops, since v2 always overlaps communication and uses double buffering.
  • Enable NCCL user buffers through the v2 symmetric-memory pool, rejecting only the incompatible combination with disabled symmetric registration.
  • Remove the v1-only HSDP restriction and clarify that v2 has no persistent-buffer fallback because it allocates communication buffers from PyTorch memory pools.
  • Add adapter coverage that verifies nccl_ub=True forwards use_symm_mem=True to fully_shard.

Validation

  • isort --check-only tests/unit_tests/distributed/mfsdp_v2/test_mcore_adapter.py
  • python -m torch.distributed.run --nproc-per-node 2 -m pytest -q tests/unit_tests/distributed/mfsdp_v2/test_mcore_adapter.py
  • git diff --check

@copy-pr-bot

copy-pr-bot Bot commented Aug 6, 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 force-pushed the agent/mfsdp-v2-ignore-partial-distopt branch 2 times, most recently from a713f67 to 107da0b Compare August 6, 2026 23:55
raise ValueError("MFSDP v2 does not currently support communication overlap modes.")
if config.gradient_accumulation_fusion:
raise ValueError("MFSDP v2 does not currently support gradient accumulation fusion.")
if config.calculate_per_token_loss:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MFSDP v2 unconditionally overlaps reduce-scatter and parameter all-gathers, and always uses double buffering. We intentionally accept and ignore the legacy overlap_grad_reduce, overlap_param_gather, and fsdp_double_buffer flags for compatibility: their defaults are False, so rejecting those values would require every existing v2 caller to override them just to preserve current behavior. The tradeoff is that setting them to False does not disable v2 overlap or double buffering.

@wujingyue
wujingyue force-pushed the agent/mfsdp-v2-ignore-partial-distopt branch from 107da0b to c60c1de Compare August 7, 2026 00:49
raise ValueError("MFSDP v2 does not support fsdp_double_buffer.")
if ddp_config.fsdp_db_use_persist_buf_on_alloc_fail:
raise ValueError("MFSDP v2 does not support fsdp_db_use_persist_buf_on_alloc_fail.")
if ddp_config.fsdp_all_gather_in_start_param_sync:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag doesn't make sense for MFSDP v2 because it doesn't rely on this flag to prefetch the first bucket.

@wujingyue
wujingyue marked this pull request as ready for review August 7, 2026 00:51
@wujingyue
wujingyue requested review from a team as code owners August 7, 2026 00:51
@wujingyue
wujingyue requested a review from skyw August 7, 2026 00:51
@wujingyue

Copy link
Copy Markdown
Contributor Author

/ok to test c60c1de

@wujingyue

Copy link
Copy Markdown
Contributor Author

/ok to test 6b81672

@wujingyue wujingyue linked an issue Aug 7, 2026 that may be closed by this pull request
placements = Placements(
dp_axes=[0], parameter=[Flat()], gradient=[Flat()], optimizer=[Flat()]
)
use_symm_mem = ddp_config.nccl_ub

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider comment why symmetric memory depends on UB use here.

Q: Any reason not using long name "use_symmetric_memory"? the other PR has gone length to rename it that way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Any reason not using long name "use_symmetric_memory"? the other PR has gone length to rename it that way.

Yes. I'll do that after the other PR (#6127) is merged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added a code comment as you requested.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Final Review PR is in the "final review" stage label Aug 7, 2026
@wujingyue
wujingyue force-pushed the agent/mfsdp-v2-ignore-partial-distopt branch from 6b81672 to 1f28ed7 Compare August 7, 2026 17:45
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate MFSDP v2 with Megatron Core training

4 participants