Skip to content

[Testcase Refactoring] Use is_backend_available for MultiProcContinuousTest backend check - #192186

Closed
PlatformLC wants to merge 1 commit into
pytorch:mainfrom
PlatformLC:test/test_stage_common
Closed

PlatformLC wants to merge 1 commit into
pytorch:mainfrom
PlatformLC:test/test_stage_common

Conversation

@PlatformLC

Copy link
Copy Markdown
Contributor

Summary

Replace MultiProcContinuousTest's hardcoded backend-availability dict in _ensure_processes_spawned with c10d.is_backend_available(backend). The generic API covers any backend registered via Backend.register_backend, including out-of-tree PrivateUse1 accelerators' backends, so the spawn-time check no longer silently passes through unlisted backends.

Changes

Motivation

Part of the test-case refactoring initiative (#185590) to decouple tests from hardcoded CUDA/NCCL assumptions so out-of-tree PrivateUse1 accelerators can run the suite. Split out from #192044 per review so the base-class/tooling change lands first and the test-file changes rebase on top.

Notes

This is part of the test case refactoring initiative tracked in #185590.

…usTest backend check

Replace the hardcoded {nccl, gloo, mpi, xccl} availability dict in
MultiProcContinuousTest._ensure_processes_spawned with
c10d.is_backend_available(backend). The generic API covers any backend
registered via Backend.register_backend, including out-of-tree PrivateUse1
accelerators, so the spawn-time check no longer silently passes through
unlisted backends.

This is the prerequisite for subclasses to drop their
@requires_accelerator_dist_backend gate: with the backend availability
check centralized here, the decorator is redundant.

Test Plan:
```
python test/distributed/pipelining/test_stage.py -v
```
is_backend_available is behavior-preserving for the listed backends
(nccl/gloo/mpi/xccl); the out-of-tree/PrivateUse1 coverage it adds is
exercised by the dependent test-file PRs (e.g. test_stage pytorch#192044) once
they drop @requires_accelerator_dist_backend and rebase on top.
@pytorch-bot

pytorch-bot Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit 11462c9 with merge base 1424eca (image):

CRCR (non-blocking) - The following CRCR downstream CI jobs failed but are non-blocking:

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

@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 Aug 5, 2026
@PlatformLC
PlatformLC marked this pull request as ready for review August 5, 2026 07:26
@jishuangfeng

Copy link
Copy Markdown

Replacing the hardcoded {nccl,gloo,mpi,xccl} availability dict with is_backend_available correctly covers out-of-tree third-party backends (registered via Backend.register_backend) instead of silently passing them through. Behavior is equivalent for the listed backends.
LGTM.

@jishuangfeng jishuangfeng left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jbschlosser jbschlosser added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Aug 5, 2026
@fffrog fffrog moved this to Backlog in PyTorch Test Refactoring Aug 7, 2026

@fffrog fffrog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you.

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@albanD albanD moved this from Ready for Review(Definitive) to Ready for Merge in PyTorch Test Refactoring Aug 21, 2026
@PlatformLC

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 24, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@PlatformLC

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Aug 24, 2026
@PlatformLC

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@github-project-automation github-project-automation Bot moved this from Ready for Merge to Done in PyTorch Test Refactoring Aug 24, 2026
orrangetabby17 pushed a commit to orrangetabby17/pytorch that referenced this pull request Sep 2, 2026
…usTest backend check (pytorch#192186)

## Summary
Replace `MultiProcContinuousTest`'s hardcoded backend-availability dict in `_ensure_processes_spawned` with `c10d.is_backend_available(backend)`. The generic API covers any backend registered via `Backend.register_backend`, including out-of-tree PrivateUse1 accelerators' backends, so the spawn-time check no longer silently passes through unlisted backends.

## Changes
- `torch/testing/_internal/common_distributed.py`: Replaced the hardcoded `{nccl, gloo, mpi, xccl}` backend-availability dict in `MultiProcContinuousTest._ensure_processes_spawned` with `c10d.is_backend_available(backend)`. This is the prerequisite for test-file PRs (e.g. test_stage, pytorch#192044) to drop their `@requires_accelerator_dist_backend` gate: with the backend availability check centralized here, the decorator becomes redundant.

## Motivation
Part of the test-case refactoring initiative (pytorch#185590) to decouple tests from hardcoded CUDA/NCCL assumptions so out-of-tree PrivateUse1 accelerators can run the suite. Split out from pytorch#192044 per review so the base-class/tooling change lands first and the test-file changes rebase on top.

## Notes
This is part of the test case refactoring initiative tracked in pytorch#185590.
Pull Request resolved: pytorch#192186
Approved by: https://github.com/jishuangfeng, https://github.com/fffrog, https://github.com/albanD
aeytkn pushed a commit to aeytkn/pytorch that referenced this pull request Sep 3, 2026
…usTest backend check (pytorch#192186)

## Summary
Replace `MultiProcContinuousTest`'s hardcoded backend-availability dict in `_ensure_processes_spawned` with `c10d.is_backend_available(backend)`. The generic API covers any backend registered via `Backend.register_backend`, including out-of-tree PrivateUse1 accelerators' backends, so the spawn-time check no longer silently passes through unlisted backends.

## Changes
- `torch/testing/_internal/common_distributed.py`: Replaced the hardcoded `{nccl, gloo, mpi, xccl}` backend-availability dict in `MultiProcContinuousTest._ensure_processes_spawned` with `c10d.is_backend_available(backend)`. This is the prerequisite for test-file PRs (e.g. test_stage, pytorch#192044) to drop their `@requires_accelerator_dist_backend` gate: with the backend availability check centralized here, the decorator becomes redundant.

## Motivation
Part of the test-case refactoring initiative (pytorch#185590) to decouple tests from hardcoded CUDA/NCCL assumptions so out-of-tree PrivateUse1 accelerators can run the suite. Split out from pytorch#192044 per review so the base-class/tooling change lands first and the test-file changes rebase on top.

## Notes
This is part of the test case refactoring initiative tracked in pytorch#185590.
Pull Request resolved: pytorch#192186
Approved by: https://github.com/jishuangfeng, https://github.com/fffrog, https://github.com/albanD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: tests/distributed This label covers all test cases within the Distributed sheet. open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants