-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Refine MFSDP v2 configuration validation #6333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -564,6 +564,11 @@ def __init__( | |
| placements = Placements( | ||
| dp_axes=[0], parameter=[Flat()], gradient=[Flat()], optimizer=[Flat()] | ||
| ) | ||
| # NCCL symmetric memory requires UB. MFSDP v2 intentionally does not support UB | ||
| # without symmetric memory: it uses ncclCommRegister rather than the more performant | ||
| # ncclCommWindowRegister: | ||
| # https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/usage/bufferreg.html#window-registration | ||
| use_symm_mem = ddp_config.nccl_ub | ||
| with fully_shard_context(device=device): | ||
| for submodule in reversed(list(module.modules())): | ||
| if submodule is module: | ||
|
|
@@ -576,9 +581,14 @@ def __init__( | |
| mesh=mesh, | ||
| placements=placements, | ||
| mixed_precision_policy=self.mp_policy, | ||
| use_symm_mem=use_symm_mem, | ||
| ) | ||
| fully_shard( | ||
| module, mesh=mesh, placements=placements, mixed_precision_policy=self.mp_policy | ||
| module, | ||
| mesh=mesh, | ||
| placements=placements, | ||
| mixed_precision_policy=self.mp_policy, | ||
| use_symm_mem=use_symm_mem, | ||
| ) | ||
| super().__init__(config=config, module=module) | ||
|
|
||
|
|
@@ -642,12 +652,8 @@ def _validate_config( | |
| raise ValueError( | ||
| "MFSDP v2 requires data_parallel_sharding_strategy='optim_grads_params'." | ||
| ) | ||
| if ddp_config.num_distributed_optimizer_instances != 1: | ||
| raise ValueError("MFSDP v2 does not currently support HSDP.") | ||
| if ddp_config.outer_dp_sharding_strategy != "no_shard": | ||
| raise ValueError("MFSDP v2 does not currently support outer DP sharding.") | ||
| if ddp_config.overlap_grad_reduce or ddp_config.overlap_param_gather: | ||
| 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: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
@@ -657,16 +663,13 @@ def _validate_config( | |
| if config.cuda_graph_impl != "none" or ddp_config.megatron_fsdp_cuda_graph_mode: | ||
| raise ValueError("MFSDP v2 does not currently support CUDA graphs.") | ||
|
|
||
| if ddp_config.fsdp_double_buffer: | ||
| 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: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| raise ValueError("MFSDP v2 does not support fsdp_all_gather_in_start_param_sync.") | ||
| if ddp_config.nccl_ub: | ||
| raise ValueError("MFSDP v2 does not support nccl_ub.") | ||
| if ddp_config.disable_symmetric_registration: | ||
| raise ValueError("MFSDP v2 does not support disable_symmetric_registration.") | ||
| raise ValueError( | ||
| "MFSDP v2 does not support fsdp_db_use_persist_buf_on_alloc_fail: " | ||
| "it allocates communication buffers from PyTorch memory pools." | ||
| ) | ||
| if ddp_config.nccl_ub and ddp_config.disable_symmetric_registration: | ||
| raise ValueError("MFSDP v2 requires symmetric registration when nccl_ub is enabled.") | ||
| if ddp_config.fsdp_manual_registration: | ||
| raise ValueError("MFSDP v2 does not support fsdp_manual_registration.") | ||
| if ddp_config.delay_wgrad_compute: | ||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'll do that after the other PR (#6127) is merged.
There was a problem hiding this comment.
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.