Skip to content

[Testcase Refactoring] Enable PrivateUse1 tests and add hw-classification in test_transformer - #189682

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

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

Conversation

@PlatformLC

@PlatformLC PlatformLC commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable the test_ir device-type variant for out-of-tree PrivateUse1 accelerators in test/distributed/pipelining/test_transformer.py, and classify TransformerTests as HardwareClassification.ACCELERATOR.

Changes

  • Drop the only_for=["cpu", "cuda", "hpu", "xpu"] argument (and the now-unused devices list) from instantiate_device_type_tests, keeping allow_xpu=True. With only_for removed, get_desired_device_type_test_bases auto-registers PrivateUse1TestBase when _is_privateuse1_backend_available(), so the PrivateUse1 variant of test_ir is generated alongside the existing cpu/cuda/hpu/xpu variants. Zero-loss: HPU is added unconditionally on TEST_HPU, XPU via allow_xpu, and the only addition is PrivateUse1.
  • Set hw_classification = HardwareClassification.ACCELERATOR on TransformerTests. test_ir builds a model on device, runs pipeline(...) and asserts the pipelined output matches eager -- accelerator-generic behavior with no CUDA-specific paths. The classification is metadata: it only filters tests when --hw-classification is passed; normal discovery/execution is unchanged.

Motivation

test_ir was never generated for out-of-tree PrivateUse1 accelerators because the explicit only_for list excluded PrivateUse1. Dropping it lets the framework's existing PrivateUse1 infrastructure (PrivateUse1TestBase, _is_privateuse1_backend_available) discover the backend automatically. The HardwareClassification.ACCELERATOR tag participates in the hardware-classification filtering initiative, so --hw-classification ACCELERATOR selects this test across every accelerator backend.

Test Plan

python test/distributed/pipelining/test_transformer.py -v
python test/distributed/pipelining/test_transformer.py -v --hw-classification ACCELERATOR
python test/distributed/pipelining/test_transformer.py -v --hw-classification CPU
python test/distributed/pipelining/test_transformer.py -v --hw-classification GENERIC

Verified on a PrivateUse1 host (8 devices): the PrivateUse1 variant of test_ir is auto-generated (TransformerTestsPRIVATEUSE1) and passes alongside test_ir_cpu (normal run: Ran 2, OK). --hw-classification ACCELERATOR includes test_ir (total=2, passed=2); --hw-classification CPU and --hw-classification GENERIC filter it out (mismatched=2, Ran 0 each), confirming the filter is category-specific.

Notes

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

@pytorch-bot

pytorch-bot Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (8 Unrelated Failures)

As of commit 33db39a 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.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jul 13, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: PlatformLC / name: PlatformLC (4f042be)

@PlatformLC

Copy link
Copy Markdown
Contributor Author

@PlatformLC
PlatformLC force-pushed the test/test_transformer branch from 4f042be to 0e1510c Compare July 13, 2026 12:32
@albanD
albanD requested a review from drisspg July 13, 2026 15:42
@albanD albanD added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 13, 2026
@albanD
albanD requested a review from fffrog July 13, 2026 15:42
instantiate_device_type_tests(
TransformerTests, globals(), only_for=devices, allow_xpu=True
)
instantiate_device_type_tests(TransformerTests, globals(), allow_xpu=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this api is a lil weird to me alban like why is allow_xpu a kwarg inclusion, whihle I assume cpu, cuda, hpu and xpu are all now default in this set of allowing?

also our device test helpers have always confused me

cc @albanD

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.

Historical reasons? haha
I think it's because xpu was added in core after the fact. Not much we can do about it now...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@drisspg @albanD any other idea about this? Is the change to add pu1 variant proper here?

@PlatformLC

PlatformLC commented Jul 13, 2026 via email

Copy link
Copy Markdown
Contributor Author

@albanD

albanD commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

@PlatformLC as a new user I would recommend focussing on getting one PR merge before sending more.
For now, I'll close the others, feel free to re-open them once this one is good and you have more experience here.

@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] Enable PrivateUse1 tests in test_transformer [Testcase Refactoring] Enable PrivateUse1 tests in test_transformer Jul 28, 2026
…tion in test_transformer

`test_ir` was never generated for out-of-tree PrivateUse1 accelerators
because `instantiate_device_type_tests` was called with
`only_for=["cpu", "cuda", "hpu", "xpu"]`, which excludes PrivateUse1.

Drop `only_for` so `get_desired_device_type_test_bases` auto-registers
`PrivateUse1TestBase` (when `_is_privateuse1_backend_available()`),
auto-generating the PrivateUse1 variant of `test_ir` alongside the
existing cpu/cuda/hpu/xpu variants. Keep `allow_xpu=True` so XPU stays
opted in. This is zero-loss: HPU is added unconditionally on `TEST_HPU`,
XPU via `allow_xpu`, and the only addition is PrivateUse1.

