Repository navigation
[ROCm][test] Keep composability and FSDP prefetch/frozen tests within the RCCL /dev/shm budget - #202272
Closed
albmalamd wants to merge 1 commit into
Closed
[ROCm][test] Keep composability and FSDP prefetch/frozen tests within the RCCL /dev/shm budget#202272albmalamd wants to merge 1 commit into
albmalamd wants to merge 1 commit into
Conversation
… the RCCL /dev/shm budget Follow-up to pytorch#198299 and pytorch#200632. On ROCm with RCCL 2.32.3, these tests fail on a 10 GiB /dev/shm with: Error while creating shared memory segment /dev/shm/nccl-XXXXXX (size 82576040), error: No space left on device (28) or, when the error hits a child process, with "Expected exit code 0 but got -6". RCCL's proxy-ops pool is sized for NCCL_MAX_LOCAL_RANKS (144) and fully fallocate()d, so every communicator costs 82.6 MB of /dev/shm per rank until the test processes exit. The over-reservation is being fixed in RCCL separately; this change keeps the tests well within the budget regardless. test/distributed/test_composability.py has its own ComposabilityTest, which pytorch#198299 did not cover (it changed _composable/test_composability/ test_pp_composability.py). Its workers are reused for the whole class and every test_pp_* built a new mesh, so it now builds each distinct mesh once per class, using the same _get_mesh helper as pytorch#198299. TestFullyShardPrefetch and TestFullyShardFrozen already run each test in fresh processes, but a single test exhausts /dev/shm on its own: fully_shard(reshard_after_forward=2) builds a new post-forward mesh on every call, and its groups live until the processes exit. The tests cannot reuse these meshes because FSDP creates them internally, so the reshard_after_forward=2 subtests move to new parametrized tests, test_fully_shard_backward_prefetch_reshard_to_2_* and test_train_mixed_requires_grad_per_group_reshard_to_2_*, which run each variant in its own processes, as pytorch#200632 does for tp_ep. Coverage is unchanged. Destroying the groups at the end of each test or subtest was not used: DeviceMesh equality ignores process groups, so DTensor caches can hand back an equal mesh whose groups were destroyed (see pytorch#200632). Test Plan: 8x MI300X, 10 GiB /dev/shm, torch 2.15.0+rocm10.2.0rc0 (RCCL 2.32.3, as shipped in the wheel), with this change applied on release/2.15, where the three files match main apart from tests that this change does not touch (main's test_fully_shard_comm.py imports torch.distributed.fsdp.experimental, which the wheel lacks, and adds test_unused_backward_prefetch_with_post_forward_mesh to TestFullyShardPrefetch). Each file was run whole, twice with this change and once without it: ``` cd test export PYTORCH_TEST_WITH_ROCM=1 PYTORCH_TESTING_DEVICE_ONLY_FOR=cuda BACKEND=nccl WORLD_SIZE=8 TEMP_DIR=$(mktemp -d) python -m pytest -v -s distributed/test_composability.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_comm.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_frozen.py ``` | File | Before | After (2 runs) | Peak /dev/shm before -> after | |---|---|---|---| | test_composability.py | test_pp_fsdp_* ENOSPC | 20 passed, 2 skipped | 10197 MB -> 2547 MB | | test_fully_shard_comm.py | test_fully_shard_backward_prefetch ENOSPC | 39 passed, 1 skipped | 10108 MB -> 6642 MB | | test_fully_shard_frozen.py | test_train_mixed_requires_grad_per_group ENOSPC | 5 passed | 10189 MB -> 7902 MB | Runtime is unchanged or lower (test_composability.py: 76-86 s -> 42-50 s; the other two files within run-to-run noise). The frozen file's peak comes from the untouched test_train_mixed_requires_grad_across_groups. lintrunner was not available in the environment and was not run. This commit was authored with the help of an AI assistant (Cursor). Co-authored-by: Cursor <[email protected]>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202272
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4e1bfca with merge base 7c6df23 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
jeffdaily
marked this pull request as ready for review
October 27, 2026 21:14
Collaborator
|
@pytorchbot merge |
Collaborator
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 |
Collaborator
Merge failedReason: 1 jobs have failed, first few of them are: Auto Request Review Details for Dev Infra teamRaised by workflow job |
Collaborator
|
@pytorchbot merge |
Collaborator
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 |
albmalamd
added a commit
to ROCm/pytorch
that referenced
this pull request
Nov 4, 2026
… the RCCL /dev/shm budget (pytorch#202272) ## Linked issue or supporting maintainer Supported by @jeffdaily ## BC-breaking? No ## Summary (human written only) Follow-up to pytorch#198299 and pytorch#200632. `test_composability.py::ComposabilityTest`, `TestFullyShardPrefetch::test_fully_shard_backward_prefetch` and `TestFullyShardFrozen::test_train_mixed_requires_grad_per_group` fail with ENOSPC on a 10 GiB `/dev/shm`, because RCCL 2.32.3 reserves 82.6 MB of `/dev/shm` per communicator per rank. `ComposabilityTest` now builds each mesh once per class, as pytorch#198299 did for `test_pp_composability.py`. The `reshard_after_forward=2` subtests of the two FSDP tests run in their own processes, as pytorch#200632 does for `tp_ep`. Peak `/dev/shm` drops from ~10.2 GB to at most 7.9 GB, and runtime does not increase. ## 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]` with `NCCL_MAX_LOCAL_RANKS` = 144, and `ncclShmOpen` `fallocate`s all of it, so every communicator reserves 82,576,040 B of `/dev/shm` per rank until the processes exit. Only `localRanks` of the 144 slots are ever used. **Changes.** - `test/distributed/test_composability.py` has its own `ComposabilityTest`, separate from the one pytorch#198299 changed in `_composable/test_composability/test_pp_composability.py`. Its workers are reused for the whole class, and every `test_pp_*` built a new `("dp", "pp")` mesh: 2 communicators per rank (16 across the 8 ranks) per test, 14 tests. It now uses the same class-level `_get_mesh` cache as pytorch#198299, so the class builds 2 meshes. - `TestFullyShardPrefetch` and `TestFullyShardFrozen` already run each test in fresh processes, but a single test exhausts `/dev/shm`. `fully_shard(reshard_after_forward=2)` builds a new post-forward `DeviceMesh` on every call, and its groups live until the processes exit: 48 two-rank communicators per rank in the prefetch test, 32 in the frozen test. FSDP creates these meshes internally, so a test cannot reuse them. The `reshard_after_forward=2` subtests therefore move to: - `test_fully_shard_backward_prefetch_reshard_to_2_{None,utils,composable}`; - `test_train_mixed_requires_grad_per_group_reshard_to_2_use_activation_checkpointing_{False,True}`. Each new test runs its variant in its own processes. Coverage is unchanged. **Rejected alternative.** Destroying groups at the end of a test or subtest: `DeviceMesh.__eq__`/`__hash__` ignore process groups, so DTensor caches can return an equal mesh whose groups were destroyed (see pytorch#200632). **Validation.** 8x MI300X, 10 GiB `/dev/shm`, torch 2.15.0+rocm10.2.0rc0, with RCCL 2.32.3 as shipped in the wheel. The same change was applied on release/2.15, because `main`'s `test_fully_shard_comm.py` imports `torch.distributed.fsdp.experimental`, which that wheel lacks. On release/2.15, `test_composability.py` and `test_fully_shard_frozen.py` match `main`. `main`'s `test_fully_shard_comm.py` also has tests this change does not touch, and they were not run: `test_numerics_with_leading_dims`, several `TestCase` and `FSDPTestMultiThread` classes that create no RCCL communicators, and `test_unused_backward_prefetch_with_post_forward_mesh` in `TestFullyShardPrefetch`, which makes three `reshard_after_forward=2` calls in its own processes. Each file was run whole, twice with this change and once without it. ``` cd test export PYTORCH_TEST_WITH_ROCM=1 PYTORCH_TESTING_DEVICE_ONLY_FOR=cuda BACKEND=nccl WORLD_SIZE=8 TEMP_DIR=$(mktemp -d) python -m pytest -v -s distributed/test_composability.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_comm.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_frozen.py ``` | File | Before | After (2 runs) | Peak /dev/shm before -> after | Runtime before -> after | |---|---|---|---|---| | test_composability.py | `test_pp_fsdp_*` ENOSPC | 20 passed, 2 skipped | 10197 MB -> 2547 MB | 76-86 s -> 42-50 s | | test_fully_shard_comm.py | `test_fully_shard_backward_prefetch` ENOSPC (exit -6) | 39 passed, 1 skipped | 10108 MB -> 6642 MB | 589 s -> 567-590 s | | test_fully_shard_frozen.py | `test_train_mixed_requires_grad_per_group` ENOSPC (exit -6) | 5 passed | 10189 MB -> 7902 MB | 146 s -> 140-149 s | The frozen file's 7902 MB peak comes from the untouched `test_train_mixed_requires_grad_across_groups`. </details> Pull Request resolved: pytorch#202272 Approved by: https://github.com/jeffdaily Co-authored-by: Cursor <[email protected]> (cherry picked from commit 4a73df5)
pragupta
pushed a commit
to ROCm/pytorch
that referenced
this pull request
Nov 4, 2026
…s within the RCCL /dev/shm budget (pytorch#202272) (#3940) ## Linked issue or supporting maintainer Supported by @jeffdaily ## BC-breaking? No ## Summary (human written only) Follow-up to pytorch#198299 and pytorch#200632. `test_composability.py::ComposabilityTest`, `TestFullyShardPrefetch::test_fully_shard_backward_prefetch` and `TestFullyShardFrozen::test_train_mixed_requires_grad_per_group` fail with ENOSPC on a 10 GiB `/dev/shm`, because RCCL 2.32.3 reserves 82.6 MB of `/dev/shm` per communicator per rank. `ComposabilityTest` now builds each mesh once per class, as pytorch#198299 did for `test_pp_composability.py`. The `reshard_after_forward=2` subtests of the two FSDP tests run in their own processes, as pytorch#200632 does for `tp_ep`. Peak `/dev/shm` drops from ~10.2 GB to at most 7.9 GB, and runtime does not increase. ## 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]` with `NCCL_MAX_LOCAL_RANKS` = 144, and `ncclShmOpen` `fallocate`s all of it, so every communicator reserves 82,576,040 B of `/dev/shm` per rank until the processes exit. Only `localRanks` of the 144 slots are ever used. **Changes.** - `test/distributed/test_composability.py` has its own `ComposabilityTest`, separate from the one pytorch#198299 changed in `_composable/test_composability/test_pp_composability.py`. Its workers are reused for the whole class, and every `test_pp_*` built a new `("dp", "pp")` mesh: 2 communicators per rank (16 across the 8 ranks) per test, 14 tests. It now uses the same class-level `_get_mesh` cache as pytorch#198299, so the class builds 2 meshes. - `TestFullyShardPrefetch` and `TestFullyShardFrozen` already run each test in fresh processes, but a single test exhausts `/dev/shm`. `fully_shard(reshard_after_forward=2)` builds a new post-forward `DeviceMesh` on every call, and its groups live until the processes exit: 48 two-rank communicators per rank in the prefetch test, 32 in the frozen test. FSDP creates these meshes internally, so a test cannot reuse them. The `reshard_after_forward=2` subtests therefore move to: - `test_fully_shard_backward_prefetch_reshard_to_2_{None,utils,composable}`; - `test_train_mixed_requires_grad_per_group_reshard_to_2_use_activation_checkpointing_{False,True}`. Each new test runs its variant in its own processes. Coverage is unchanged. **Rejected alternative.** Destroying groups at the end of a test or subtest: `DeviceMesh.__eq__`/`__hash__` ignore process groups, so DTensor caches can return an equal mesh whose groups were destroyed (see pytorch#200632). **Validation.** 8x MI300X, 10 GiB `/dev/shm`, torch 2.15.0+rocm10.2.0rc0, with RCCL 2.32.3 as shipped in the wheel. The same change was applied on release/2.15, because `main`'s `test_fully_shard_comm.py` imports `torch.distributed.fsdp.experimental`, which that wheel lacks. On release/2.15, `test_composability.py` and `test_fully_shard_frozen.py` match `main`. `main`'s `test_fully_shard_comm.py` also has tests this change does not touch, and they were not run: `test_numerics_with_leading_dims`, several `TestCase` and `FSDPTestMultiThread` classes that create no RCCL communicators, and `test_unused_backward_prefetch_with_post_forward_mesh` in `TestFullyShardPrefetch`, which makes three `reshard_after_forward=2` calls in its own processes. Each file was run whole, twice with this change and once without it. ``` cd test export PYTORCH_TEST_WITH_ROCM=1 PYTORCH_TESTING_DEVICE_ONLY_FOR=cuda BACKEND=nccl WORLD_SIZE=8 TEMP_DIR=$(mktemp -d) python -m pytest -v -s distributed/test_composability.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_comm.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_frozen.py ``` | File | Before | After (2 runs) | Peak /dev/shm before -> after | Runtime before -> after | |---|---|---|---|---| | test_composability.py | `test_pp_fsdp_*` ENOSPC | 20 passed, 2 skipped | 10197 MB -> 2547 MB | 76-86 s -> 42-50 s | | test_fully_shard_comm.py | `test_fully_shard_backward_prefetch` ENOSPC (exit -6) | 39 passed, 1 skipped | 10108 MB -> 6642 MB | 589 s -> 567-590 s | | test_fully_shard_frozen.py | `test_train_mixed_requires_grad_per_group` ENOSPC (exit -6) | 5 passed | 10189 MB -> 7902 MB | 146 s -> 140-149 s | The frozen file's 7902 MB peak comes from the untouched `test_train_mixed_requires_grad_across_groups`. </details> Pull Request resolved: pytorch#202272 Approved by: https://github.com/jeffdaily (cherry picked from commit 4a73df5) Co-authored-by: Cursor <[email protected]>
dominikjastrzebskix
pushed a commit
to dominikjastrzebskix/pytorch
that referenced
this pull request
Nov 5, 2026
… the RCCL /dev/shm budget (pytorch#202272) ## Linked issue or supporting maintainer Supported by @jeffdaily ## BC-breaking? No ## Summary (human written only) Follow-up to pytorch#198299 and pytorch#200632. `test_composability.py::ComposabilityTest`, `TestFullyShardPrefetch::test_fully_shard_backward_prefetch` and `TestFullyShardFrozen::test_train_mixed_requires_grad_per_group` fail with ENOSPC on a 10 GiB `/dev/shm`, because RCCL 2.32.3 reserves 82.6 MB of `/dev/shm` per communicator per rank. `ComposabilityTest` now builds each mesh once per class, as pytorch#198299 did for `test_pp_composability.py`. The `reshard_after_forward=2` subtests of the two FSDP tests run in their own processes, as pytorch#200632 does for `tp_ep`. Peak `/dev/shm` drops from ~10.2 GB to at most 7.9 GB, and runtime does not increase. ## 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]` with `NCCL_MAX_LOCAL_RANKS` = 144, and `ncclShmOpen` `fallocate`s all of it, so every communicator reserves 82,576,040 B of `/dev/shm` per rank until the processes exit. Only `localRanks` of the 144 slots are ever used. **Changes.** - `test/distributed/test_composability.py` has its own `ComposabilityTest`, separate from the one pytorch#198299 changed in `_composable/test_composability/test_pp_composability.py`. Its workers are reused for the whole class, and every `test_pp_*` built a new `("dp", "pp")` mesh: 2 communicators per rank (16 across the 8 ranks) per test, 14 tests. It now uses the same class-level `_get_mesh` cache as pytorch#198299, so the class builds 2 meshes. - `TestFullyShardPrefetch` and `TestFullyShardFrozen` already run each test in fresh processes, but a single test exhausts `/dev/shm`. `fully_shard(reshard_after_forward=2)` builds a new post-forward `DeviceMesh` on every call, and its groups live until the processes exit: 48 two-rank communicators per rank in the prefetch test, 32 in the frozen test. FSDP creates these meshes internally, so a test cannot reuse them. The `reshard_after_forward=2` subtests therefore move to: - `test_fully_shard_backward_prefetch_reshard_to_2_{None,utils,composable}`; - `test_train_mixed_requires_grad_per_group_reshard_to_2_use_activation_checkpointing_{False,True}`. Each new test runs its variant in its own processes. Coverage is unchanged. **Rejected alternative.** Destroying groups at the end of a test or subtest: `DeviceMesh.__eq__`/`__hash__` ignore process groups, so DTensor caches can return an equal mesh whose groups were destroyed (see pytorch#200632). **Validation.** 8x MI300X, 10 GiB `/dev/shm`, torch 2.15.0+rocm10.2.0rc0, with RCCL 2.32.3 as shipped in the wheel. The same change was applied on release/2.15, because `main`'s `test_fully_shard_comm.py` imports `torch.distributed.fsdp.experimental`, which that wheel lacks. On release/2.15, `test_composability.py` and `test_fully_shard_frozen.py` match `main`. `main`'s `test_fully_shard_comm.py` also has tests this change does not touch, and they were not run: `test_numerics_with_leading_dims`, several `TestCase` and `FSDPTestMultiThread` classes that create no RCCL communicators, and `test_unused_backward_prefetch_with_post_forward_mesh` in `TestFullyShardPrefetch`, which makes three `reshard_after_forward=2` calls in its own processes. Each file was run whole, twice with this change and once without it. ``` cd test export PYTORCH_TEST_WITH_ROCM=1 PYTORCH_TESTING_DEVICE_ONLY_FOR=cuda BACKEND=nccl WORLD_SIZE=8 TEMP_DIR=$(mktemp -d) python -m pytest -v -s distributed/test_composability.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_comm.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_frozen.py ``` | File | Before | After (2 runs) | Peak /dev/shm before -> after | Runtime before -> after | |---|---|---|---|---| | test_composability.py | `test_pp_fsdp_*` ENOSPC | 20 passed, 2 skipped | 10197 MB -> 2547 MB | 76-86 s -> 42-50 s | | test_fully_shard_comm.py | `test_fully_shard_backward_prefetch` ENOSPC (exit -6) | 39 passed, 1 skipped | 10108 MB -> 6642 MB | 589 s -> 567-590 s | | test_fully_shard_frozen.py | `test_train_mixed_requires_grad_per_group` ENOSPC (exit -6) | 5 passed | 10189 MB -> 7902 MB | 146 s -> 140-149 s | The frozen file's 7902 MB peak comes from the untouched `test_train_mixed_requires_grad_across_groups`. </details> Pull Request resolved: pytorch#202272 Approved by: https://github.com/jeffdaily Co-authored-by: Cursor <[email protected]>
dominikjastrzebskix
pushed a commit
to dominikjastrzebskix/pytorch
that referenced
this pull request
Nov 9, 2026
… the RCCL /dev/shm budget (pytorch#202272) ## Linked issue or supporting maintainer Supported by @jeffdaily ## BC-breaking? No ## Summary (human written only) Follow-up to pytorch#198299 and pytorch#200632. `test_composability.py::ComposabilityTest`, `TestFullyShardPrefetch::test_fully_shard_backward_prefetch` and `TestFullyShardFrozen::test_train_mixed_requires_grad_per_group` fail with ENOSPC on a 10 GiB `/dev/shm`, because RCCL 2.32.3 reserves 82.6 MB of `/dev/shm` per communicator per rank. `ComposabilityTest` now builds each mesh once per class, as pytorch#198299 did for `test_pp_composability.py`. The `reshard_after_forward=2` subtests of the two FSDP tests run in their own processes, as pytorch#200632 does for `tp_ep`. Peak `/dev/shm` drops from ~10.2 GB to at most 7.9 GB, and runtime does not increase. ## 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]` with `NCCL_MAX_LOCAL_RANKS` = 144, and `ncclShmOpen` `fallocate`s all of it, so every communicator reserves 82,576,040 B of `/dev/shm` per rank until the processes exit. Only `localRanks` of the 144 slots are ever used. **Changes.** - `test/distributed/test_composability.py` has its own `ComposabilityTest`, separate from the one pytorch#198299 changed in `_composable/test_composability/test_pp_composability.py`. Its workers are reused for the whole class, and every `test_pp_*` built a new `("dp", "pp")` mesh: 2 communicators per rank (16 across the 8 ranks) per test, 14 tests. It now uses the same class-level `_get_mesh` cache as pytorch#198299, so the class builds 2 meshes. - `TestFullyShardPrefetch` and `TestFullyShardFrozen` already run each test in fresh processes, but a single test exhausts `/dev/shm`. `fully_shard(reshard_after_forward=2)` builds a new post-forward `DeviceMesh` on every call, and its groups live until the processes exit: 48 two-rank communicators per rank in the prefetch test, 32 in the frozen test. FSDP creates these meshes internally, so a test cannot reuse them. The `reshard_after_forward=2` subtests therefore move to: - `test_fully_shard_backward_prefetch_reshard_to_2_{None,utils,composable}`; - `test_train_mixed_requires_grad_per_group_reshard_to_2_use_activation_checkpointing_{False,True}`. Each new test runs its variant in its own processes. Coverage is unchanged. **Rejected alternative.** Destroying groups at the end of a test or subtest: `DeviceMesh.__eq__`/`__hash__` ignore process groups, so DTensor caches can return an equal mesh whose groups were destroyed (see pytorch#200632). **Validation.** 8x MI300X, 10 GiB `/dev/shm`, torch 2.15.0+rocm10.2.0rc0, with RCCL 2.32.3 as shipped in the wheel. The same change was applied on release/2.15, because `main`'s `test_fully_shard_comm.py` imports `torch.distributed.fsdp.experimental`, which that wheel lacks. On release/2.15, `test_composability.py` and `test_fully_shard_frozen.py` match `main`. `main`'s `test_fully_shard_comm.py` also has tests this change does not touch, and they were not run: `test_numerics_with_leading_dims`, several `TestCase` and `FSDPTestMultiThread` classes that create no RCCL communicators, and `test_unused_backward_prefetch_with_post_forward_mesh` in `TestFullyShardPrefetch`, which makes three `reshard_after_forward=2` calls in its own processes. Each file was run whole, twice with this change and once without it. ``` cd test export PYTORCH_TEST_WITH_ROCM=1 PYTORCH_TESTING_DEVICE_ONLY_FOR=cuda BACKEND=nccl WORLD_SIZE=8 TEMP_DIR=$(mktemp -d) python -m pytest -v -s distributed/test_composability.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_comm.py python -m pytest -v -s distributed/_composable/fsdp/test_fully_shard_frozen.py ``` | File | Before | After (2 runs) | Peak /dev/shm before -> after | Runtime before -> after | |---|---|---|---|---| | test_composability.py | `test_pp_fsdp_*` ENOSPC | 20 passed, 2 skipped | 10197 MB -> 2547 MB | 76-86 s -> 42-50 s | | test_fully_shard_comm.py | `test_fully_shard_backward_prefetch` ENOSPC (exit -6) | 39 passed, 1 skipped | 10108 MB -> 6642 MB | 589 s -> 567-590 s | | test_fully_shard_frozen.py | `test_train_mixed_requires_grad_per_group` ENOSPC (exit -6) | 5 passed | 10189 MB -> 7902 MB | 146 s -> 140-149 s | The frozen file's 7902 MB peak comes from the untouched `test_train_mixed_requires_grad_across_groups`. </details> Pull Request resolved: pytorch#202272 Approved by: https://github.com/jeffdaily Co-authored-by: Cursor <[email protected]>
This branch was previously deployed
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.
Linked issue or supporting maintainer
Supported by @jeffdaily
BC-breaking?
No
Summary (human written only)
Follow-up to #198299 and #200632.
test_composability.py::ComposabilityTest,TestFullyShardPrefetch::test_fully_shard_backward_prefetchandTestFullyShardFrozen::test_train_mixed_requires_grad_per_groupfail with ENOSPC on a 10 GiB/dev/shm, because RCCL 2.32.3 reserves 82.6 MB of/dev/shmper communicator per rank.ComposabilityTestnow builds each mesh once per class, as #198299 did fortest_pp_composability.py. Thereshard_after_forward=2subtests of the two FSDP tests run in their own processes, as #200632 does fortp_ep. Peak/dev/shmdrops from ~10.2 GB to at most 7.9 GB, and runtime does not increase.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.
Agent-generated details
Root cause. RCCL's proxy-ops pool is sized as
ops[MAX_OPS_PER_PEER * NCCL_MAX_LOCAL_RANKS]withNCCL_MAX_LOCAL_RANKS= 144, andncclShmOpenfallocates all of it, so every communicator reserves 82,576,040 B of/dev/shmper rank until the processes exit. OnlylocalRanksof the 144 slots are ever used.Changes.
test/distributed/test_composability.pyhas its ownComposabilityTest, separate from the one [ROCm][test]Reuse device meshes across ComposabilityTest cases #198299 changed in_composable/test_composability/test_pp_composability.py. Its workers are reused for the whole class, and everytest_pp_*built a new("dp", "pp")mesh: 2 communicators per rank (16 across the 8 ranks) per test, 14 tests. It now uses the same class-level_get_meshcache as [ROCm][test]Reuse device meshes across ComposabilityTest cases #198299, so the class builds 2 meshes.TestFullyShardPrefetchandTestFullyShardFrozenalready run each test in fresh processes, but a single test exhausts/dev/shm.fully_shard(reshard_after_forward=2)builds a new post-forwardDeviceMeshon every call, and its groups live until the processes exit: 48 two-rank communicators per rank in the prefetch test, 32 in the frozen test. FSDP creates these meshes internally, so a test cannot reuse them. Thereshard_after_forward=2subtests therefore move to:test_fully_shard_backward_prefetch_reshard_to_2_{None,utils,composable};test_train_mixed_requires_grad_per_group_reshard_to_2_use_activation_checkpointing_{False,True}.Each new test runs its variant in its own processes. Coverage is unchanged.
Rejected alternative. Destroying groups at the end of a test or subtest:
DeviceMesh.__eq__/__hash__ignore process groups, so DTensor caches can return an equal mesh whose groups were destroyed (see #200632).Validation. 8x MI300X, 10 GiB
/dev/shm, torch 2.15.0+rocm10.2.0rc0, with RCCL 2.32.3 as shipped in the wheel. The same change was applied on release/2.15, becausemain'stest_fully_shard_comm.pyimportstorch.distributed.fsdp.experimental, which that wheel lacks. On release/2.15,test_composability.pyandtest_fully_shard_frozen.pymatchmain.main'stest_fully_shard_comm.pyalso has tests this change does not touch, and they were not run:test_numerics_with_leading_dims, severalTestCaseandFSDPTestMultiThreadclasses that create no RCCL communicators, andtest_unused_backward_prefetch_with_post_forward_meshinTestFullyShardPrefetch, which makes threereshard_after_forward=2calls in its own processes. Each file was run whole, twice with this change and once without it.test_pp_fsdp_*ENOSPCtest_fully_shard_backward_prefetchENOSPC (exit -6)test_train_mixed_requires_grad_per_groupENOSPC (exit -6)The frozen file's 7902 MB peak comes from the untouched
test_train_mixed_requires_grad_across_groups.cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang