Repository navigation
[Testcase Refactoring] Clean up old TestCompilerBisector class after device migrations - #198362
gavinwang269 wants to merge 1 commit into
Conversation
PR Status: draftThis PR is waiting for its author to mark it ready for review. Pre-review does not advance while the PR is a draft. 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198362
Note: Links to docs will display an error until the docs builds have been completed.
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@pytorchbot label "module: tests/graph" |
396914d to
8466505
Compare
|
@claude review these changes |
|
Claude finished @jansel's task in 1m 5s —— View job Don't merge this yet: on current PR Review: #198362SummaryThe PR removes the device-dependent tests, the dead Testing
Code Quality
RecommendationRequest Changes Merging now permanently drops 7 GPU tests. After rebasing on the landed migration PRs, only the lint cleanup remains to fix. |
8466505 to
f203644
Compare
|
Follow-up on @claude's review (triggered by @jansel) — all three points confirmed and addressed:
PTAL again once the chain ahead of this merges. |
…tantiate_device_type_tests (#198358) ## Summary Move `test_bad_lowering` 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` (+19 -18): - `test_bad_lowering` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `#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. ## 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` (e.g., Ascend NPU) 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 #198361, so this PR is a pure single-method move. Triton gating keeps the existing device-blind `@unittest.skipIf(not has_triton(), ...)` convention already used by `test_bisect_run_debuginfo` on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`torch-2.15-cpu`, pytest --collect-only): 9 tests collected, identical to `main` baseline; `pytest -q` -> 9 skipped (guard unchanged on CPU). - NPU real hardware (Ascend 910B4, CANN 9.1.0, `torch-2.15-npu`, triton-ascend): `pytest -k test_bad_lowering_npu` -> **1 passed** (previously this test never executed on NPU). - `pycodestyle --select E3` clean; `ruff format --diff` shows no findings in the touched region. ## Dependencies Part of the #191435 split series (#198353 ~ #198362); independent of its siblings, each moves one test method. Pull Request resolved: #198358 Approved by: https://github.com/guilhermeleobas
…tantiate_device_type_tests (pytorch#198358) ## Summary Move `test_bad_lowering` 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` (+19 -18): - `test_bad_lowering` 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. ## 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` (e.g., Ascend NPU) 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 this PR is a pure single-method move. Triton gating keeps the existing device-blind `@unittest.skipIf(not has_triton(), ...)` convention already used by `test_bisect_run_debuginfo` on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`torch-2.15-cpu`, pytest --collect-only): 9 tests collected, identical to `main` baseline; `pytest -q` -> 9 skipped (guard unchanged on CPU). - NPU real hardware (Ascend 910B4, CANN 9.1.0, `torch-2.15-npu`, triton-ascend): `pytest -k test_bad_lowering_npu` -> **1 passed** (previously this test never executed on NPU). - `pycodestyle --select E3` clean; `ruff format --diff` shows no findings in the touched region. ## 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#198358 Approved by: https://github.com/guilhermeleobas
f203644 to
d507bcb
Compare
…tic via instantiate_device_type_tests (#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 #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 `#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 `#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 #191435 split series (#198353 ~ #198362); independent of its siblings, each moves one test method. Pull Request resolved: #198357 Approved by: https://github.com/can-gaa-hou, https://github.com/lizhihai137, https://github.com/jansel
…isector class Re-derived on top of merged reality. The original revision of this PR also dropped seven methods (bad_decomp, joint_graph, rng, emulate_precision_casts, bad_lowering, bisect_pre_grad_graph, cudagraph_bisect_max) whose device-agnostic replacements arrive in sibling PRs, and declared the remaining class GENERIC. Since then only pytorch#198358 (test_bad_lowering) and pytorch#198361 (test_bisect_run_debuginfo) have landed: deleting the still-present six methods now would remove their only coverage before their replacements merge, and labeling the class GENERIC would be wrong while six GPU-bound tests remain under its HAS_GPU gate. Those parts are therefore obsolete-after-merge / premature and were dropped from this PR. What remains valid independently of the sibling series: - Rename the class attribute test_ns -> bisector_ns. An attribute whose name starts with the "test" prefix is a latent test-collection footgun (it would be picked up by instantiate_device_type_tests or prefix-based loaders). - Remove get_lib(), which is dead code after pytorch#198358 (no callers left), together with the Library import and the self.lib teardown it required. Authored with an AI assistant. Signed-off-by: gavinwang269 <[email protected]>
d507bcb to
889b674
Compare
|
Content migrated into #198360 at @can-gaa-hou's request (same file, and the two reviews would otherwise have to be re-run against each other). Closing here; the change is the second half of the commit on #198360, with the collection-count check (10 tests before and after) recorded on that thread. |
|
Superseded by #198360, which now carries this cleanup as requested in review. |
…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
…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
…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
…assified test class (#198360) Summary `test_cudagraph_bisect_max` needs CUDA graphs, so it does not belong in the accelerator-wide `TestCompilerBisector` class, where it was reachable for any device the old aggregate gate accepted. This moves it into a class of its own, classified for CUDA and instantiated through `instantiate_device_type_tests`, Changes - New `TestCompilerBisectorCuda` with `hw_classification = CUDA`, holding `test_cudagraph_bisect_max`, instantiated with `instantiate_device_type_tests(..., only_for="cuda")` so the test takes the injected `device` parameter instead of naming one. - `@requires_cuda` is not kept on top of that: after `only_for="cuda"` the instantiation already answers it, and a second gate would be a second, independently rotting source of the same fact. - The Triton condition that the original class reached through the `HAS_GPU` formula is restored on the class that still needs a Triton kernel, expressed as its own requirement rather than as part of an aggregate boolean. - `test_rng` no longer carries an upstream PrivateUse1 skip; per maintainer direction out-of-tree accelerators are exposed rather than silently skipped, and a backend that does not support it opts out in its own `instantiate_device_type_tests` instantiation. Test Plan Host: torch 2.16.0.dev20261029; the "cpu" venv autoloads torch_npu and therefore registers PrivateUse1, so CPU-only claims below run with `TORCH_DEVICE_BACKEND_AUTOLOAD=0`. All pytest commands from a directory outside the source tree with the absolute file path. CPU-only (no CUDA, no accelerator registered) at head 78146ef: TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -m pytest -q -rs test/dynamo/test_compiler_bisector.py -> collected: 3 (TestCompilerBisector::test_pre_grad / test_crossref / test_eager_backend) -> 3 passed With the `HAS_GPU` gate removed the three GENERIC tests now run on a GPU-less host and pass; that addresses the automated review's request for HEAD numbers. The new head's macOS/Windows CPU test jobs have not reported yet, so those remain CI's to report. Test-ID move: on a CUDA build `test_cudagraph_bisect_max` is `TestCompilerBisectorCudaCUDA.test_cudagraph_bisect_max_cuda` (class name = original + `device_type.upper()`, method suffix `_cuda`, per `instantiate_device_type_tests`). On a machine with no CUDA device type registered it is not collected at all (`only_for="cuda"` matches nothing); collection here is 10 IDs with PrivateUse1 registered vs 11 pre-PR. PrivateUse1-registered host (same wheel, torch_npu autoloaded): python -m pytest -q -rs test/dynamo/test_compiler_bisector.py -> 1 failed, 3 passed, 6 skipped (skips: 6x "requires Triton on npu", the pre-existing per-device gates) The one failure is `TestCompilerBisectorRNGNPU.test_rng_npu` with `String comparison failed: 'eager' != 'inductor'`. This is the intended coverage change decided in review: per @fffrog's instruction the `@skipPRIVATEUSE1` special case is not restored — `test_rng` is exposed to all out-of-tree accelerators and backends that do not support it skip it in their own `instantiate_device_type_tests` instantiation. (`preserve_rng_state` currently preserves only CPU/CUDA/XPU RNG, so an out-of-tree backend without RNG preservation must opt out.) The stock (pre-PR) file run with the same command gives `11 skipped, 0 failed`, isolating this as the deliberate skip-to-exposed delta, not a pre-existing failure. NPU hardware (8x Ascend 910B4, triton-ascend installed): python -m pytest -q -rs test/dynamo/test_compiler_bisector.py -k test_rng -> 1 failed, 9 deselected The bisect diverges on the eager/aot legs (RNG, as above); the inductor leg on this wheel additionally hits a pre-existing torch_npu codegen skew (`NPUPythonWrapperCodeGen... 'tunable_dyn_dims_mask'`), reproduced with a plain `torch.compile` of the same function and unrelated to this change. Pre-PR the same command skipped with "test doesn't work on privateuse1 backend". Lint: python tools/linter/adapters/test_linter.py test/dynamo/test_compiler_bisector.py -> no findings (allowlist entry removed in this PR) lintrunner test/dynamo/test_compiler_bisector.py tools/linter/adapters/test_linter_allowlist.json -> ok No lint issues. Not covered here: the CUDA legs (`test_cudagraph_bisect_max_cuda`, the cuda/xpu variants of the Triton-gated tests) — this host has no NVIDIA hardware; the upstream hardware shards run those. Signed-off-by: gavinwang269 <[email protected]> - `TestCompilerBisector` gains `hw_classification = HardwareClassification.GENERIC` (review request), byte-identical to the declaration in #198354/#198355 so the three slices converge in any merge order. - Bare one-line `hw_classification = HardwareClassification.GENERIC` on `TestCompilerBisector` (the only PR adding it). Once #198354/#198355 have moved the remaining GPU_TYPE occupants, the import-time `HAS_GPU` decorator and the `HAS_GPU`/`GPU_TYPE` imports are retired here too, so the natural merge order lands the exact end state. Rebase note (2026-11-09): replayed onto current main after #198354/#198355 merged, and per review this now also removes the import-time HAS_GPU gate and the GPU_TYPE/HAS_GPU import (both have no users left in the file). The single GENERIC declaration here is the only one across the series. Scope note: an earlier revision of this PR carried the dead-scaffolding cleanup from #198362; per the review discussion that cleanup is dropped, and this PR closes out the bisector series with the move and the classification only (+53/-53). Final-cleanup note (2026-11-10): as the last PR touching test_compiler_bisector.py in this series, this also drops the file entry from tools/linter/adapters/test_linter_allowlist.json (TEST_LINTER runs clean on the file after the removal), and moves the Triton gates to accelerator-aware @skipIf(..., device_type=...) forms, narrowed per review on each class. Pull Request resolved: #198360 Approved by: https://github.com/fffrog, https://github.com/lizhihai137, https://github.com/can-gaa-hou
Summary
Final leftover cleanup of the old
TestCompilerBisectorclass intest/dynamo/test_compiler_bisector.py, split from #191435 (refactoring this file for out-of-tree accelerator support).Scope reduced after rebase: the previously planned deletion of the seven still-present device-dependent tests and the
HAS_GPUclass-guard removal are dropped from this PR — several sibling move PRs in the series (#198354–#198360, #198359) are still open, so those deletions would drop coverage today ("must merge LAST" premise still unmet). They can be revisited once the remaining siblings land; the file will then be naturally clean without needing this PR to delete anything.Changes (minimal remainder)
test/dynamo/test_compiler_bisector.pyonly (+6/−13):test_ns→bisector_nsfor clarity (a helper, not a test).get_lib()and theLibraryimport name (the only callertest_crossrefuses the_scoped_librarycontext manager).tearDownto the remaining live cleanups.Kept as-is (genuinely generic):
test_pre_grad,test_crossref,test_eager_backend.Test plan
Sibling series status
Merged: #198361 (
test_bisect_run_debuginfo), #198358 (test_bad_lowering). Still open: #198354, #198355, #198356, #198357, #198359, #198360. This PR no longer depends on them for coverage reasons since the deletion part was dropped; it is safe to review/merge independently.Notes
Part of the hardware-decoupling effort tracking RFC #189138. Split from #191435.