Skip to content

[Testcase Refactoring] Update requires_accelerator_dist_backend to resolve/enable privateuse1 & enable PrivateUse1 tests in test_stage - #190153

Closed
PlatformLC wants to merge 2 commits into
pytorch:mainfrom
PlatformLC:test/test_stage
Closed

PlatformLC wants to merge 2 commits into
pytorch:mainfrom
PlatformLC:test/test_stage

Conversation

@PlatformLC

@PlatformLC PlatformLC commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR updates requires_accelerator_dist_backend in common_distributed.py to dynamically resolve "privateuse1" to the actual backend name at call time, and enables the StageTest/StageNegativeTest tests in test_stage.py to run on out-of-tree PrivateUse1 accelerators.

This is a step toward making pipelining distributed tests device-agnostic for PrivateUse1 backends.

Changes

  • common_distributed.py (Commit 1): Updated requires_accelerator_dist_backend to resolve "privateuse1" to the actual backend name via Backend.default_device_backend_map at call time, then check availability with c10d.is_backend_available. Added TEST_PRIVATEUSE1 and TEST_PRIVATEUSE1_DEVICE_TYPE imports. On HPU, TEST_PRIVATEUSE1 is False, so "privateuse1" is filtered out and HPU behavior is unchanged.
  • test_stage.py (Commit 2): Changed @requires_accelerator_dist_backend(["nccl", "xccl"]) to @requires_accelerator_dist_backend(["nccl", "xccl", "privateuse1"]) on the 7 StageTest/StageNegativeTest tests, and updated the skip message "2+ GPUs" -> "2+ accelerators".

Motivation

requires_accelerator_dist_backend(["nccl", "xccl"]) excluded PrivateUse1, so the 7 tests were skipped on PrivateUse1 accelerators even when the backend was available. Adding "privateuse1" (resolved dynamically to the actual backend name) lets the tests run on PrivateUse1 (and still run on CUDA via nccl, still skip on CPU with no accelerator backend). HPU is unaffected — "privateuse1" is not resolved on HPU (TEST_PRIVATEUSE1 is False).

Notes

  • Commit 1 (common_distributed.py framework change) is standalone and can be cherry-picked by other PRs that depend on requires_accelerator_dist_backend. After it merges, those PRs rebase onto main and can merge directly.
  • This is part of the test case refactoring initiative tracked in [Test] PyTorch Test Case Refactoring and Track #185590.

@pytorch-bot

pytorch-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/190153

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@PlatformLC

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@PlatformLC

