Repository navigation
[Testcase Refactoring] Enable PrivateUse1 tests and add hw-classification in test_transformer - #189682
[Testcase Refactoring] Enable PrivateUse1 tests and add hw-classification in test_transformer#189682PlatformLC wants to merge 1 commit into
Conversation
|
|
4f042be to
0e1510c
Compare
| instantiate_device_type_tests( | ||
| TransformerTests, globals(), only_for=devices, allow_xpu=True | ||
| ) | ||
| instantiate_device_type_tests(TransformerTests, globals(), allow_xpu=True) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Historical reasons? haha
I think it's because xpu was added in core after the fact. Not much we can do about it now...
|
Same doubt on this, xpu/hpu/mps are using kwargs to enable while `only_for`is a confusing argument...
---- Replied Message ----
From Driss ***@***.***> Date 07/14/2026 00:43 To ***@***.***> Cc Chun ***@***.***>***@***.***> Subject Re: [pytorch/pytorch] [Test] Enable PrivateUse1 tests in test_transformer (PR #189682)
@drisspg commented on this pull request.
In test/distributed/pipelining/test_transformer.py:
@@ -74,10 +74,7 @@ def get_layers(module): print(f"Equivalence test passed {torch.sum(out)} ref {torch.sum(ref)}") -devices = ["cpu", "cuda", "hpu", "xpu"] -instantiate_device_type_tests( - TransformerTests, globals(), only_for=devices, allow_xpu=True -) +instantiate_device_type_tests(TransformerTests, globals(), allow_xpu=True)
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
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
|
@PlatformLC as a new user I would recommend focussing on getting one PR merge before sending more. |
|
@pytorchbot label "module: tests/distributed" |
…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.
0e1510c to
33db39a
Compare
jishuangfeng
left a comment
There was a problem hiding this comment.
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.
|
@pytorchbot merge |
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 |
…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
Summary
Enable the
test_irdevice-type variant for out-of-tree PrivateUse1 accelerators intest/distributed/pipelining/test_transformer.py, and classifyTransformerTestsasHardwareClassification.ACCELERATOR.Changes
only_for=["cpu", "cuda", "hpu", "xpu"]argument (and the now-unuseddeviceslist) frominstantiate_device_type_tests, keepingallow_xpu=True. Withonly_forremoved,get_desired_device_type_test_basesauto-registersPrivateUse1TestBasewhen_is_privateuse1_backend_available(), so the PrivateUse1 variant oftest_iris generated alongside the existing cpu/cuda/hpu/xpu variants. Zero-loss: HPU is added unconditionally onTEST_HPU, XPU viaallow_xpu, and the only addition is PrivateUse1.hw_classification = HardwareClassification.ACCELERATORonTransformerTests.test_irbuilds a model ondevice, runspipeline(...)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-classificationis passed; normal discovery/execution is unchanged.Motivation
test_irwas never generated for out-of-tree PrivateUse1 accelerators because the explicitonly_forlist excluded PrivateUse1. Dropping it lets the framework's existing PrivateUse1 infrastructure (PrivateUse1TestBase,_is_privateuse1_backend_available) discover the backend automatically. TheHardwareClassification.ACCELERATORtag participates in the hardware-classification filtering initiative, so--hw-classification ACCELERATORselects this test across every accelerator backend.Test Plan
Verified on a PrivateUse1 host (8 devices): the PrivateUse1 variant of
test_iris auto-generated (TransformerTestsPRIVATEUSE1) and passes alongsidetest_ir_cpu(normal run: Ran 2, OK).--hw-classification ACCELERATORincludestest_ir(total=2, passed=2);--hw-classification CPUand--hw-classification GENERICfilter 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.