Repository navigation
[ROCm][test] Reuse process groups across FSDP hybrid-shard subtests - #198302
chinmaydk99 wants to merge 1 commit into
Conversation
TestFSDPHybridShard is a continuous test, so its 8 worker processes are reused for every test in the class. test_fsdp_hybrid_shard_basic_setup built a new device mesh in each subtest and test_fsdp_hybrid_shard_parity built new HSDP process groups in each subtest. On RCCL every communicator keeps a ~40 MB proxy-ops segment per rank in /dev/shm until the workers exit. basic_setup left ~7 GB behind and parity then hit ENOSPC on a 10 GiB /dev/shm, passing only on retry with fresh workers. Build the mesh and the HSDP groups once per test and share them across subtests. Peak /dev/shm for the class on 8x MI300X at this commit drops from 11.4 GB to 7.5 GB, and all tests pass on a 10 GiB /dev/shm.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198302
Note: Links to docs will display an error until the docs builds have been completed. ❌ You can merge normally! (5 Unrelated Failures), 1 Unclassified FailureAs of commit edef885 with merge base f704053 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs 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. |
|
Warning: Unknown label
Please add the new label to .github/pytorch-probot.yml |
…ubtests (pytorch#198302) (#3691) Cherry-pick of pytorch#198302 into `release/2.12`. TestFSDPHybridShard is a continuous test, so its 8 worker processes are reused for every test in the class. test_fsdp_hybrid_shard_basic_setup built a new device mesh in each subtest and test_fsdp_hybrid_shard_parity built new HSDP process groups in each subtest. On RCCL every communicator keeps a ~40 MB proxy-ops segment per rank in /dev/shm until the workers exit. basic_setup left ~7 GB behind and parity then hit ENOSPC on a 10 GiB /dev/shm, passing only on retry with fresh workers. Build the mesh and the HSDP groups once per test and share them across subtests. Peak /dev/shm for the class on 8x MI300X at this commit drops from 11.4 GB to 7.5 GB, and all tests pass on a 10 GiB /dev/shm. Cherry-picked with `-x` from `edef8852b9461b1b86adeaf7eac4b9726fbc4167`; applied cleanly with no conflicts. Touches one file: `test/distributed/fsdp/test_fsdp_hybrid_shard.py` (+17/-10). **Note:** the upstream PR is still open at the time of this cherry-pick. If it is squashed or rebased on merge, the SHA in the `(cherry picked from ...)` trailer will not exist in `main` — the PR link above is the stable reference for provenance. **CI caveat for this branch:** `test_fsdp_hybrid_shard.py` currently collects 0 items on `release/2.12` (the file reports success having run nothing), so a green distributed run here does not exercise this change.
…ubtests (pytorch#198302) (#3692) Cherry-pick of pytorch#198302 into `release/2.13`. TestFSDPHybridShard is a continuous test, so its 8 worker processes are reused for every test in the class. test_fsdp_hybrid_shard_basic_setup built a new device mesh in each subtest and test_fsdp_hybrid_shard_parity built new HSDP process groups in each subtest. On RCCL every communicator keeps a ~40 MB proxy-ops segment per rank in /dev/shm until the workers exit. basic_setup left ~7 GB behind and parity then hit ENOSPC on a 10 GiB /dev/shm, passing only on retry with fresh workers. Build the mesh and the HSDP groups once per test and share them across subtests. Peak /dev/shm for the class on 8x MI300X at this commit drops from 11.4 GB to 7.5 GB, and all tests pass on a 10 GiB /dev/shm. Cherry-picked with `-x` from `edef8852b9461b1b86adeaf7eac4b9726fbc4167`; applied cleanly with no conflicts. Touches one file: `test/distributed/fsdp/test_fsdp_hybrid_shard.py` (+17/-10). **Note:** the upstream PR is still open at the time of this cherry-pick. If it is squashed or rebased on merge, the SHA in the `(cherry picked from ...)` trailer will not exist in `main` — the PR link above is the stable reference for provenance.
…ubtests (pytorch#198302) (#3693) Cherry-pick of pytorch#198302 into `release/2.14`. TestFSDPHybridShard is a continuous test, so its 8 worker processes are reused for every test in the class. test_fsdp_hybrid_shard_basic_setup built a new device mesh in each subtest and test_fsdp_hybrid_shard_parity built new HSDP process groups in each subtest. On RCCL every communicator keeps a ~40 MB proxy-ops segment per rank in /dev/shm until the workers exit. basic_setup left ~7 GB behind and parity then hit ENOSPC on a 10 GiB /dev/shm, passing only on retry with fresh workers. Build the mesh and the HSDP groups once per test and share them across subtests. Peak /dev/shm for the class on 8x MI300X at this commit drops from 11.4 GB to 7.5 GB, and all tests pass on a 10 GiB /dev/shm. Cherry-picked with `-x` from `edef8852b9461b1b86adeaf7eac4b9726fbc4167`; applied cleanly with no conflicts. Touches one file: `test/distributed/fsdp/test_fsdp_hybrid_shard.py` (+17/-10). **Note:** the upstream PR is still open at the time of this cherry-pick. If it is squashed or rebased on merge, the SHA in the `(cherry picked from ...)` trailer will not exist in `main` — the PR link above is the stable reference for provenance.
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 6 checks: Auto Request Review, periodic-rocm-mi200 / linux-jammy-rocm-py3.10-mi200 / test (distributed, 2, 3, linux.rocm.gpu.mi210.2, module:rocm, oncall:distributed), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 8, 8, amd-dpx-linux.rocm.gpu.gfx950.1), trunk / linux-noble-rocm-py3.11-mi350 / test (distributed, 3, 3, amd-dpx-linux.rocm.gpu.gfx950.2), periodic-rocm-mi300 / linux-noble-rocm-py3.11-mi300 / test (distributed, 1, 5, linux.rocm.gpu.mi300.4, module:rocm, oncall:distributed), periodic-rocm-mi300 / linux-noble-rocm-py3.11-mi300 / test (distributed, 4, 5, linux.rocm.gpu.mi300.4, module:rocm, oncall:distributed) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
## Linked issue or supporting maintainer Supported by @jeffdaily ## BC-breaking? No ## Summary (human written only) Follow-up to #198299, #198301 and #198302. Some FSDP/HSDP/TP distributed tests started failing with ENOSPC error again on 10 GiB `/dev/shm` after RCCL 2.32.3 doubled the per-communicator `/dev/shm` segment to 82.6 MB per rank. This change reuses or frees the groups they create (MoE expert group, TP and HSDP meshes, hybrid-shard auto groups) and runs each `tp_ep` configuration in its own processes. Peak `/dev/shm` drops from ~10.6 GB to at most 5.3 GB. ## Agent details (if applicable) I used Cursor (Claude) to root-cause the failures, write the change and run the validation below. I reviewed the code and the results. <details> <summary>Agent-generated details</summary> **Root cause.** RCCL's proxy-ops pool is sized as `ops[MAX_OPS_PER_PEER * NCCL_MAX_LOCAL_RANKS]` and `ncclShmOpen` `fallocate`s all of it. The NCCL v2.32.3 sync raised `NCCL_MAX_LOCAL_RANKS` from 72 to 144, so each communicator reserves 82,576,040 B per rank, up from ~41 MB. Only about 16 communicators per rank fit in 10 GiB on 8 GPUs. **Changes.** - `MixtureOfExperts` shares one size-1 expert group per parent group instead of creating one per model build. - `TestTPFSDPIntegration` and `TestHSDPWithDeviceMeshAndDTensor` build their mesh once per class, as in #198299. - `test_fsdp_hybrid_shard_basic_setup` destroys the groups FSDP auto-creates in its `use_device_mesh=False` subtests. Reusing them would skip the setup path under test. - `test_shard_placement_fn_tp_ep` is parametrized over `(tp_degree, dp_replicate)`, because it still needs ~27 communicators per rank with the #198301 reuse. **Rejected alternative.** Freeing `tp_ep`'s groups when its configuration changes fails with `Could not resolve the process group registered under the name 3`. `DeviceMesh.__eq__`/`__hash__` ignore process groups, so DTensor caches return an equal mesh whose groups were destroyed. A generic per-test group cleanup in `MultiProcContinuousTest` would hit the same hazard. **Validation.** 8x MI300X, 10 GiB `/dev/shm`, torch 2.13.0+rocm10.2.0a20261008 (RCCL 2.32.3). `test_fully_shard_training.py` on `main` needs a newer torch than this wheel, so its identical change was validated on release/2.13. ``` python -m pytest distributed/fsdp/test_fsdp_core.py -k mixture_of_experts -v --timeout 900 python -m pytest distributed/fsdp/test_fsdp_hybrid_shard.py -v --timeout 900 python -m pytest distributed/fsdp/test_fsdp_tp_integration.py -v --timeout 900 python -m pytest distributed/fsdp/test_hsdp_dtensor_state_dict.py -v --timeout 900 python -m pytest "distributed/_composable/fsdp/test_fully_shard_training.py::TestFullyShardNDTraining" -v --timeout 900 ``` | Scope | Before | After | Peak /dev/shm after | |---|---|---|---| | test_fsdp_core.py -k mixture_of_experts | ENOSPC | 12 passed | 1.3 GB | | test_fsdp_hybrid_shard.py | ENOSPC | 7 passed | 5.3 GB | | test_fsdp_tp_integration.py | ENOSPC | 3 passed | 2.0 GB | | test_hsdp_dtensor_state_dict.py | ENOSPC | 8 passed | 2.0 GB | | TestFullyShardNDTraining (incl. 4x tp_ep) | ENOSPC | 5 passed | 5.3 GB | `test_mixture_of_experts_offload_true_no_shard_cuda` also has a pre-existing, unrelated flaky FSDP-vs-DDP parity mismatch on ROCm, seen with RCCL 2.30.7 too. </details> Pull Request resolved: #200632 Approved by: https://github.com/jeffdaily
pytorch#200632) (#3808) ## Linked issue or supporting maintainer Supported by @jeffdaily ## BC-breaking? No ## Summary (human written only) Follow-up to pytorch#198299, pytorch#198301 and pytorch#198302. Some FSDP/HSDP/TP distributed tests started failing with ENOSPC error again on 10 GiB `/dev/shm` after RCCL 2.32.3 doubled the per-communicator `/dev/shm` segment to 82.6 MB per rank. This change reuses or frees the groups they create (MoE expert group, TP and HSDP meshes, hybrid-shard auto groups) and runs each `tp_ep` configuration in its own processes. Peak `/dev/shm` drops from ~10.6 GB to at most 5.3 GB. ## Agent details (if applicable) I used Cursor (Claude) to root-cause the failures, write the change and run the validation below. I reviewed the code and the results. <details> <summary>Agent-generated details</summary> **Root cause.** RCCL's proxy-ops pool is sized as `ops[MAX_OPS_PER_PEER * NCCL_MAX_LOCAL_RANKS]` and `ncclShmOpen` `fallocate`s all of it. The NCCL v2.32.3 sync raised `NCCL_MAX_LOCAL_RANKS` from 72 to 144, so each communicator reserves 82,576,040 B per rank, up from ~41 MB. Only about 16 communicators per rank fit in 10 GiB on 8 GPUs. **Changes.** - `MixtureOfExperts` shares one size-1 expert group per parent group instead of creating one per model build. - `TestTPFSDPIntegration` and `TestHSDPWithDeviceMeshAndDTensor` build their mesh once per class, as in pytorch#198299. - `test_fsdp_hybrid_shard_basic_setup` destroys the groups FSDP auto-creates in its `use_device_mesh=False` subtests. Reusing them would skip the setup path under test. - `test_shard_placement_fn_tp_ep` is parametrized over `(tp_degree, dp_replicate)`, because it still needs ~27 communicators per rank with the pytorch#198301 reuse. **Rejected alternative.** Freeing `tp_ep`'s groups when its configuration changes fails with `Could not resolve the process group registered under the name 3`. `DeviceMesh.__eq__`/`__hash__` ignore process groups, so DTensor caches return an equal mesh whose groups were destroyed. A generic per-test group cleanup in `MultiProcContinuousTest` would hit the same hazard. **Validation.** 8x MI300X, 10 GiB `/dev/shm`, torch 2.13.0+rocm10.2.0a20261008 (RCCL 2.32.3). `test_fully_shard_training.py` on `main` needs a newer torch than this wheel, so its identical change was validated on release/2.13. ``` python -m pytest distributed/fsdp/test_fsdp_core.py -k mixture_of_experts -v --timeout 900 python -m pytest distributed/fsdp/test_fsdp_hybrid_shard.py -v --timeout 900 python -m pytest distributed/fsdp/test_fsdp_tp_integration.py -v --timeout 900 python -m pytest distributed/fsdp/test_hsdp_dtensor_state_dict.py -v --timeout 900 python -m pytest "distributed/_composable/fsdp/test_fully_shard_training.py::TestFullyShardNDTraining" -v --timeout 900 ``` | Scope | Before | After | Peak /dev/shm after | |---|---|---|---| | test_fsdp_core.py -k mixture_of_experts | ENOSPC | 12 passed | 1.3 GB | | test_fsdp_hybrid_shard.py | ENOSPC | 7 passed | 5.3 GB | | test_fsdp_tp_integration.py | ENOSPC | 3 passed | 2.0 GB | | test_hsdp_dtensor_state_dict.py | ENOSPC | 8 passed | 2.0 GB | | TestFullyShardNDTraining (incl. 4x tp_ep) | ENOSPC | 5 passed | 5.3 GB | `test_mixture_of_experts_offload_true_no_shard_cuda` also has a pre-existing, unrelated flaky FSDP-vs-DDP parity mismatch on ROCm, seen with RCCL 2.30.7 too. </details> Pull Request resolved: pytorch#200632 Approved by: https://github.com/jeffdaily (cherry picked from commit 605ec3f)
TestFSDPHybridShard is a continuous test, so its 8 worker processes are reused for every test in the class. test_fsdp_hybrid_shard_basic_setup built a new device mesh in each subtest and test_fsdp_hybrid_shard_parity built new HSDP process groups in each subtest.
On RCCL every communicator keeps a ~40 MB proxy-ops segment per rank in /dev/shm until the workers exit. basic_setup left ~7 GB behind and parity then hit ENOSPC on a 10 GiB /dev/shm, passing only on retry with fresh workers.
Build the mesh and the HSDP groups once per test and share them across subtests. Peak /dev/shm for the class on 8x MI300X at this commit drops from 11.4 GB to 7.5 GB, and all tests pass on a 10 GiB /dev/shm.
cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang