Add NCCL symmetric-memory staging to experimental FSDP#5440
Merged
Conversation
|
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. |
3d9c0e4 to
a499fa1
Compare
Contributor
Author
|
/ok to test |
Autumn1998
approved these changes
Jun 29, 2026
Allocate experimental FSDP all-gather and reduce-scatter staging buffers from PyTorch's NCCL symmetric-memory pool when use_symm_mem=True. Add explicit rendezvous before the symmetric-memory collectives and cover the path with a CUDA/NCCL profiler test that checks the symmetric kernel counts. Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
b10ac1e to
aad98de
Compare
deepakn94
approved these changes
Jul 1, 2026
- unshard_parameters now raises on a None gather axis and rendezvous unconditionally under symmetric memory, mirroring reduce_gradients. - Inline the single-use num_sharded_modules constant in the parity test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
The parity test used a tiny model (Linear(8,16)+Linear(16,4)); its sub-KB collectives make NCCL fall back to ring on runners with NCCL_NVLS_ENABLE=0 (e.g. CI), so the ncclSymk* kernel-count assertions failed there even though the runner supports symmetric memory. Widen the two sharded Linears to 1024 (a few-MiB bf16 weight), which reliably engages the symmetric kernels while preserving the loss-parity check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
Contributor
Author
|
/ok to test |
Phlip79
approved these changes
Jul 2, 2026
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/28622613847 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds an opt-in
use_symm_mem=Truepath for experimental Megatron-FSDP staging buffers. The full-parameter all-gather buffer and full-gradient reduce-scatter buffer are allocated from PyTorch's NCCL symmetric-memory pool, rendezvoused before collectives, and verified through profiler activity.Details
use_symm_memthroughfully_shard,FsdpModule, andFsdpParameterGroup.torch.cuda.use_mem_poolwhile leaving theDBufferallocation API unchanged.unshard_parametersraises on aNonegather axis and rendezvous unconditionally under symmetric memory, mirroringreduce_gradients.test_symmetric_memory.pythat checks loss parity and requires observedncclSymkall-gather and reduce-scatter kernels.Validation
python -m isort megatron/core/distributed/fsdp/src/megatron_fsdp/experimental/dbuffer.py megatron/core/distributed/fsdp/src/megatron_fsdp/experimental/fully_shard.py megatron/core/distributed/fsdp/src/megatron_fsdp/experimental/module.py megatron/core/distributed/fsdp/src/megatron_fsdp/experimental/parameter_group.py megatron/core/distributed/fsdp/src/megatron_fsdp/experimental/placement.py tests/unit_tests/distributed/megatron_fsdp/test_symmetric_memory.pypython -m torch.distributed.run --nproc-per-node 2 --standalone -m pytest -q tests/unit_tests/distributed/megatron_fsdp/test_symmetric_memory.py