Repository navigation
[Testcase Refactoring] Make test_emulate_precision_casts device-agnostic via instantiate_device_type_tests - #198357
gavinwang269 wants to merge 2 commits into
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Findings (2): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198357
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 502cef6 with merge base 109544c ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/graph" |
078b27a to
82ca2de
Compare
|
|
@claude review these changes |
|
Claude finished @jansel's task in 38s —— View job The method move itself is correct, but a blank-line mistake at the insertion point is failing lint and has to be fixed before this can merge. PR Review: #198357SummaryThis PR moves Code Quality
Testing
RecommendationRequest Changes: fix the blank lines so lint passes. After that the change is a straightforward mechanical move. |
82ca2de to
9a06110
Compare
|
Fixed the blank-line findings (blank line before the moved method, two blanks before |
…device migrations Rebased onto latest main (scaffold + migrated debuginfo from pytorch#198361 are kept). Drops the seven methods whose device versions arrive in the parallel move pieces pytorch#198354 (test_bad_decomp), pytorch#198355 (test_joint_graph), pytorch#198356 (test_rng), pytorch#198357 (test_emulate_precision_casts), pytorch#198358 (test_bad_lowering), pytorch#198359 (test_bisect_pre_grad_graph) and pytorch#198360 (test_cudagraph_bisect_max); keeps test_pre_grad, test_crossref and test_eager_backend. Marks the remaining class GENERIC, renames test_ns to bisector_ns (a class attribute named test_* would otherwise be collected by instantiate_device_type_tests), slims tearDown and removes get_lib. Must merge LAST in the series, only after every sibling move above has landed; otherwise the deleted GPU tests lose their replacements. Also fixes the lint failures on the previous revision: removes imports that are unused at this point in the series (contextmanager, import_module, _prims_common, preserve_rng_state, module-level config) and normalizes the blank-line runs left by the method removals. These imports are intentionally not kept for the siblings; each move piece brings back exactly what it uses. Signed-off-by: gavinwang269 <[email protected]>
|
@pytorchbot merge |
Merge failedReason: Approvers from one of the following sets are needed:
|
|
Hi @fffrog — this PR failed It's the same mechanical move pattern as the already-landed siblings (#198361, #198358): Could you (or @guilhermeleobas, who approved the sibling #198358) drop an approval from a merge-rule-set so this can proceed? Re-triggering |
9a06110 to
502cef6
Compare
There was a problem hiding this comment.
Automated review of 502cef6: nothing blocking; ready for human review.
The PR moves test_emulate_precision_casts from the HAS_GPU-gated TestCompilerBisector into the device-instantiated TestCompilerBisectorDevice, and moves the has_triton() skip from each method up to the class. Recommendation: Needs Discussion. Someone needs to explicitly decide that losing MTIA coverage is acceptable, for this PR and the rest of the series, and the description needs to mention the decorator move.
⚪ 2 non-blocking findings
pytorch/test/dynamo/test_compiler_bisector.py
Line 404 in 502cef6
The test no longer runs on MTIA. This is still true at HEAD. Before, it ran under the class guard HAS_GPU, which includes HAS_MTIA_AND_TRITON (inductor_utils.py:82), so on an MTIA host GPU_TYPE was "mtia" and the test ran. common_device_type.py has no MTIATestBase. When TEST_WITH_MTIA is set, get_device_type_test_bases() (common_device_type.py:1028-1039) adds only CPUTestBase in fbcode, because the not TEST_WITH_MTIA condition leaves out CUDATestBase. except_for="cpu" then removes that CPU base, so an MTIA host gets zero variants of this test. The landed siblings # 198361 and # 198358 made the same trade, so this is really a question for the whole series, and neither those PRs nor this description says so. Fix: either keep MTIA coverage (e.g. a HAS_MTIA_AND_TRITON-gated variant until an MTIA device base exists), or state in the PR that dropping MTIA coverage is intended and get the MTIA owners to agree. (The review couldn't check offline whether any MTIA CI job actually runs this file.)
pytorch/test/dynamo/test_compiler_bisector.py
Line 346 in 502cef6
The PR description no longer matches the diff. It calls this "a pure single-method move" and says it keeps the per-method @ unittest.skipIf(not has_triton(), ...) convention "already used by test_bisect_run_debuginfo". At HEAD, the PR instead deletes that decorator from test_bisect_run_debuginfo and test_bad_lowering and puts one on the TestCompilerBisectorDevice class. That changes the gating for two tests the PR says it doesn't touch. The new behaviour is equivalent: the generated per-device classes inherit unittest_skip via type(class_name, (base, generic_test_class), {}) at common_device_type.py:1289. Still, the description and the "+23 -22" line count need updating so that reviewers and the commit message describe what actually lands.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
Withdrawn: the automated review of 502cef6 found nothing blocking.
|
@pytorchbot merge |
Merge failedReason: Approvers from one of the following sets are needed:
|
|
@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 |
…device_type_tests (#198356) ## Summary Move `test_rng` out of the guard-skipped `TestCompilerBisector` class into its own instantiated device class, so it runs on real accelerator devices instead of being skipped by the old `@unittest.skipIf(not HAS_GPU)` class guard. Split from #191435 (refactoring this file for out-of-tree accelerator support). This piece is a pure method move: the `instantiate_device_type_tests` scaffold already landed via #198361. ## Changes `test/dynamo/test_compiler_bisector.py` (+38 -20): 1. Add `TestCompilerBisectorRNG(TestCase)` (`hw_classification = HardwareClassification.ACCELERATOR`) containing the moved `test_rng`; the hardcoded `device=GPU_TYPE` becomes the `device` argument injected by instantiation, and the Triton gate sits on the class (same pattern as #198357). 2. Instantiate with `except_for="cpu"` (per @lizhihai137's review: keeps the ACCELERATOR contract instead of narrowing the device matrix via `only_for`). `test_rng` relies on `torch._dynamo.utils.preserve_rng_state`, which today saves/restores only CPU, CUDA and XPU RNG state; on backends without generator save/restore the eager-vs-compiled comparison silently diverges and the bisector blames the wrong subsystem (verified on an Ascend NPU: `do_bisect` reports `eager` instead of `inductor`). Such devices now skip explicitly via `@skipPRIVATEUSE1` rather than being silently excluded from instantiation. ## Notes - Generalizing `preserve_rng_state` via `torch.get_device_module(device)` would widen this test's device coverage; that is a source-side change beyond this series, left as a follow-up candidate. - Test IDs change from `TestCompilerBisector.test_rng` to per-device variants (`test_rng_cuda`, `test_rng_xpu`, `test_rng_npu` [skipped], ...). I checked the `test/dynamo_skips/` and `test/dynamo_expected_failures/` entries and the slow-test lists in `main`: nothing is keyed on the old `TestCompilerBisector.test_rng` name. ## Motivation The `@unittest.skipIf(not HAS_GPU)` class guard uses `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`. Out-of-tree accelerators registered via `PrivateUse1` are not in this list, so the test was skipped even where it can run. `instantiate_device_type_tests` gives each supported device its own variant, and `hw_classification` provides metadata for `--hw-classification` filtering. ## Test Plan | Environment | Result | |---|---| | CPU (`env-pytorch-2.16-20261029-cpu`) | `pytest --collect-only -q` -> **11 tests collected** (the moved test no longer appears un-instantiated) | | NPU (`env-pytorch-2.16-20261029-npu`, Ascend 910B4 / CANN 9.2.0 GA / torch_npu 737bb43 / triton-ascend 3.6.0) | `test_rng_npu` is instantiated and **skips cleanly (0.009s)** via `@skipPRIVATEUSE1` instead of being silently absent | | CUDA / XPU execution | covered by the ciflow trunk jobs | | lint | `lintrunner` (includes in-tree TEST_LINTER): no issues | Pull Request resolved: #198356 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…tic via instantiate_device_type_tests (pytorch#198357) ## Summary Move `test_emulate_precision_casts` from the `HAS_GPU`-guarded `TestCompilerBisector` into the existing device-instantiated `TestCompilerBisectorDevice` in `test/dynamo/test_compiler_bisector.py`, so it runs on out-of-tree accelerators instead of being skipped. Split from pytorch#191435 (refactoring this file for out-of-tree accelerator support). ## Changes `test/dynamo/test_compiler_bisector.py` (+23 -24): - `test_emulate_precision_casts` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `pytorch#198361` already set up and `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. - The Triton gate moves from per-method decorators to `TestCompilerBisectorDevice` itself: every test in the class requires Triton, so a single class-level `@unittest.skipIf(not has_triton(), "requires Triton")` replaces the three duplicated method-level decorators (per review). ## Motivation The class guard `@unittest.skipIf(not HAS_GPU, ...)` treats `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`, so out-of-tree accelerators registered via `PrivateUse1` skip the whole class even though this test only needs a generic accelerator. `instantiate_device_type_tests` with `except_for="cpu"` covers all registered non-CPU device types, and `hw_classification` metadata enables `--hw-classification` filtering. ## Notes The shared scaffold (new class + instantiation) is already on `main` via `pytorch#198361`, so the move itself is a single method transfer. The Triton gate stays device-blind (`has_triton()`); a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). Class-level `skipIf` survives `instantiate_device_type_tests` because the device-specific classes inherit from the template class, verified on real hardware below. ## Test Plan - CPU (`torch-2.16-cpu` nightly wheel): collection identical to baseline modulo the moved test. ``` python -m pytest test/dynamo/test_compiler_bisector.py --collect-only -q # 11 tests collected; TestCompilerBisectorDevicePRIVATEUSE1 now owns test_emulate_precision_casts_npu ``` - `lintrunner test/dynamo/test_compiler_bisector.py` -> `ok No lint issues.` - NPU real hardware (Ascend 910B4): ``` python -m pytest test/dynamo/test_compiler_bisector.py -v # 3 passed, 8 skipped ``` ### Verification Report | Hardware | Cases | Passed | Failed | Skipped | Result | |----------|-------|--------|--------|---------|--------| | CPU (no accelerator) | 11 collected | - | - | - | Collect-only; 11 items, device class now owns `test_emulate_precision_casts_npu` | | NPU (Ascend 910B4) | 11 | 3 | 0 | 8 | `test_emulate_precision_casts_npu` passes (previously never executed on NPU); 8 skips are the `HAS_GPU`-guarded legacy class, expected | Gate behavior verified both directions on NPU: with Triton installed all three tests in the device class run and pass; with Triton absent the class skips with `requires Triton`. ### Environment | Item | Version | |------|---------| | CANN | 9.2.0 (GA) | | driver | 26.1.1 | | PyTorch | 2.16.0.dev20261029+cpu (nightly wheel, same day as trunk) | | torch_npu | 2.16.0.dev20261029+git737bb43 (source build from master) | | Python | 3.12.15 | | triton-ascend | 3.6.0+git0cfb1708 | ## Dependencies Part of the pytorch#191435 split series (pytorch#198353 ~ pytorch#198362); independent of its siblings, each moves one test method. Pull Request resolved: pytorch#198357 Approved by: https://github.com/can-gaa-hou, https://github.com/lizhihai137, https://github.com/jansel
…device_type_tests (pytorch#198356) ## Summary Move `test_rng` out of the guard-skipped `TestCompilerBisector` class into its own instantiated device class, so it runs on real accelerator devices instead of being skipped by the old `@unittest.skipIf(not HAS_GPU)` class guard. Split from pytorch#191435 (refactoring this file for out-of-tree accelerator support). This piece is a pure method move: the `instantiate_device_type_tests` scaffold already landed via pytorch#198361. ## Changes `test/dynamo/test_compiler_bisector.py` (+38 -20): 1. Add `TestCompilerBisectorRNG(TestCase)` (`hw_classification = HardwareClassification.ACCELERATOR`) containing the moved `test_rng`; the hardcoded `device=GPU_TYPE` becomes the `device` argument injected by instantiation, and the Triton gate sits on the class (same pattern as pytorch#198357). 2. Instantiate with `except_for="cpu"` (per @lizhihai137's review: keeps the ACCELERATOR contract instead of narrowing the device matrix via `only_for`). `test_rng` relies on `torch._dynamo.utils.preserve_rng_state`, which today saves/restores only CPU, CUDA and XPU RNG state; on backends without generator save/restore the eager-vs-compiled comparison silently diverges and the bisector blames the wrong subsystem (verified on an Ascend NPU: `do_bisect` reports `eager` instead of `inductor`). Such devices now skip explicitly via `@skipPRIVATEUSE1` rather than being silently excluded from instantiation. ## Notes - Generalizing `preserve_rng_state` via `torch.get_device_module(device)` would widen this test's device coverage; that is a source-side change beyond this series, left as a follow-up candidate. - Test IDs change from `TestCompilerBisector.test_rng` to per-device variants (`test_rng_cuda`, `test_rng_xpu`, `test_rng_npu` [skipped], ...). I checked the `test/dynamo_skips/` and `test/dynamo_expected_failures/` entries and the slow-test lists in `main`: nothing is keyed on the old `TestCompilerBisector.test_rng` name. ## Motivation The `@unittest.skipIf(not HAS_GPU)` class guard uses `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`. Out-of-tree accelerators registered via `PrivateUse1` are not in this list, so the test was skipped even where it can run. `instantiate_device_type_tests` gives each supported device its own variant, and `hw_classification` provides metadata for `--hw-classification` filtering. ## Test Plan | Environment | Result | |---|---| | CPU (`env-pytorch-2.16-20261029-cpu`) | `pytest --collect-only -q` -> **11 tests collected** (the moved test no longer appears un-instantiated) | | NPU (`env-pytorch-2.16-20261029-npu`, Ascend 910B4 / CANN 9.2.0 GA / torch_npu 737bb43 / triton-ascend 3.6.0) | `test_rng_npu` is instantiated and **skips cleanly (0.009s)** via `@skipPRIVATEUSE1` instead of being silently absent | | CUDA / XPU execution | covered by the ciflow trunk jobs | | lint | `lintrunner` (includes in-tree TEST_LINTER): no issues | Pull Request resolved: pytorch#198356 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…antiate_device_type_tests (#198355) ## Summary Move `test_joint_graph` from the `HAS_GPU`-guarded `TestCompilerBisector` into the existing device-instantiated `TestCompilerBisectorDevice` in `test/dynamo/test_compiler_bisector.py`, so it runs on out-of-tree accelerators instead of being skipped. Split from #191435 (refactoring this file for out-of-tree accelerator support). ## Changes `test/dynamo/test_compiler_bisector.py` (+36 -38): - `test_joint_graph` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. - Drop the now-redundant in-method `from torch._inductor import config` (the module is imported at file scope). - Update the `CustomPostPass.uuid()` string to name `TestCompilerBisectorDevice` after the move (keeps the pass identity meaningful and unique). - The method-level `@unittest.skipIf(not has_triton(), ...)` on the moved test was removed as a duplicate of the class-level decorator of `TestCompilerBisectorDevice`. - The base class itself is untouched here; the GENERIC declaration belongs to #198360 alone (review note). ## Motivation The class guard `@unittest.skipIf(not HAS_GPU, ...)` treats `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`, so out-of-tree accelerators registered via `PrivateUse1` skip the whole class even though this test only needs a generic accelerator. `instantiate_device_type_tests` with `except_for="cpu"` covers all registered non-CPU device types, and `hw_classification` metadata enables `--hw-classification` filtering. ## Notes The shared scaffold (new class + instantiation) is already on `main`, so this PR is a pure single-method move. Triton gating for `TestCompilerBisectorDevice` lives on the class-level `@unittest.skipIf(not has_triton(), ...)` decorator, the convention already used on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`env-pytorch-2.16-20261029-cpu` venv, `pytest --collect-only`): 11 tests collected on the rebased branch; the moved test now instantiates only for accelerator devices. Re-measured after the follow-up edits: still 11. - NPU real hardware (Ascend 910B4, CANN 9.2.0 GA, `env-pytorch-2.16-20261029-npu` venv with torch_npu 737bb43 + triton-ascend 3.6.0): `pytest -k test_joint_graph_npu` -> **1 passed (32.2s, re-measured after this round's edits)**; previously this test never executed on NPU. - `lintrunner` (includes in-tree TEST_LINTER): no issues, re-run after this round's edits. Rebased onto latest main after #198358 landed; the class-level Triton gate arrives with #198357 and this PR will inherit it on the next rebase. ## Dependencies Part of the #191435 split series (#198353 ~ #198362); independent of its siblings, each moves one test method. Pull Request resolved: #198355 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…tic via instantiate_device_type_tests (pytorch#198357) ## Summary Move `test_emulate_precision_casts` from the `HAS_GPU`-guarded `TestCompilerBisector` into the existing device-instantiated `TestCompilerBisectorDevice` in `test/dynamo/test_compiler_bisector.py`, so it runs on out-of-tree accelerators instead of being skipped. Split from pytorch#191435 (refactoring this file for out-of-tree accelerator support). ## Changes `test/dynamo/test_compiler_bisector.py` (+23 -24): - `test_emulate_precision_casts` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `pytorch#198361` already set up and `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. - The Triton gate moves from per-method decorators to `TestCompilerBisectorDevice` itself: every test in the class requires Triton, so a single class-level `@unittest.skipIf(not has_triton(), "requires Triton")` replaces the three duplicated method-level decorators (per review). ## Motivation The class guard `@unittest.skipIf(not HAS_GPU, ...)` treats `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`, so out-of-tree accelerators registered via `PrivateUse1` skip the whole class even though this test only needs a generic accelerator. `instantiate_device_type_tests` with `except_for="cpu"` covers all registered non-CPU device types, and `hw_classification` metadata enables `--hw-classification` filtering. ## Notes The shared scaffold (new class + instantiation) is already on `main` via `pytorch#198361`, so the move itself is a single method transfer. The Triton gate stays device-blind (`has_triton()`); a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). Class-level `skipIf` survives `instantiate_device_type_tests` because the device-specific classes inherit from the template class, verified on real hardware below. ## Test Plan - CPU (`torch-2.16-cpu` nightly wheel): collection identical to baseline modulo the moved test. ``` python -m pytest test/dynamo/test_compiler_bisector.py --collect-only -q # 11 tests collected; TestCompilerBisectorDevicePRIVATEUSE1 now owns test_emulate_precision_casts_npu ``` - `lintrunner test/dynamo/test_compiler_bisector.py` -> `ok No lint issues.` - NPU real hardware (Ascend 910B4): ``` python -m pytest test/dynamo/test_compiler_bisector.py -v # 3 passed, 8 skipped ``` ### Verification Report | Hardware | Cases | Passed | Failed | Skipped | Result | |----------|-------|--------|--------|---------|--------| | CPU (no accelerator) | 11 collected | - | - | - | Collect-only; 11 items, device class now owns `test_emulate_precision_casts_npu` | | NPU (Ascend 910B4) | 11 | 3 | 0 | 8 | `test_emulate_precision_casts_npu` passes (previously never executed on NPU); 8 skips are the `HAS_GPU`-guarded legacy class, expected | Gate behavior verified both directions on NPU: with Triton installed all three tests in the device class run and pass; with Triton absent the class skips with `requires Triton`. ### Environment | Item | Version | |------|---------| | CANN | 9.2.0 (GA) | | driver | 26.1.1 | | PyTorch | 2.16.0.dev20261029+cpu (nightly wheel, same day as trunk) | | torch_npu | 2.16.0.dev20261029+git737bb43 (source build from master) | | Python | 3.12.15 | | triton-ascend | 3.6.0+git0cfb1708 | ## Dependencies Part of the pytorch#191435 split series (pytorch#198353 ~ pytorch#198362); independent of its siblings, each moves one test method. Pull Request resolved: pytorch#198357 Approved by: https://github.com/can-gaa-hou, https://github.com/lizhihai137, https://github.com/jansel
…device_type_tests (pytorch#198356) ## Summary Move `test_rng` out of the guard-skipped `TestCompilerBisector` class into its own instantiated device class, so it runs on real accelerator devices instead of being skipped by the old `@unittest.skipIf(not HAS_GPU)` class guard. Split from pytorch#191435 (refactoring this file for out-of-tree accelerator support). This piece is a pure method move: the `instantiate_device_type_tests` scaffold already landed via pytorch#198361. ## Changes `test/dynamo/test_compiler_bisector.py` (+38 -20): 1. Add `TestCompilerBisectorRNG(TestCase)` (`hw_classification = HardwareClassification.ACCELERATOR`) containing the moved `test_rng`; the hardcoded `device=GPU_TYPE` becomes the `device` argument injected by instantiation, and the Triton gate sits on the class (same pattern as pytorch#198357). 2. Instantiate with `except_for="cpu"` (per @lizhihai137's review: keeps the ACCELERATOR contract instead of narrowing the device matrix via `only_for`). `test_rng` relies on `torch._dynamo.utils.preserve_rng_state`, which today saves/restores only CPU, CUDA and XPU RNG state; on backends without generator save/restore the eager-vs-compiled comparison silently diverges and the bisector blames the wrong subsystem (verified on an Ascend NPU: `do_bisect` reports `eager` instead of `inductor`). Such devices now skip explicitly via `@skipPRIVATEUSE1` rather than being silently excluded from instantiation. ## Notes - Generalizing `preserve_rng_state` via `torch.get_device_module(device)` would widen this test's device coverage; that is a source-side change beyond this series, left as a follow-up candidate. - Test IDs change from `TestCompilerBisector.test_rng` to per-device variants (`test_rng_cuda`, `test_rng_xpu`, `test_rng_npu` [skipped], ...). I checked the `test/dynamo_skips/` and `test/dynamo_expected_failures/` entries and the slow-test lists in `main`: nothing is keyed on the old `TestCompilerBisector.test_rng` name. ## Motivation The `@unittest.skipIf(not HAS_GPU)` class guard uses `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`. Out-of-tree accelerators registered via `PrivateUse1` are not in this list, so the test was skipped even where it can run. `instantiate_device_type_tests` gives each supported device its own variant, and `hw_classification` provides metadata for `--hw-classification` filtering. ## Test Plan | Environment | Result | |---|---| | CPU (`env-pytorch-2.16-20261029-cpu`) | `pytest --collect-only -q` -> **11 tests collected** (the moved test no longer appears un-instantiated) | | NPU (`env-pytorch-2.16-20261029-npu`, Ascend 910B4 / CANN 9.2.0 GA / torch_npu 737bb43 / triton-ascend 3.6.0) | `test_rng_npu` is instantiated and **skips cleanly (0.009s)** via `@skipPRIVATEUSE1` instead of being silently absent | | CUDA / XPU execution | covered by the ciflow trunk jobs | | lint | `lintrunner` (includes in-tree TEST_LINTER): no issues | Pull Request resolved: pytorch#198356 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…antiate_device_type_tests (pytorch#198355) ## Summary Move `test_joint_graph` from the `HAS_GPU`-guarded `TestCompilerBisector` into the existing device-instantiated `TestCompilerBisectorDevice` in `test/dynamo/test_compiler_bisector.py`, so it runs on out-of-tree accelerators instead of being skipped. Split from pytorch#191435 (refactoring this file for out-of-tree accelerator support). ## Changes `test/dynamo/test_compiler_bisector.py` (+36 -38): - `test_joint_graph` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. - Drop the now-redundant in-method `from torch._inductor import config` (the module is imported at file scope). - Update the `CustomPostPass.uuid()` string to name `TestCompilerBisectorDevice` after the move (keeps the pass identity meaningful and unique). - The method-level `@unittest.skipIf(not has_triton(), ...)` on the moved test was removed as a duplicate of the class-level decorator of `TestCompilerBisectorDevice`. - The base class itself is untouched here; the GENERIC declaration belongs to pytorch#198360 alone (review note). ## Motivation The class guard `@unittest.skipIf(not HAS_GPU, ...)` treats `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`, so out-of-tree accelerators registered via `PrivateUse1` skip the whole class even though this test only needs a generic accelerator. `instantiate_device_type_tests` with `except_for="cpu"` covers all registered non-CPU device types, and `hw_classification` metadata enables `--hw-classification` filtering. ## Notes The shared scaffold (new class + instantiation) is already on `main`, so this PR is a pure single-method move. Triton gating for `TestCompilerBisectorDevice` lives on the class-level `@unittest.skipIf(not has_triton(), ...)` decorator, the convention already used on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`env-pytorch-2.16-20261029-cpu` venv, `pytest --collect-only`): 11 tests collected on the rebased branch; the moved test now instantiates only for accelerator devices. Re-measured after the follow-up edits: still 11. - NPU real hardware (Ascend 910B4, CANN 9.2.0 GA, `env-pytorch-2.16-20261029-npu` venv with torch_npu 737bb43 + triton-ascend 3.6.0): `pytest -k test_joint_graph_npu` -> **1 passed (32.2s, re-measured after this round's edits)**; previously this test never executed on NPU. - `lintrunner` (includes in-tree TEST_LINTER): no issues, re-run after this round's edits. Rebased onto latest main after pytorch#198358 landed; the class-level Triton gate arrives with pytorch#198357 and this PR will inherit it on the next rebase. ## Dependencies Part of the pytorch#191435 split series (pytorch#198353 ~ pytorch#198362); independent of its siblings, each moves one test method. Pull Request resolved: pytorch#198355 Approved by: https://github.com/lizhihai137, https://github.com/jansel
Summary
Move
test_emulate_precision_castsfrom theHAS_GPU-guardedTestCompilerBisectorinto the existing device-instantiatedTestCompilerBisectorDeviceintest/dynamo/test_compiler_bisector.py, so it runs on out-of-tree accelerators instead of being skipped.Split from #191435 (refactoring this file for out-of-tree accelerator support).
Changes
test/dynamo/test_compiler_bisector.py(+23 -24):test_emulate_precision_castsmoves verbatim (body unchanged) intoTestCompilerBisectorDevice, which#198361already set up andinstantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)instantiates; the hardcodeddevice=GPU_TYPEbecomes the injecteddeviceargument.TestCompilerBisectorDeviceitself: every test in the class requires Triton, so a single class-level@unittest.skipIf(not has_triton(), "requires Triton")replaces the three duplicated method-level decorators (per review).Motivation
The class guard
@unittest.skipIf(not HAS_GPU, ...)treatsHAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON, so out-of-tree accelerators registered viaPrivateUse1skip the whole class even though this test only needs a generic accelerator.instantiate_device_type_testswithexcept_for="cpu"covers all registered non-CPU device types, andhw_classificationmetadata enables--hw-classificationfiltering.Notes
The shared scaffold (new class + instantiation) is already on
mainvia#198361, so the move itself is a single method transfer. The Triton gate stays device-blind (has_triton()); a fully device-aware gate needs a TritonCapabilityin the registry (follow-up). Class-levelskipIfsurvivesinstantiate_device_type_testsbecause the device-specific classes inherit from the template class, verified on real hardware below.Test Plan
torch-2.16-cpunightly wheel): collection identical to baseline modulo the moved test.lintrunner test/dynamo/test_compiler_bisector.py->ok No lint issues.NPU real hardware (Ascend 910B4):
Verification Report
test_emulate_precision_casts_nputest_emulate_precision_casts_npupasses (previously never executed on NPU); 8 skips are theHAS_GPU-guarded legacy class, expectedGate behavior verified both directions on NPU: with Triton installed all three tests in the device class run and pass; with Triton absent the class skips with
requires Triton.Environment
Dependencies
Part of the #191435 split series (#198353 ~ #198362); independent of its siblings, each moves one test method.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98