Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/186335
Note: Links to docs will display an error until the docs builds have been completed. ❌ 8 New Failures, 1 Unrelated FailureAs of commit 7001fe3 with merge base f5d8a56 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
```
python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \
TestFullyShardOverlap.test_set_separate_reduce_scatter_group \
TestFullyShardOverlap.test_fully_shard_backward_comm_overlap
```
Both pass on 4xH100:
- test_set_separate_reduce_scatter_group: default shares the shard PG; enabling
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
- test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
ghstack-source-id: 13013ba
Pull-Request: #186335
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
```
python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \
TestFullyShardOverlap.test_set_separate_reduce_scatter_group \
TestFullyShardOverlap.test_fully_shard_backward_comm_overlap
```
Both pass on 4xH100:
- test_set_separate_reduce_scatter_group: default shares the shard PG; enabling
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
- test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
ghstack-source-id: 13013ba
Pull-Request: #186335
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
```
python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \
TestFullyShardOverlap.test_set_separate_reduce_scatter_group \
TestFullyShardOverlap.test_fully_shard_backward_comm_overlap
```
Both pass on 4xH100:
- test_set_separate_reduce_scatter_group: default shares the shard PG; enabling
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
- test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
ghstack-source-id: 6364399
Pull-Request: #186335
|
@pytorchmergebot merge -i |
|
This PR needs to be approved by an authorized maintainer before merge. |
|
@claude review this pr |
|
Claude finished @anshul-si's task in 3m 29s —— View job Review of PR #186335: [FSDP2] Add
|
|
@pytorchmergebot merge -i |
Merge startedYour change will be merged while ignoring the following 2 checks: torchtitan-test / torchtitan-x-pytorch-test / test-osdc (torchtitan_features_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), inductor / inductor-test / test-osdc (inductor_huggingface, 1, 1, mt-l-x86aavx2-29-113-a10g) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
```
python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \
TestFullyShardOverlap.test_set_separate_reduce_scatter_group \
TestFullyShardOverlap.test_fully_shard_backward_comm_overlap
```
Both pass on 4xH100:
- test_set_separate_reduce_scatter_group: default shares the shard PG; enabling
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
- test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
ghstack-source-id: c0ca593
Pull-Request: #186335
Merge failedReason: New commits were pushed while merging. Please rerun the merge command. Details for Dev Infra teamRaised by workflow job |
|
@pytorchmergebot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
[ghstack-poisoned] Co-authored-by: Lei Tian <[email protected]>
9478aff to
3c68888
Compare
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
```
python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \
TestFullyShardOverlap.test_set_separate_reduce_scatter_group \
TestFullyShardOverlap.test_fully_shard_backward_comm_overlap
```
Both pass on 4xH100:
- test_set_separate_reduce_scatter_group: default shares the shard PG; enabling
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
- test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
ghstack-source-id: c0ca593
Pull-Request: #186335
Co-authored-by: Lei Tian <[email protected]>
Merge failedReason: New commits were pushed while merging. Please rerun the merge command. Details for Dev Infra teamRaised by workflow job |
[ghstack-poisoned] Co-authored-by: Lei Tian <[email protected]>
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
```
python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \
TestFullyShardOverlap.test_set_separate_reduce_scatter_group \
TestFullyShardOverlap.test_fully_shard_backward_comm_overlap
```
Both pass on 4xH100:
- test_set_separate_reduce_scatter_group: default shares the shard PG; enabling
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
- test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
ghstack-source-id: 0b0a02b
Pull-Request: #186335
Co-authored-by: Lei Tian <[email protected]>
[ghstack-poisoned] Co-authored-by: Lei Tian <[email protected]>
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
```
python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \
TestFullyShardOverlap.test_set_separate_reduce_scatter_group \
TestFullyShardOverlap.test_fully_shard_backward_comm_overlap
```
Both pass on 4xH100:
- test_set_separate_reduce_scatter_group: default shares the shard PG; enabling
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
- test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
ghstack-source-id: ae2c755
Pull-Request: #186335
Co-authored-by: Lei Tian <[email protected]>
|
@pytorchmergebot merge -i |
…ytorch#186335) By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but through the same process group -- one NCCL communicator, which processes one collective at a time and so serializes them on the wire. This adds an opt-in FSDPModule API to give reduce-scatter its own communicator: FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True) When enabled, FSDP creates a dedicated process group over the shard ranks (dist.new_group), one per distinct set of shard ranks (typically one communicator), so reduce-scatter and all-gather can progress concurrently when the network can sustain it; enable=False resets to the shared group. The default is unchanged -- reduce-scatter shares the shard process group -- so this is purely opt-in and creates no extra communicators unless requested. This redesigns the approach explored in (closed) PR pytorch#177015, which made the separate communicator the unconditional default (and created one even for post-forward meshes); here it is an opt-in toggle. Test Plan: ``` python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \ TestFullyShardOverlap.test_set_separate_reduce_scatter_group \ TestFullyShardOverlap.test_fully_shard_backward_comm_overlap ``` Both pass on 4xH100: - test_set_separate_reduce_scatter_group: default shares the shard PG; enabling creates one dedicated PG shared across same-rank-set meshes; disabling resets to the shared PG. - test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large matmuls + collectives) is no slower than a serialized single-communicator reference. Authored with Claude. Co-authored-by: Lei Tian <[email protected]> Pull Request resolved: pytorch#186335 Approved by: https://github.com/anshul-si ghstack dependencies: pytorch#186000 Co-authored-by: Lei Tian <[email protected]>
…ytorch#186335) By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but through the same process group -- one NCCL communicator, which processes one collective at a time and so serializes them on the wire. This adds an opt-in FSDPModule API to give reduce-scatter its own communicator: FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True) When enabled, FSDP creates a dedicated process group over the shard ranks (dist.new_group), one per distinct set of shard ranks (typically one communicator), so reduce-scatter and all-gather can progress concurrently when the network can sustain it; enable=False resets to the shared group. The default is unchanged -- reduce-scatter shares the shard process group -- so this is purely opt-in and creates no extra communicators unless requested. This redesigns the approach explored in (closed) PR pytorch#177015, which made the separate communicator the unconditional default (and created one even for post-forward meshes); here it is an opt-in toggle. Test Plan: ``` python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \ TestFullyShardOverlap.test_set_separate_reduce_scatter_group \ TestFullyShardOverlap.test_fully_shard_backward_comm_overlap ``` Both pass on 4xH100: - test_set_separate_reduce_scatter_group: default shares the shard PG; enabling creates one dedicated PG shared across same-rank-set meshes; disabling resets to the shared PG. - test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large matmuls + collectives) is no slower than a serialized single-communicator reference. Authored with Claude. Co-authored-by: Lei Tian <[email protected]> Pull Request resolved: pytorch#186335 Approved by: https://github.com/anshul-si ghstack dependencies: pytorch#186000 Co-authored-by: Lei Tian <[email protected]>
…ytorch#186335) By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but through the same process group -- one NCCL communicator, which processes one collective at a time and so serializes them on the wire. This adds an opt-in FSDPModule API to give reduce-scatter its own communicator: FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True) When enabled, FSDP creates a dedicated process group over the shard ranks (dist.new_group), one per distinct set of shard ranks (typically one communicator), so reduce-scatter and all-gather can progress concurrently when the network can sustain it; enable=False resets to the shared group. The default is unchanged -- reduce-scatter shares the shard process group -- so this is purely opt-in and creates no extra communicators unless requested. This redesigns the approach explored in (closed) PR pytorch#177015, which made the separate communicator the unconditional default (and created one even for post-forward meshes); here it is an opt-in toggle. Test Plan: ``` python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \ TestFullyShardOverlap.test_set_separate_reduce_scatter_group \ TestFullyShardOverlap.test_fully_shard_backward_comm_overlap ``` Both pass on 4xH100: - test_set_separate_reduce_scatter_group: default shares the shard PG; enabling creates one dedicated PG shared across same-rank-set meshes; disabling resets to the shared PG. - test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large matmuls + collectives) is no slower than a serialized single-communicator reference. Authored with Claude. Co-authored-by: Lei Tian <[email protected]> Pull Request resolved: pytorch#186335 Approved by: https://github.com/anshul-si ghstack dependencies: pytorch#186000 Co-authored-by: Lei Tian <[email protected]>
…ytorch#186335) By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but through the same process group -- one NCCL communicator, which processes one collective at a time and so serializes them on the wire. This adds an opt-in FSDPModule API to give reduce-scatter its own communicator: FSDPModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True) When enabled, FSDP creates a dedicated process group over the shard ranks (dist.new_group), one per distinct set of shard ranks (typically one communicator), so reduce-scatter and all-gather can progress concurrently when the network can sustain it; enable=False resets to the shared group. The default is unchanged -- reduce-scatter shares the shard process group -- so this is purely opt-in and creates no extra communicators unless requested. This redesigns the approach explored in (closed) PR pytorch#177015, which made the separate communicator the unconditional default (and created one even for post-forward meshes); here it is an opt-in toggle. Test Plan: ``` python test/distributed/_composable/fsdp/test_fully_shard_overlap.py \ TestFullyShardOverlap.test_set_separate_reduce_scatter_group \ TestFullyShardOverlap.test_fully_shard_backward_comm_overlap ``` Both pass on 4xH100: - test_set_separate_reduce_scatter_group: default shares the shard PG; enabling creates one dedicated PG shared across same-rank-set meshes; disabling resets to the shared PG. - test_fully_shard_backward_comm_overlap: real backward AG/RS overlap (large matmuls + collectives) is no slower than a serialized single-communicator reference. Authored with Claude. Co-authored-by: Lei Tian <[email protected]> Pull Request resolved: pytorch#186335 Approved by: https://github.com/anshul-si ghstack dependencies: pytorch#186000 Co-authored-by: Lei Tian <[email protected]>
Clears six MI200 (gfx90a) test gates and widens one tolerance. Each was root-caused on a 4x gfx90a host first; the two MI200 skips that turned out to be real library bugs stay, now with issue links. - **elastic `test_tcp`** (DISABLED #144689) was never a gfx90a problem. `_WorkerServer("", 1234)` binds IPv6-only on the ROCm runners, where `getaddrinfo("localhost")` returns only `127.0.0.1`, so the request is refused; the hardcoded port was a second latent failure mode on shared runners. Binding `("127.0.0.1", 0)` and reading `_WorkerServer.port` fixes both on every platform, so the arch gate goes away with the bug. - **`TestExternKernelCaller`** (#170205, #162803): both gates were added with no recorded root cause, and neither test has a gfx90a-specific failure mode on record. The timing test's separate gfx942 flakiness is a Triton codegen bug handled in #196673. - **`TestFullyShardOverlap`**: one gate is from a ROCm 6.1-era DISABLED issue (#134139), the other was preemptive when the test landed (#186335); both are clean under stress on a current stack. The two `TestFullyShardPerParamMeshOverlap` gates stay - those hang 100% of the time on gfx90a with HSA queues frozen behind partially written packets, an RCCL launch-tracking deadlock filed as ROCm/rccl#2191. - **`test_deleted_mempool_not_used_on_oom`**: the MI200 gate is dead code under the unconditional Linux skip for #176145 above it, so dropping it changes no test selection. The DDP fp16 grad-layout tolerance is the one real numerics change. On gfx90a the fp16 case fails deterministically at 3.0e-3, always the same 1-of-512 element at 3.067e-3 absolute, reproducing byte for byte across machines and builds. It is not fp16 arithmetic: a CPU fp16 run tracks fp64 to 7e-6 while the MIOpen GPU run is off by 2.5e-3 on a gradient whose maximum magnitude is 5.4e-3. Per-op bisection localizes it to conv1's data and weight gradients amplified through conv0's 1568-term reduction, and `MIOPEN_DEBUG_CONV_IMPLICIT_GEMM=0` drops the error ~70x; the solvers are `ConvHipImplicitGemmGroup{Bwd,Wrw}Xdlops`, which MIOpen picks for these shapes only on gfx90a. Filed as ROCm/rocm-libraries#11938. The 8.0e-3 bound is measured, not fitted: over a 31-seed sweep the worst DDP versus full-batch difference is 3.8e-3 with each side up to 4.7e-3 from an fp64 reference, bounding the comparison at ~7.4e-3. It applies only to fp16 on gfx90a; CUDA and every other ROCm architecture keep 3.0e-3. Test plan: on a 4x gfx90a (MI250X) host with ROCm 7.14, each affected test x25 in isolation, then its class, then the full file, plus lintrunner on every touched file. Every unskipped test is 25/25; the DDP fp16 case is 25/25 with the new tolerance and 0/10 without. Residual full-file failures reproduce identically on the unmodified files on that box. Cross-architecture coverage comes from the ciflow labels. This description and the changes were authored with the assistance of Claude, an AI assistant, and reviewed by me. Pull Request resolved: #196674 Approved by: https://github.com/jeffdaily Co-authored-by: Jeff Daily <[email protected]>
…#118) Summary: Pull Request resolved: meta-pytorch#118 Ported from meta-pytorch#84 (weifengpy). Applied unchanged. A bucket's all-gathers and reduce-scatters run on separate streams but through its mesh's process group: one NCCL communicator, which runs one collective at a time, so a backward all-gather waits behind the reduce-scatter issued before it. meta-pytorch#84 measured, on 256 H100s with Llama 3.1 405B (blockwise FP8, 4,096 tokens per GPU): the all-gathers and reduce-scatters never overlapped, and a gather that started within 5 ms of a reduce-scatter's end took 46-47 ms against 27-28 ms after another gather. 85% of the backward gathers started that close, so the network time was the sum of both collectives (152.6 s of a 168 s step). FSDP2 has the same pattern, and `FSDPModule.set_separate_reduce_scatter_group` (pytorch/pytorch#186335) as the opt-in fix. `FlexShardModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)` is its counterpart: each bucket reduce-scatters over a `DeviceMesh` built from a dedicated process group over its mesh's ranks (`dist.new_group` with local synchronization, one per distinct set of ranks, shared by the buckets, as FSDP2 shares its group), so the two collectives can progress together. Enabling again keeps the group; `False` goes back to the mesh's. 1-D meshes only; a 1-rank mesh has nothing to separate. The reduce path reads the bucket's `reduce_mesh` where it read its mesh, eager and compiled. The FlexShard MXFP8 Dist-MoE benchmarks ran with this enabled in the FlexShard arm, and FSDP2's counterpart in the FSDP2 arm. fbcode torchtitan has no config option for it yet. Reviewed By: weifengpy Differential Revision: D127640092
…#118) Summary: Ported from meta-pytorch#84 (weifengpy). Applied unchanged. A bucket's all-gathers and reduce-scatters run on separate streams but through its mesh's process group: one NCCL communicator, which runs one collective at a time, so a backward all-gather waits behind the reduce-scatter issued before it. meta-pytorch#84 measured, on 256 H100s with Llama 3.1 405B (blockwise FP8, 4,096 tokens per GPU): the all-gathers and reduce-scatters never overlapped, and a gather that started within 5 ms of a reduce-scatter's end took 46-47 ms against 27-28 ms after another gather. 85% of the backward gathers started that close, so the network time was the sum of both collectives (152.6 s of a 168 s step). FSDP2 has the same pattern, and `FSDPModule.set_separate_reduce_scatter_group` (pytorch/pytorch#186335) as the opt-in fix. `FlexShardModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)` is its counterpart: each bucket reduce-scatters over a `DeviceMesh` built from a dedicated process group over its mesh's ranks (`dist.new_group` with local synchronization, one per distinct set of ranks, shared by the buckets, as FSDP2 shares its group), so the two collectives can progress together. Enabling again keeps the group; `False` goes back to the mesh's. 1-D meshes only; a 1-rank mesh has nothing to separate. The reduce path reads the bucket's `reduce_mesh` where it read its mesh, eager and compiled. The FlexShard MXFP8 Dist-MoE benchmarks ran with this enabled in the FlexShard arm, and FSDP2's counterpart in the FSDP2 arm. fbcode torchtitan has no config option for it yet. Reviewed By: weifengpy Differential Revision: D127640092
Summary: Ported from #84 (weifengpy). Applied unchanged. A bucket's all-gathers and reduce-scatters run on separate streams but through its mesh's process group: one NCCL communicator, which runs one collective at a time, so a backward all-gather waits behind the reduce-scatter issued before it. #84 measured, on 256 H100s with Llama 3.1 405B (blockwise FP8, 4,096 tokens per GPU): the all-gathers and reduce-scatters never overlapped, and a gather that started within 5 ms of a reduce-scatter's end took 46-47 ms against 27-28 ms after another gather. 85% of the backward gathers started that close, so the network time was the sum of both collectives (152.6 s of a 168 s step). FSDP2 has the same pattern, and `FSDPModule.set_separate_reduce_scatter_group` (pytorch/pytorch#186335) as the opt-in fix. `FlexShardModule.set_separate_reduce_scatter_group(enable=True, *, recurse=True)` is its counterpart: each bucket reduce-scatters over a `DeviceMesh` built from a dedicated process group over its mesh's ranks (`dist.new_group` with local synchronization, one per distinct set of ranks, shared by the buckets, as FSDP2 shares its group), so the two collectives can progress together. Enabling again keeps the group; `False` goes back to the mesh's. 1-D meshes only; a 1-rank mesh has nothing to separate. The reduce path reads the bucket's `reduce_mesh` where it read its mesh, eager and compiled. The FlexShard MXFP8 Dist-MoE benchmarks ran with this enabled in the FlexShard arm, and FSDP2's counterpart in the FSDP2 arm. fbcode torchtitan has no config option for it yet. Reviewed By: weifengpy Differential Revision: D127640092 Pull Request resolved: #118
Stack from ghstack (oldest at bottom):
By default FSDP2 runs all-gather and reduce-scatter on separate CUDA streams but
through the same process group -- one NCCL communicator, which processes one
collective at a time and so serializes them on the wire. This adds an opt-in
FSDPModule API to give reduce-scatter its own communicator:
When enabled, FSDP creates a dedicated process group over the shard ranks
(dist.new_group), one per distinct set of shard ranks (typically one
communicator), so reduce-scatter and all-gather can progress concurrently when
the network can sustain it; enable=False resets to the shared group. The default
is unchanged -- reduce-scatter shares the shard process group -- so this is
purely opt-in and creates no extra communicators unless requested.
This redesigns the approach explored in (closed) PR #177015, which made the
separate communicator the unconditional default (and created one even for
post-forward meshes); here it is an opt-in toggle.
Test Plan:
Both pass on 4xH100:
creates one dedicated PG shared across same-rank-set meshes; disabling resets
to the shared PG.
matmuls + collectives) is no slower than a serialized single-communicator
reference.
Authored with Claude.
Co-authored-by: Lei Tian [email protected]