Classify `TransformerTests` as `HardwareClassification.ACCELERATOR`:
`test_ir` builds a model on `device`, runs `pipeline(...)` and asserts
the pipelined output matches eager -- accelerator-generic behavior with
no CUDA-specific paths. The classification is metadata: it only filters
tests when `--hw-classification` is passed; normal discovery/execution
is unchanged.

Test Plan:
```
python test/distributed/pipelining/test_transformer.py -v
python test/distributed/pipelining/test_transformer.py -v --hw-classification ACCELERATOR
python test/distributed/pipelining/test_transformer.py -v --hw-classification CPU
python test/distributed/pipelining/test_transformer.py -v --hw-classification GENERIC
```
Verified on a PrivateUse1 host (8 devices): the PrivateUse1 variant of
`test_ir` is auto-generated (`TransformerTestsPRIVATEUSE1`) and passes
alongside `test_ir_cpu` (normal run: Ran 2, OK). `--hw-classification
ACCELERATOR` includes `test_ir` (total=2, passed=2); `--hw-classification
CPU` and `--hw-classification GENERIC` filter it out (mismatched=2,
Ran 0 each), confirming the filter is category-specific.
@PlatformLC
PlatformLC force-pushed the test/test_transformer branch from 0e1510c to 33db39a Compare July 31, 2026 06:41
@PlatformLC PlatformLC changed the title [Testcase Refactoring] Enable PrivateUse1 tests in test_transformer [Testcase Refactoring] Enable PrivateUse1 tests and add hw-classification in test_transformer Jul 31, 2026
@PlatformLC

Copy link
Copy Markdown
Contributor Author

@fffrog @drisspg In addition, I've modified the change to add hw-classification for test cases, PTAL again.

@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.
On the allow_xpu question — it's a historical API quirk: XPU and MPS were added to core after the fact and require explicit opt-in (allow_xpu/allow_mps), while CPU/CUDA/HPU/PrivateUse1 are included by default in get_device_type_test_bases. The PrivateUse1 variant here is correct — it was already in the default bases, the old only_for whitelist was just filtering it out.

@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.

SGTM, thank you.

@fffrog fffrog moved this from Ready for Review(Initial) to Ready for Merge in PyTorch Test Refactoring Aug 10, 2026
@zyw-hw

zyw-hw commented Aug 11, 2026

Copy link
Copy Markdown

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 11, 2026
@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 11, 2026
ankitbhrdwj pushed a commit to ankitbhrdwj/pytorch that referenced this pull request Aug 12, 2026
…tion in test_transformer (pytorch#189682)

## Summary
Enable the `test_ir` device-type variant for out-of-tree PrivateUse1 accelerators in `test/distributed/pipelining/test_transformer.py`, and classify `TransformerTests` as `HardwareClassification.ACCELERATOR`.

## Changes
- Drop the `only_for=["cpu", "cuda", "hpu", "xpu"]` argument (and the now-unused `devices` list) from `instantiate_device_type_tests`, keeping `allow_xpu=True`. With `only_for` removed, `get_desired_device_type_test_bases` auto-registers `PrivateUse1TestBase` when `_is_privateuse1_backend_available()`, so the PrivateUse1 variant of `test_ir` is generated alongside the existing cpu/cuda/hpu/xpu variants. Zero-loss: HPU is added unconditionally on `TEST_HPU`, XPU via `allow_xpu`, and the only addition is PrivateUse1.
- Set `hw_classification = HardwareClassification.ACCELERATOR` on `TransformerTests`. `test_ir` builds a model on `device`, runs `pipeline(...)` and asserts the pipelined output matches eager -- accelerator-generic behavior with no CUDA-specific paths. The classification is metadata: it only filters tests when `--hw-classification` is passed; normal discovery/execution is unchanged.

## Motivation
`test_ir` was never generated for out-of-tree PrivateUse1 accelerators because the explicit `only_for` list excluded PrivateUse1. Dropping it lets the framework's existing PrivateUse1 infrastructure (`PrivateUse1TestBase`, `_is_privateuse1_backend_available`) discover the backend automatically. The `HardwareClassification.ACCELERATOR` tag participates in the hardware-classification filtering initiative, so `--hw-classification ACCELERATOR` selects this test across every accelerator backend.

## Test Plan
```
python test/distributed/pipelining/test_transformer.py -v
python test/distributed/pipelining/test_transformer.py -v --hw-classification ACCELERATOR
python test/distributed/pipelining/test_transformer.py -v --hw-classification CPU
python test/distributed/pipelining/test_transformer.py -v --hw-classification GENERIC
```
Verified on a PrivateUse1 host (8 devices): the PrivateUse1 variant of `test_ir` is auto-generated (`TransformerTestsPRIVATEUSE1`) and passes alongside `test_ir_cpu` (normal run: Ran 2, OK). `--hw-classification ACCELERATOR` includes `test_ir` (total=2, passed=2); `--hw-classification CPU` and `--hw-classification GENERIC` filter it out (mismatched=2, Ran 0 each), confirming the filter is category-specific.

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

Pull Request resolved: pytorch#189682
Approved by: https://github.com/drisspg, https://github.com/jishuangfeng, https://github.com/fffrog
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.

8 participants