Copy link
Copy Markdown
Contributor Author

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jul 16, 2026
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Change `@requires_accelerator_dist_backend(["nccl", "xccl", "hccl"])` to
`@requires_accelerator_dist_backend(["nccl", "xccl", "privateuse1"])` in
the `_requires_multi_accelerator` helper. Depends on the framework change
in the preceding commit (cherry-picked from pytorch#190153).

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_unit_tests.py -v
```
Verified on a PrivateUse1 host (8 devices): all 16 tests pass.
On a CPU-only host all 16 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Change `@requires_accelerator_dist_backend()` (no-args, which uses the
default `ACCELERATOR_DIST_BACKENDS = ["nccl", "xccl", "hccl"]` and would
enable HPU too) to `@requires_accelerator_dist_backend(["nccl", "xccl",
"privateuse1"])` on all 4 tests. With the framework change from pytorch#190153,
"privateuse1" is resolved to the actual backend name (e.g., "hccl") at
call time — on HPU, `TEST_PRIVATEUSE1` is False so "privateuse1" is
filtered out and HPU behavior is unchanged.

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
Update `requires_accelerator_dist_backend` in `common_distributed.py`
to resolve `"privateuse1"` to the actual backend name (e.g., "hccl")
at call time via `Backend.default_device_backend_map`, then check
availability with `c10d.is_backend_available`. On HPU,
`TEST_PRIVATEUSE1` is False so `"privateuse1"` is filtered out and
behavior is unchanged.

Test Plan:
```
python test/distributed/pipelining/test_stage.py -v
```
Verified on a PrivateUse1 host (8 devices): the 8 StageTest/
StageNegativeTest tests run (via "privateuse1" resolved to "hccl")
and pass. On a CPU-only host all 8 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Change @requires_accelerator_dist_backend(["nccl", "xccl", "hccl"]) to
@requires_accelerator_dist_backend(ACCELERATOR_DIST_BACKENDS + ["privateuse1"])
in the _requires_multi_accelerator helper. The test file references the
framework's ACCELERATOR_DIST_BACKENDS constant and appends "privateuse1" locally.
Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_unit_tests.py -v
```
Verified on a PrivateUse1 host (8 devices): all 16 tests pass.
On a CPU-only host all 16 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Change @requires_accelerator_dist_backend() to
@requires_accelerator_dist_backend(ACCELERATOR_DIST_BACKENDS + ["privateuse1"])
on all 4 tests. The test file references the framework's
ACCELERATOR_DIST_BACKENDS constant and appends "privateuse1" locally.
Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
Change `@requires_accelerator_dist_backend(["nccl", "xccl"])` to
`@requires_accelerator_dist_backend(ACCELERATOR_DIST_BACKENDS + ["privateuse1"])`
on the 7 StageTest/StageNegativeTest tests, and update the skip
message "2+ GPUs" -> "2+ accelerators". The test file references the
framework's `ACCELERATOR_DIST_BACKENDS` constant and appends
`"privateuse1"` locally — the framework constant itself is unchanged.
Depends on the framework change in the preceding commit.

Test Plan:
```
python test/distributed/pipelining/test_stage.py -v
```
Verified on a PrivateUse1 host (8 devices): all 8 tests pass.
On a CPU-only host all 8 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Change `@requires_accelerator_dist_backend()` (no-args, which uses the
default `ACCELERATOR_DIST_BACKENDS = ["nccl", "xccl", "hccl"]` and would
enable HPU too) to `@requires_accelerator_dist_backend(["nccl", "xccl",
"privateuse1"])` on all 4 tests. With the framework change from pytorch#190153,
"privateuse1" is resolved to the actual backend name (e.g., "hccl") at
call time — on HPU, `TEST_PRIVATEUSE1` is False so "privateuse1" is
filtered out and HPU behavior is unchanged.

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Update requires_accelerator_dist_backend in common_distributed.py
to resolve "privateuse1" to the actual backend name (e.g., "hccl")
at call time via Backend.default_device_backend_map, then check
availability with c10d.is_backend_available. On HPU,
TEST_PRIVATEUSE1 is False so "privateuse1" is filtered out and
behavior is unchanged.

Cherry-picked from pytorch#190153.

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
- Change @requires_accelerator_dist_backend() to
  @requires_accelerator_dist_backend(ACCELERATOR_DIST_BACKENDS + ["privateuse1"])
  on all 4 tests. Originally used () (no-args, default list), now references
  ACCELERATOR_DIST_BACKENDS constant and appends "privateuse1" locally.
- Replace @skip_if_lt_x_gpu(8) with @skip_if_lt_x_devices(8) (from pytorch#187650).
- Replace at_least_x_gpu(8) with at_least_x_device(8) and "GPUs" -> "accelerators".
Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Update requires_accelerator_dist_backend in common_distributed.py
to resolve "privateuse1" to the actual backend name (e.g., "hccl")
at call time via Backend.default_device_backend_map, then check
availability with c10d.is_backend_available. On HPU,
TEST_PRIVATEUSE1 is False so "privateuse1" is filtered out and
behavior is unchanged.

Cherry-picked from pytorch#190153.

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_unit_tests.py -v
```
Verified on a PrivateUse1 host (8 devices): all 16 tests pass.
On a CPU-only host all 16 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
- Change @requires_accelerator_dist_backend(["nccl", "xccl", "hccl"]) to
  @requires_accelerator_dist_backend(["nccl", "xccl", "privateuse1"]) in
  the _requires_multi_accelerator helper.
- init_pg: if device_type == "cuda": torch.cuda.set_device(self.device) ->
  if torch.accelerator.is_available(): torch.accelerator.set_device_index(self.device).
- Rename _requires_multi_gpu -> _requires_multi_accelerator and the skip
  message "4+ GPUs" -> "4+ accelerators".
Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_unit_tests.py -v
```
Verified on a PrivateUse1 host (8 devices): all 16 tests pass.
On a CPU-only host all 16 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Update `requires_accelerator_dist_backend` in `common_distributed.py`
to resolve the PrivateUse1 entry in the backends list to the host's
actual communication backend for the PrivateUse1 device type at call
time via `Backend.default_device_backend_map`, then check availability
with `c10d.is_backend_available`. On HPU, `TEST_PRIVATEUSE1` is False
so the PrivateUse1 entry is filtered out and existing behavior is
unchanged.

Cherry-picked from pytorch#190153.

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
- Change `@requires_accelerator_dist_backend()` to
  `@requires_accelerator_dist_backend(ACCELERATOR_DIST_BACKENDS + ["privateuse1"])`
  on all 4 tests. The list was originally `()` (no-args, default), so it
  now references the `ACCELERATOR_DIST_BACKENDS` constant and appends
  `"privateuse1"` locally — the framework constant itself is unchanged.
- Replace `@skip_if_lt_x_gpu(8)` with `@skip_if_lt_x_devices(8)` (from pytorch#187650).
- Replace `at_least_x_gpu(8)` with `at_least_x_device(8)` (added to
  `common_distributed.py` in this commit) and the skip message
  `"8+ GPUs"` -> `"8+ accelerators"`.

Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Update `requires_accelerator_dist_backend` in `common_distributed.py`
to resolve the PrivateUse1 entry in the backends list to the host's
actual communication backend for the PrivateUse1 device type at call
time via `Backend.default_device_backend_map`, then check availability
with `c10d.is_backend_available`. On HPU, `TEST_PRIVATEUSE1` is False
so the PrivateUse1 entry is filtered out and existing behavior is
unchanged.

Cherry-picked from pytorch#190153.

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_unit_tests.py -v
```
Verified on a PrivateUse1 host (8 devices): all 16 tests pass.
On a CPU-only host all 16 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
- In the `_requires_multi_accelerator` helper, change
  `@requires_accelerator_dist_backend(["nccl", "xccl"])` to
  `@requires_accelerator_dist_backend(["nccl", "xccl", "privateuse1"])`.
  The list was originally explicit, so it stays explicit (it does not
  reference `ACCELERATOR_DIST_BACKENDS`).
- `init_pg`: `if device_type == "cuda": torch.cuda.set_device(self.device)`
  -> `if torch.accelerator.is_available(): torch.accelerator.set_device_index(self.device)`.
- Rename `_requires_multi_gpu` -> `_requires_multi_accelerator` and the
  skip message `"4+ GPUs"` -> `"4+ accelerators"`.

Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_unit_tests.py -v
```
Verified on a PrivateUse1 host (8 devices): all 16 tests pass.
On a CPU-only host all 16 are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Update `requires_accelerator_dist_backend` in `common_distributed.py`
to resolve the PrivateUse1 entry in the backends list to the host's
actual communication backend for the PrivateUse1 device type at call
time via `Backend.default_device_backend_map`, then check availability
with `c10d.is_backend_available`. On HPU, `TEST_PRIVATEUSE1` is False
so the PrivateUse1 entry is filtered out and existing behavior is
unchanged.

Cherry-picked from pytorch#190153.

Test Plan:
```
python test/distributed/pipelining/test_schedule.py -v
```
Verified on a PrivateUse1 host (8 devices): all 56 tests pass,
including the 2 gated tests (previously skipped). On a CPU-only host
the 2 gated tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 16, 2026
Change `@requires_accelerator_dist_backend(["nccl", "xccl"])` to
`@requires_accelerator_dist_backend(["nccl", "xccl", "privateuse1"])`
on the `test_grad_with_v_schedule` and `test_grad_with_split_b_w`
tests. The list was originally explicit, so it stays explicit (it does
not reference `ACCELERATOR_DIST_BACKENDS`).

Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/pipelining/test_schedule.py -v
```
Verified on a PrivateUse1 host (8 devices): all 56 tests pass,
including the 2 gated tests (previously skipped). On a CPU-only host
the 2 gated tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 17, 2026
Update `requires_accelerator_dist_backend` in `common_distributed.py`
to resolve the PrivateUse1 entry in the backends list to the host's
actual communication backend for the PrivateUse1 device type at call
time via `Backend.default_device_backend_map`, then check availability
with `c10d.is_backend_available`. On HPU, `TEST_PRIVATEUSE1` is False
so the PrivateUse1 entry is filtered out and existing behavior is
unchanged.

Cherry-picked from pytorch#190153.

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_integration.py -v
```
On a CPU-only host all tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 17, 2026
- In the `_requires_multi_accelerator` helper, change the
  `@requires_accelerator_dist_backend` backend list to
  `["nccl", "xccl", "privateuse1"]` (was hardcoded to a specific vendor
  backend; now uses privateuse1, resolved by the framework to the actual
  backend).
- `init_pg`: `if device_type == "cuda": torch.cuda.set_device(self.device)`
  -> `if torch.accelerator.is_available(): torch.accelerator.set_device_index(self.device)`.
- Rename `_requires_multi_gpu` -> `_requires_multi_accelerator` and the
  skip message "4+ GPUs" -> "4+ accelerators".

Depends on the framework change in the preceding commit (from pytorch#190153).

Test Plan:
```
python test/distributed/pipelining/test_dtensor_pp_integration.py -v
```
On a CPU-only host all tests are skipped.
@albanD

albanD commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

See #189682 (comment)

@albanD albanD closed this Jul 17, 2026
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 21, 2026
Update `requires_accelerator_dist_backend` in `common_distributed.py`
to resolve the PrivateUse1 entry in the backends list to the host's
actual communication backend for the PrivateUse1 device type at call
time via `Backend.default_device_backend_map`, then check availability
with `c10d.is_backend_available`. On HPU, `TEST_PRIVATEUSE1` is False
so the PrivateUse1 entry is filtered out and existing behavior is
unchanged.

Cherry-picked from pytorch#190153.

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
Verified on a PrivateUse1 host (8 devices): test_pp_and_dcp passes.
On a CPU-only host all tests are skipped.
PlatformLC added a commit to PlatformLC/pytorch that referenced this pull request Jul 21, 2026
- Change `@requires_accelerator_dist_backend()` to
  `@requires_accelerator_dist_backend(ACCELERATOR_DIST_BACKENDS + ["privateuse1"])`
  on all 4 tests (the default list doesn't include PrivateUse1).
- Extend `at_least_x_gpu` in `common_distributed.py` to be hardware-agnostic
  (uses `torch.accelerator.is_available()` and `torch.accelerator.device_count()`).
  The naming retains "gpu" for backward compatibility, consistent with pytorch#187650's
  approach to `skip_if_lt_x_gpu`.
- No changes to `skip_if_lt_x_gpu` (extended by pytorch#187650 to be hardware-agnostic)
  or the skip message `"8+ GPUs"` (kept for backward compatibility).

Depends on the framework change in the preceding commit (from pytorch#190153) and
pytorch#187650 (skip_if_lt_x_gpu hardware-agnostic).

Test Plan:
```
python test/distributed/_composable/test_composability/test_pp_composability.py -v
```
On a CPU-only host all tests are skipped.
@PlatformLC

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "module: tests/distributed"

@pytorch-bot pytorch-bot Bot added the module: tests/distributed This label covers all test cases within the Distributed sheet. label Jul 25, 2026
@PlatformLC PlatformLC changed the title [Test] Update requires_accelerator_dist_backend to resolve/enable privateuse1 & enable PrivateUse1 tests in test_stage [Testcase Refactoring] Update requires_accelerator_dist_backend to resolve/enable privateuse1 & enable PrivateUse1 tests in test_stage Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: tests/distributed This label covers all test cases within the Distributed sheet. open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants