Repository navigation
[Testcase Refactoring] Split TestFastLauncherCompileResult into mixin, accelerator and CUDA-only classes - #198440
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 (4): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198440
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit d920f47 with merge base 50d50e7 ( NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following job failed, but the AI CI Advisor judged the failure not to be evidence against this change:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/graph" |
bd51c97 to
561d0e0
Compare
561d0e0 to
2e5b444
Compare
…ixin + fallback + CUDA classes Part of splitting pytorch#192893 (one class per PR, zero overlap).
2e5b444 to
0c0b20b
Compare
|
@jansel same ask as on #198439: the five workflows on This is the larger of the two launcher splits, still one file (
Flagging the same judgment call here, and it is sharper in this PR: |
|
@pytorchbot triage |
…antiate_device_type_tests
Split the monolithic TestFastLauncher class: the fast-launcher C-extension
tests that apply to any Triton accelerator stay in TestFastLauncher
(HardwareClassification.ACCELERATOR, instantiated only_for=("cuda", "xpu")),
the XPU-specific tests move to TestFastLauncherXpuOnly
(HardwareClassification.XPU, only_for="xpu"), and the shared builders move
into a _FastLauncherMixin helper class. write_cubin_to_tmp and _make_launcher
gain an explicit device argument and pick the binary key per device (npubin
alongside zebin/cubin/hsaco).
Rebase notes (onto main after pytorch#198440): pytorch#198440 refactored the separate
TestFastLauncherCompileResult class into mixin + fallback + CUDA classes;
those classes are untouched here. This PR's two instantiate calls join the
trailing instantiate_device_type_tests group.
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant. Rebase notes (onto main after pytorch#199309): main's two new oversized shared memory tests (test_oversized_shared_mem, test_too_high_oversized_shared_mem) are kept and converted to this PR's per-device form: injected device argument, per-test Triton gate, and a CUDA-only SkipTest guard since the shared helper _oversized_shared_mem_limits() reads torch.cuda device properties. The from pathlib import Path import is restored because test_make_launcher_reuses_loaded_kernel_after_cache_context still calls Path(); without it the PR head raises NameError (undefined-name check on the pre-rebase head confirms this predates the rebase). Rebase notes (onto main after pytorch#198440): pytorch#198440 refactored the unrelated TestFastLauncherCompileResult class and moved the file's instantiate_device_type_tests calls into a single trailing group; this PR's TestStaticTritonLauncher instantiation now joins that group. The import-block and tail hunks merged accordingly; nothing inside the decoupled class changed.
…stic via instantiate_device_type_tests Part of splitting pytorch#192893 (one class per PR, zero overlap). Rebase notes (onto current main): main added test_oversized_shared_mem_mm_template to this class after the branch was cut. It is kept and converted to this PR's per-device form: injected device argument, per-test Triton gate, and a CUDA-only SkipTest guard since the helper _oversized_shared_mem_limits() reads torch.cuda device properties. The instantiate call joins the trailing instantiate_device_type_tests group introduced by pytorch#198440.
…mpileResult Responds to the automated CHANGES_REQUESTED review on pytorch#198438. Blocking (test/REVIEW.md Rules 1/2): test_oversized_shared_mem_mm_template and test_basic_compile_pdl are CUDA-only (the former reads CUDA device properties and builds a CUDAMMTemplateConfigHeuristic; the latter gates on SM90OrLater and PDL, supported only by StaticallyLaunchedCudaKernel), so they move to a new TestCudaStaticTritonCompileResult (hw_classification CUDA, instantiated only_for=("cuda",)), following the merged pytorch#198440 split of TestFastLauncherCompileResult in this file. The rebase-introduced "!= cuda" body guard and skipIfXpu are superseded by the CUDA-only instantiation: filter_desired_device_types normalizes out-of-tree backend names to "privateuse1", which only_for drops, so the class is never instantiated for PrivateUse1 and the torch.cuda reads happen only on cuda. That also resolves the crash the guard was introduced for in the sibling pytorch#198437 rebase (a PrivateUse1 variant raising in torch.cuda.current_device() instead of skipping): with the tests out of the except_for="cpu" class no other accelerator instantiates them, and the shared per-device setUp gates skip before the body runs even if PYTORCH_TESTING_DEVICE_FOR_CUSTOM opts a PrivateUse1 base into the CUDA class. Non-blocking: the eight host-wide unittest.skipIf(not has_triton()) decorators and the missing gate on test_basic_compile_pdl are replaced by one has_triton_for_device check plus an is_registered_static_launch_device check in the shared _StaticTritonCompileResultMixin setUp, placed before the config patch is entered (tearDown does not run when setUp raises), following pytorch#198359; test_disable_static_triton_launcher is exempt from the registration gate because it runs with the launcher off, where strict mode raising CannotStaticallyLaunchKernel was the other failure mode. test_custom_op_bad_fake_dtype_fails_fast stays in the ACCELERATOR class; its host-wide skipIfXpu becomes skipXPUIf from common_device_type (Rule 4), which no longer skips the CUDA variant on TEST_XPU hosts, with a reason that no longer claims the dtype check is CUDA launcher-specific (it comes from the generic assert_tensor_metadata wrapper codegen); the XPU exclusion is kept because the fail-fast path has never been verified there (Rule 6). skipIfRocm moves with the two tests into the CUDA class, where Rule 5 adds no requirements, and SM90OrLater keeps its decorator for the same reason. Stale "static cuda launcher" wording in the class docstring and the disable-test comment is corrected. Test Plan: no working torch environment on the machine that prepared this commit, so verification was static: ``` python -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())" ``` plus AST checks of final class membership (ACCELERATOR keeps the seven device-agnostic tests; the CUDA class holds only the two moved tests), line-length and ASCII checks on changed lines, and grep of the instantiate wiring. CI exercises the CUDA variants of both classes. Authored with AI assistance and reviewed by the PR owner before submission. Co-Authored-By: gavinwang269 <[email protected]>
…r hw classes (#198439) ## Summary Make `TestFastLauncher` in `test/inductor/test_static_triton_launcher.py` hardware-classified and instantiated for both CUDA and XPU, keeping every test that ran before the split running after it. Split from #192893 (one test class per PR, zero overlap), rebased onto main after #200916 renamed `TestFastCudaLauncher` to `TestFastLauncher` and moved the shared helpers into `StaticLauncherTestMixin`. ## Changes - `TestFastLauncher` declares `hw_classification = HardwareClassification.ACCELERATOR` and is instantiated with `only_for=("cuda", "xpu"), allow_xpu=True` (the in-tree combination used by e.g. test_comparison_utils.py, test_gpu_trace.py, test/dynamo/test_after_aot.py). Five tests (`test_basic`, `test_multiple_tensor_args`, `test_zero_grid`, `test_wrong_arg_count`, `test_too_many_args_raises_value_error`) take the injected `device` argument; the remaining tests resolve `GPU_TYPE`, which equals the running device on the CUDA and XPU single-device-type CI runners. - The five XPU-specific tests (`test_xpu_static_shared_mem`, `test_xpu_fast_kernel_arg_count_mismatch`, `test_xpu_rejects_invalid_launch_metadata`, `test_xpu_rejects_unloaded_kernel`, `test_xpu_keeps_kernel_capsule_alive`) move to a new `TestFastLauncherXpuOnly` class: `hw_classification = HardwareClassification.XPU`, instantiated with `only_for="xpu", allow_xpu=True`, keeping their `@unittest.skipUnless(HAS_XPU_AND_TRITON)` guards. On non-XPU devices the class collects empty (the generic form is deleted by instantiation and no variant is generated). - The fast-launcher construction helpers (`_fast_launcher_cls`, `_make_fast_launcher`, `_stream`, `_store_sum_launcher`) move into a file-private `_FastLauncherMixin` shared by the two classes. `StaticLauncherTestMixin` is unchanged; its `_make_launcher`/`write_cubin_to_tmp` device-optional form stays byte-identical with the sibling #198437 so whichever lands first supplies them. Why `only_for=("cuda", "xpu")` instead of `except_for="cpu"`: the static launcher registry (`torch/_inductor/runtime/static_triton_launcher.py`) only has `cuda`/`hip`/`xpu` entries, so `except_for="cpu"` would generate MPS/PrivateUse1 variants that hard-error in `_make_launcher` instead of skipping; `cuda`+`xpu` is exactly the device set the pre-series `GPU_TYPE` gating covered. ## Notes - **Test IDs change for the whole class.** `TestFastLauncher.test_x` becomes `TestFastLauncherCUDA.test_x_cuda` (and a `TestFastLauncherXPU...._xpu` variant on XPU runners); the XPU-specific tests become `TestFastLauncherXpuOnlyXPU.test_xpu_*_xpu` there. No in-tree DISABLED/slow-test entries reference the old names (grepped `test/`, `.ci/`, `tools/`). - The `write_cubin_to_tmp` helper in this diff gains an `npubin` binary key alongside `zebin`/`cubin`/`hsaco` for the out-of-tree NPU backends that motivate this series; having the backend supply its binary key via `register_statically_launched_kernel` is a plausible follow-up. - MTIA coverage: previously `GPU_TYPE`-gated classes could resolve to MTIA on MTIA runners; no MTIA test base is registered here, so no MTIA variants are generated. A coverage note, not a regression on currently-tested devices. ## Motivation The static Triton launcher tests are gated by `@requires_gpu_and_triton` / `GPU_TYPE`, which only recognize in-tree devices (`cuda`/`mps`/`xpu`/`mtia`): out-of-tree accelerators registered via `PrivateUse1` never run them. Migrating each class to `instantiate_device_type_tests` + `hw_classification` makes the tests device-agnostic and classifiable by `--hw-classification` filtering. This PR makes that true for `TestFastLauncher` without dropping its existing XPU coverage. ## Test Plan CPU-only host (torch `2.16.0.dev20261102+cpu` wheel; no CUDA or XPU device available): ``` python -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())" cd /tmp && python -I -m pytest <repo-checkout>/test/inductor/test_static_triton_launcher.py --collect-only -q cd /tmp && python -I -m pytest <repo-checkout>/test/inductor/test_static_triton_launcher.py -q uv run --python 3.11 --script tools/linter/adapters/pyfmt_linter.py -- test/inductor/test_static_triton_launcher.py uv run --python 3.10 --script tools/linter/adapters/ruff_linter.py -- test/inductor/test_static_triton_launcher.py python3 tools/linter/adapters/test_linter.py test/inductor/test_static_triton_launcher.py ``` - Collect: 60 tests on the rebased head (the pre-rebase head collected 58; the delta is entirely main-side: 3 unit-class ids removed by #198440's restructure and 5 main-added tests absent from the older base); no instantiated `TestFastLauncher*` variants on a CPU-only host, as designed. - Run: 22 passed, 36 skipped, 2 failed. Both failures are in the untouched `TestStaticTritonLauncherUnit` (the CPU wheel carries no `_FastXpuLauncher` extension, and without Triton/GPU compilation no cubin is produced) and reproduce identically on the unmodified current-main file in the same environment (wheel-vs-trunk drift), so this change is CPU-neutral. - Import probe: importing the module with a recording stub over `instantiate_device_type_tests` asserts both generic classes, their `hw_classification` values, the exact test placement (the 5 `test_xpu_*` tests only in `TestFastLauncherXpuOnly`), helper resolution through `_FastLauncherMixin`, the retained skip guards, and the instantiate kwargs; `filter_by_hw_classification` is exercised directly (`{ACCELERATOR}` keeps the shared class, `{XPU}` keeps `TestFastLauncherXpuOnly`). - Lint: pyfmt and CI-pinned ruff 0.14.4 (check + format) clean; `test_linter.py` reports nothing (the file is in its allowlist, like the precedent files above). CUDA and XPU on-device execution of the instantiated classes is delegated to CI; the authoring host has neither device. ## Agent details (if applicable) This description and the linked review replies were drafted with an AI assistant and reviewed against the diff by the author before posting. Rebase note (2026-11-16): rebased onto current main after #198440 landed. #198440 refactored the separate `TestFastLauncherCompileResult` class (untouched here) and gathered the file's `instantiate_device_type_tests` calls into a single trailing group; this PR's two instantiation calls now join that group and its two import lines dedup against main. The branch's three commits were squashed into one (head `d3924245614`); diff +61/-33 -> +57/-33; no scope change. Pull Request resolved: #198439 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…stic via instantiate_device_type_tests Part of splitting pytorch#192893 (one class per PR, zero overlap). Rebase notes (onto current main): main added test_oversized_shared_mem_mm_template to this class after the branch was cut. It is kept and converted to this PR's per-device form: injected device argument, per-test Triton gate, and a CUDA-only SkipTest guard since the helper _oversized_shared_mem_limits() reads torch.cuda device properties. The instantiate call joins the trailing instantiate_device_type_tests group introduced by pytorch#198440.
…mpileResult Responds to the automated CHANGES_REQUESTED review on pytorch#198438. Blocking (test/REVIEW.md Rules 1/2): test_oversized_shared_mem_mm_template and test_basic_compile_pdl are CUDA-only (the former reads CUDA device properties and builds a CUDAMMTemplateConfigHeuristic; the latter gates on SM90OrLater and PDL, supported only by StaticallyLaunchedCudaKernel), so they move to a new TestCudaStaticTritonCompileResult (hw_classification CUDA, instantiated only_for=("cuda",)), following the merged pytorch#198440 split of TestFastLauncherCompileResult in this file. The rebase-introduced "!= cuda" body guard and skipIfXpu are superseded by the CUDA-only instantiation: filter_desired_device_types normalizes out-of-tree backend names to "privateuse1", which only_for drops, so the class is never instantiated for PrivateUse1 and the torch.cuda reads happen only on cuda. That also resolves the crash the guard was introduced for in the sibling pytorch#198437 rebase (a PrivateUse1 variant raising in torch.cuda.current_device() instead of skipping): with the tests out of the except_for="cpu" class no other accelerator instantiates them, and the shared per-device setUp gates skip before the body runs even if PYTORCH_TESTING_DEVICE_FOR_CUSTOM opts a PrivateUse1 base into the CUDA class. Non-blocking: the eight host-wide unittest.skipIf(not has_triton()) decorators and the missing gate on test_basic_compile_pdl are replaced by one has_triton_for_device check plus an is_registered_static_launch_device check in the shared _StaticTritonCompileResultMixin setUp, placed before the config patch is entered (tearDown does not run when setUp raises), following pytorch#198359; test_disable_static_triton_launcher is exempt from the registration gate because it runs with the launcher off, where strict mode raising CannotStaticallyLaunchKernel was the other failure mode. test_custom_op_bad_fake_dtype_fails_fast stays in the ACCELERATOR class; its host-wide skipIfXpu becomes skipXPUIf from common_device_type (Rule 4), which no longer skips the CUDA variant on TEST_XPU hosts, with a reason that no longer claims the dtype check is CUDA launcher-specific (it comes from the generic assert_tensor_metadata wrapper codegen); the XPU exclusion is kept because the fail-fast path has never been verified there (Rule 6). skipIfRocm moves with the two tests into the CUDA class, where Rule 5 adds no requirements, and SM90OrLater keeps its decorator for the same reason. Stale "static cuda launcher" wording in the class docstring and the disable-test comment is corrected. Test Plan: no working torch environment on the machine that prepared this commit, so verification was static: ``` python -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())" ``` plus AST checks of final class membership (ACCELERATOR keeps the seven device-agnostic tests; the CUDA class holds only the two moved tests), line-length and ASCII checks on changed lines, and grep of the instantiate wiring. CI exercises the CUDA variants of both classes. Authored with AI assistance and reviewed by the PR owner before submission. Co-Authored-By: gavinwang269 <[email protected]>
…stic via instantiate_device_type_tests [Testcase Refactoring] make TestStaticTritonCompileResult device-agnostic via instantiate_device_type_tests Part of splitting pytorch#192893 (one class per PR, zero overlap). Rebase notes (onto current main): main added test_oversized_shared_mem_mm_template to this class after the branch was cut. It is kept and converted to this PR's per-device form: injected device argument, per-test Triton gate, and a CUDA-only SkipTest guard since the helper _oversized_shared_mem_limits() reads torch.cuda device properties. The instantiate call joins the trailing instantiate_device_type_tests group introduced by pytorch#198440.
…r hw classes (pytorch#198439) ## Summary Make `TestFastLauncher` in `test/inductor/test_static_triton_launcher.py` hardware-classified and instantiated for both CUDA and XPU, keeping every test that ran before the split running after it. Split from pytorch#192893 (one test class per PR, zero overlap), rebased onto main after pytorch#200916 renamed `TestFastCudaLauncher` to `TestFastLauncher` and moved the shared helpers into `StaticLauncherTestMixin`. ## Changes - `TestFastLauncher` declares `hw_classification = HardwareClassification.ACCELERATOR` and is instantiated with `only_for=("cuda", "xpu"), allow_xpu=True` (the in-tree combination used by e.g. test_comparison_utils.py, test_gpu_trace.py, test/dynamo/test_after_aot.py). Five tests (`test_basic`, `test_multiple_tensor_args`, `test_zero_grid`, `test_wrong_arg_count`, `test_too_many_args_raises_value_error`) take the injected `device` argument; the remaining tests resolve `GPU_TYPE`, which equals the running device on the CUDA and XPU single-device-type CI runners. - The five XPU-specific tests (`test_xpu_static_shared_mem`, `test_xpu_fast_kernel_arg_count_mismatch`, `test_xpu_rejects_invalid_launch_metadata`, `test_xpu_rejects_unloaded_kernel`, `test_xpu_keeps_kernel_capsule_alive`) move to a new `TestFastLauncherXpuOnly` class: `hw_classification = HardwareClassification.XPU`, instantiated with `only_for="xpu", allow_xpu=True`, keeping their `@unittest.skipUnless(HAS_XPU_AND_TRITON)` guards. On non-XPU devices the class collects empty (the generic form is deleted by instantiation and no variant is generated). - The fast-launcher construction helpers (`_fast_launcher_cls`, `_make_fast_launcher`, `_stream`, `_store_sum_launcher`) move into a file-private `_FastLauncherMixin` shared by the two classes. `StaticLauncherTestMixin` is unchanged; its `_make_launcher`/`write_cubin_to_tmp` device-optional form stays byte-identical with the sibling pytorch#198437 so whichever lands first supplies them. Why `only_for=("cuda", "xpu")` instead of `except_for="cpu"`: the static launcher registry (`torch/_inductor/runtime/static_triton_launcher.py`) only has `cuda`/`hip`/`xpu` entries, so `except_for="cpu"` would generate MPS/PrivateUse1 variants that hard-error in `_make_launcher` instead of skipping; `cuda`+`xpu` is exactly the device set the pre-series `GPU_TYPE` gating covered. ## Notes - **Test IDs change for the whole class.** `TestFastLauncher.test_x` becomes `TestFastLauncherCUDA.test_x_cuda` (and a `TestFastLauncherXPU...._xpu` variant on XPU runners); the XPU-specific tests become `TestFastLauncherXpuOnlyXPU.test_xpu_*_xpu` there. No in-tree DISABLED/slow-test entries reference the old names (grepped `test/`, `.ci/`, `tools/`). - The `write_cubin_to_tmp` helper in this diff gains an `npubin` binary key alongside `zebin`/`cubin`/`hsaco` for the out-of-tree NPU backends that motivate this series; having the backend supply its binary key via `register_statically_launched_kernel` is a plausible follow-up. - MTIA coverage: previously `GPU_TYPE`-gated classes could resolve to MTIA on MTIA runners; no MTIA test base is registered here, so no MTIA variants are generated. A coverage note, not a regression on currently-tested devices. ## Motivation The static Triton launcher tests are gated by `@requires_gpu_and_triton` / `GPU_TYPE`, which only recognize in-tree devices (`cuda`/`mps`/`xpu`/`mtia`): out-of-tree accelerators registered via `PrivateUse1` never run them. Migrating each class to `instantiate_device_type_tests` + `hw_classification` makes the tests device-agnostic and classifiable by `--hw-classification` filtering. This PR makes that true for `TestFastLauncher` without dropping its existing XPU coverage. ## Test Plan CPU-only host (torch `2.16.0.dev20261102+cpu` wheel; no CUDA or XPU device available): ``` python -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())" cd /tmp && python -I -m pytest <repo-checkout>/test/inductor/test_static_triton_launcher.py --collect-only -q cd /tmp && python -I -m pytest <repo-checkout>/test/inductor/test_static_triton_launcher.py -q uv run --python 3.11 --script tools/linter/adapters/pyfmt_linter.py -- test/inductor/test_static_triton_launcher.py uv run --python 3.10 --script tools/linter/adapters/ruff_linter.py -- test/inductor/test_static_triton_launcher.py python3 tools/linter/adapters/test_linter.py test/inductor/test_static_triton_launcher.py ``` - Collect: 60 tests on the rebased head (the pre-rebase head collected 58; the delta is entirely main-side: 3 unit-class ids removed by pytorch#198440's restructure and 5 main-added tests absent from the older base); no instantiated `TestFastLauncher*` variants on a CPU-only host, as designed. - Run: 22 passed, 36 skipped, 2 failed. Both failures are in the untouched `TestStaticTritonLauncherUnit` (the CPU wheel carries no `_FastXpuLauncher` extension, and without Triton/GPU compilation no cubin is produced) and reproduce identically on the unmodified current-main file in the same environment (wheel-vs-trunk drift), so this change is CPU-neutral. - Import probe: importing the module with a recording stub over `instantiate_device_type_tests` asserts both generic classes, their `hw_classification` values, the exact test placement (the 5 `test_xpu_*` tests only in `TestFastLauncherXpuOnly`), helper resolution through `_FastLauncherMixin`, the retained skip guards, and the instantiate kwargs; `filter_by_hw_classification` is exercised directly (`{ACCELERATOR}` keeps the shared class, `{XPU}` keeps `TestFastLauncherXpuOnly`). - Lint: pyfmt and CI-pinned ruff 0.14.4 (check + format) clean; `test_linter.py` reports nothing (the file is in its allowlist, like the precedent files above). CUDA and XPU on-device execution of the instantiated classes is delegated to CI; the authoring host has neither device. ## Agent details (if applicable) This description and the linked review replies were drafted with an AI assistant and reviewed against the diff by the author before posting. Rebase note (2026-11-16): rebased onto current main after pytorch#198440 landed. pytorch#198440 refactored the separate `TestFastLauncherCompileResult` class (untouched here) and gathered the file's `instantiate_device_type_tests` calls into a single trailing group; this PR's two instantiation calls now join that group and its two import lines dedup against main. The branch's three commits were squashed into one (head `d3924245614`); diff +61/-33 -> +57/-33; no scope change. Pull Request resolved: pytorch#198439 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…via instantiate_device_type_tests Summary Completes the device-agnostic migration of the CUDA-facing tests in TestStaticTritonLauncher on top of the post-pytorch#198439/pytorch#198440 reality: - the class becomes ACCELERATOR-classified and instantiated (except_for="cpu", allow_xpu=True); the class-level @requires_gpu_and_triton decorator is replaced by per-test Triton skips so the instantiated variants keep the same effective guard set; - float/scalar/ABI tests that were missing the injected device now take it (test_float_scalars, test_bfloat16_scalar, and both oversized-shared-memory tests), replacing GPU_TYPE in the bodies; - the six XPU-specific tests move to a dedicated XPU-classified TestStaticTritonLauncherXpuOnly instantiated with only_for="xpu", mirroring TestFastLauncherXpuOnly from pytorch#198439 - XPU capsule/ABI behavior is accelerator-specific and does not belong in an ACCELERATOR class; - the mixin helpers already gained device parameters via pytorch#198439/pytorch#198440, so this PR no longer touches them; the XPU-only tests pytorch#198439 added to the old class are preserved verbatim (in their new home). Test Plan - cpu-wheel venv (no accelerator here): collection and skip profile reviewed; remaining failures are wheel-vs-trunk drift artifacts reproduced identically on the pristine base file; - the XPU-specific split is covered by the CI xpu shards (only_for="xpu") - no local XPU hardware here; - lintrunner and the in-tree test linter clean for this class region with the allowlist entry for the file removed.
…RIC hardware-classification class Part of splitting pytorch#192893 (one class per PR, zero overlap). Last PR of the static-launcher split series: as the final step it also drops the file's entry from tools/linter/adapters/test_linter_allowlist.json, so the in-tree test linter runs in enforcement mode on the whole file once the sibling slices (pytorch#198437, pytorch#198438, pytorch#198439, pytorch#198440, pytorch#203548, pytorch#203550, pytorch#203551, pytorch#205277) have landed - each of which owns its own class region. This PR is meant to merge strictly last. Test Plan - the Unit class body contains no accelerator API usage, so the GENERIC declaration is clean under the linter's AcceleratorApiRule (verified with the allowlist entry removed); - with all sibling PRs applied, TEST_LINTER reports zero errors for the file in enforcement mode.
…stic via instantiate_device_type_tests (#198438) ## Summary Make `TestStaticTritonCompileResult` device-agnostic via `instantiate_device_type_tests`, and move its CUDA-only tests to a new `TestCudaStaticTritonCompileResult`. Split from #192893 (refactoring `test/inductor/test_static_triton_launcher.py` for out-of-tree accelerator support), one test class per PR so each piece is independent. ## Changes `test/inductor/test_static_triton_launcher.py`: - `TestStaticTritonCompileResult` (`hw_classification = ACCELERATOR`, :1410) keeps the seven device-agnostic tests and is instantiated `except_for="cpu", allow_xpu=True` (:2179-2181). The class-level `@requires_gpu_and_triton` decorator is gone: Triton availability is now checked per device in the shared setUp. - `test_oversized_shared_mem_mm_template` and `test_basic_compile_pdl` are CUDA launcher features (silent recompile with `num_stages=1` on oversized shared memory; PDL via `StaticallyLaunchedCudaKernel`), so they move to `TestCudaStaticTritonCompileResult` (`hw_classification = CUDA`, :1548), instantiated `only_for=("cuda",)` (:2182-2184) — following the merged #198440 split of `TestFastLauncherCompileResult` in this same file, including the shared-mixin shape (`_StaticTritonCompileResultMixin` :1384 mirrors `_FastLauncherCompileMixin`). - The mixin setUp (:1393-1407) runs both device gates before `super().setUp()` — a test skipped in setUp never reaches tearDown, so the base classes' setUp state must not be reached first (pattern per #198359, `test/dynamo/test_compiler_bisector.py:145-148`): `has_triton_for_device(self.device_type)` (:1394), and `is_registered_static_launch_device(self.device_type)` (:1401), which exempts `test_disable_static_triton_launcher` by name prefix (:1398, `instantiate_device_type_tests` registers device-suffixed names such as `test_disable_static_triton_launcher_cuda`) because that test runs with the launcher off and would otherwise hit `strict_static_triton_launcher` raising instead of skipping on unregistered devices. The config patch `{"use_static_triton_launcher": True, "strict_static_triton_launcher": True}` moves from the class decorator into setUp via `self.enterContext(...)` (:1404-1407), whose cleanup runs even when setUp raises. - `TestCudaStaticTritonCompileResult.setUp` additionally skips non-`cuda` device types (:1555-1561): `PYTORCH_TESTING_DEVICE_FOR_CUSTOM` re-adds matching device bases after `only_for` is applied (`common_device_type.py:1251-1253, 1284-1287`), so without this the oversized-shared-memory test could get a PrivateUse1 variant reading `torch.cuda` device properties. - `test_custom_op_bad_fake_dtype_fails_fast` stays in the ACCELERATOR class; its host-wide `@skipIfXpu` becomes `@skipXPUIf(True, ...)` (:1471), which targets the XPU instantiation instead of any TEST_XPU host (Rule 4), with a corrected reason: the fail-fast dtype check comes from the generic `assert_tensor_metadata` wrapper codegen, not a CUDA launcher path. The exclusion stands because the path has never run on XPU (Rule 6); happy to un-skip in a follow-up once verified there. ## Notes - This PR is self-contained: it adds the three imports its classes need (`skipXPUIf`, `has_triton_for_device`, `is_registered_static_launch_device`); the `instantiate_device_type_tests` / `HardwareClassification` scaffold already lands with #198440 in the same file. Sibling pieces of this split touch only their own classes; where both append `instantiate_device_type_tests(...)` calls at the file end, resolution is a one-line keep-both. - MTIA coverage: previously `GPU_TYPE`-gated classes could resolve to MTIA on MTIA runners; no MTIA test base is registered here, so no MTIA variants are generated. A coverage note, not a regression on currently-tested devices. ## Motivation The static Triton launcher tests are gated by `@requires_gpu_and_triton` / `GPU_TYPE`, which only recognize in-tree devices (`cuda`/`mps`/`xpu`/`mtia`): out-of-tree accelerators registered via `PrivateUse1` never run them. Migrating each class to `instantiate_device_type_tests` + `hw_classification` makes the tests device-agnostic and classifiable by `--hw-classification` filtering. The registry gate keeps the strict-launcher config from turning a missing out-of-tree static launcher into an error for the tests that need one, while still letting `test_disable_static_triton_launcher` exercise the launcher-off path on every Triton-capable device. ## Test Plan | Environment | Result | |---|---| | CPU-only (`torch-2.15-cpu`) | At head `5ad9c394`: `pytest test/inductor/test_static_triton_launcher.py` collects 69 tests -> **22 passed / 45 skipped / 2 failed**, both failures reproducing identically on the unmodified main file (pre-existing); this class's instantiated variants collect zero on CPU-only, as designed (earlier branch-cut-base run: 8 passed / 26 skipped). | | NPU (Ascend 910B4, CANN 9.1.0 GA, torch 2.14.0.dev + torch_npu 2.14 + triton-ascend 3.6.0) | variants exercised in #192893's full-file run (21/24; 3 failures tracked as accelerator limitations: uint64 zero_, fp64 isinf lowering, worker-thread config propagation) | The review-fix heads `8ed07571` (CUDA-class split) and `1ff6807ef0` (setUp gate fixes) were verified statically — `python -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())"`, AST/grep checks of final class membership and instantiate wiring, line-length/ASCII checks on changed lines — because no working torch environment is available on the machine that prepared them. CI exercises the CUDA variants of both classes; the per-device gates skip cleanly elsewhere. Authored with AI assistance and reviewed by the PR owner before submission. Rebase note (2026-11-16): #198440 landed in this file and gathered the `instantiate_device_type_tests` calls into a single trailing group; this PR's instantiation joins that group and its import lines dedup against main. Since the branch was cut, main also added `test_any` (already in device form) and `test_oversized_shared_mem_mm_template` to this class; the latter is converted here to the device-parameter form and now lives in the CUDA-only class. Re-verified on a CPU-only wheel at that point: the file collects 69 tests (22 passed / 45 skipped / 2 failed), both failures pre-existing on current main (reproduced identically on the unmodified main file); this class's instantiated variants collect zero on CPU-only, as designed. CUDA/NPU legs delegated to CI. Rebase note (2026-11-17): rebased onto current main after #198439/#198440 merged; the three review-round commits were squashed into one (the mixin split plus the device-suffixed exemption/skip-ordering fixes from the final round are all in). Diff unchanged in substance: mixin + TestStaticTritonCompileResult instantiation, gates skip before super().setUp(), config patch via enterContext. Pull Request resolved: #198438 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…via instantiate_device_type_tests Summary Completes the device-agnostic migration of the CUDA-facing tests in TestStaticTritonLauncher on top of the post-pytorch#198439/pytorch#198440 reality: - the class becomes ACCELERATOR-classified and instantiated (except_for="cpu", allow_xpu=True); the class-level @requires_gpu_and_triton decorator is replaced by per-test Triton skips so the instantiated variants keep the same effective guard set; - float/scalar/ABI tests that were missing the injected device now take it (test_float_scalars, test_bfloat16_scalar, and both oversized-shared-memory tests), replacing GPU_TYPE in the bodies; - the six XPU-specific tests move to a dedicated XPU-classified TestStaticTritonLauncherXpuOnly instantiated with only_for="xpu", mirroring TestFastLauncherXpuOnly from pytorch#198439 - XPU capsule/ABI behavior is accelerator-specific and does not belong in an ACCELERATOR class; - the mixin helpers already gained device parameters via pytorch#198439/pytorch#198440, so this PR no longer touches them; the XPU-only tests pytorch#198439 added to the old class are preserved verbatim (in their new home). Test Plan - cpu-wheel venv (no accelerator here): collection and skip profile reviewed; remaining failures are wheel-vs-trunk drift artifacts reproduced identically on the pristine base file; - the XPU-specific split is covered by the CI xpu shards (only_for="xpu") - no local XPU hardware here; - lintrunner and the in-tree test linter clean for this class region with the allowlist entry for the file removed.
…RIC hardware-classification class Part of splitting pytorch#192893 (one class per PR, zero overlap). Last PR of the static-launcher split series: as the final step it also drops the file's entry from tools/linter/adapters/test_linter_allowlist.json, so the in-tree test linter runs in enforcement mode on the whole file once the sibling slices (pytorch#198437, pytorch#198438, pytorch#198439, pytorch#198440, pytorch#203548, pytorch#203550, pytorch#203551, pytorch#205277) have landed - each of which owns its own class region. This PR is meant to merge strictly last. Test Plan - the Unit class body contains no accelerator API usage, so the GENERIC declaration is clean under the linter's AcceleratorApiRule (verified with the allowlist entry removed); - with all sibling PRs applied, TEST_LINTER reports zero errors for the file in enforcement mode.
…r device injection Summary The automated review on pytorch#205277 flagged the `ACCELERATOR` -> `CUDA` relabel of `TestFastLauncher` and `TestFastLauncherFallbackCompileResult` as a blocking mislabel, and this commit agrees with it after checking the mechanism in the code. Both classes are still instantiated with `only_for=("cuda", "xpu")`, `allow_xpu=True`, and `get_hw_classification` reads the attribute with `getattr`, so the generated XPU variants inherited the `CUDA` label: on an XPU host `--hw-classification ACCELERATOR XPU` would have dropped these tests, and because the test linter only checks the declaration on a device-specific class, the two `only_for` errors those classes report vanished with the label instead of with a fix. Both declarations go back to `ACCELERATOR`, matching the structure that landed through pytorch#198439/pytorch#198440. The consequence is that this file's entry in `tools/linter/adapters/test_linter_allowlist.json` has to stay until pytorch#204896 adds tuple labels, which is the only end state where `(CUDA, XPU)` can drop both the allowlist entry and the device restriction. What clears the errors honestly is the device injection, which is completed here rather than relabeled around: `_fast_launcher_cls`, `_stream` and `_store_sum_launcher` take an optional `device` defaulting to `GPU_TYPE`, and the `TestFastLauncher` tests pass their injected device at every helper call site, including the three `_make_launcher` calls that still fell back to the global. `test_build_fast_launcher_launches` now derives `device_props` from the injected device instead of `GPU_TYPE`, which is what `_build_fast_launcher` compares against `xpu`/`cuda`/`hip`. The defaults leave `TestFastLauncherXpuOnly`, which takes no device parameter, on exactly its old path. The fallback class docstring no longer claims "every accelerator". Test Plan Checked on a CPU-only host; the CUDA and XPU legs run on their CI shards. Simulated the linter over this file with its allowlist entry removed, by importing the in-tree adapter and clearing its allowlist set: ``` python3 -I - <<'EOF' import importlib.util, sys spec = importlib.util.spec_from_file_location( "test_linter", "tools/linter/adapters/test_linter.py") mod = importlib.util.module_from_spec(spec) sys.modules["test_linter"] = mod spec.loader.exec_module(mod) mod._allowlist = set() for m in mod.check_file("test/inductor/test_static_triton_launcher.py"): print(m.name, m.line) EOF ``` main reports 13 findings (8 `device_param`, 2 `only_for`, and 3 `hw_classification` in class regions owned by sibling PRs); this head reports 5 (the same 2 `only_for` plus those 3). The 8 `device_param` findings are gone because the methods take `device`, not because of any label. With the allowlist as it stands in CI today, the file is clean: ``` python3 tools/linter/adapters/test_linter.py -- test/inductor/test_static_triton_launcher.py ``` The RUFF and PYFMT adapters, run through `uv` the way `.lintrunner.toml` does and falsification-checked against planted violations first, report nothing on this file. ``` python3 -I -m py_compile test/inductor/test_static_triton_launcher.py python -m pytest --collect-only -q test_static_triton_launcher.py ``` The collection run used the nightly cpu-wheel venv (`env-pytorch-2.16-20261029-cpu`), from outside the source tree so the wheel `torch` is the one imported: 60 tests collected, no errors, and the collected set is identical to the ones from main and from the previous head. On a host with neither CUDA nor XPU, `instantiate_device_type_tests` generates no device-suffixed variants at all, so variant generation for `allow_xpu=True` is verified by the fact that the instantiate calls are untouched here and by the respective CI shards.
…align hw classifications Summary Follow-up to pytorch#198439/pytorch#198440 for the fast-launcher classes, in preparation for removing the file's test-linter allowlist entry: - the eight tests in TestFastLauncher that still picked their device from the GPU_TYPE global (float/scalar/ABI families) now take the injected device parameter used by their siblings; - TestFastLauncher and TestFastLauncherFallbackCompileResult are reclassified ACCELERATOR -> CUDA. Both classes only generate cuda and xpu variants (their instantiate calls, kept untouched, use only_for=("cuda","xpu")), and their extension selection requires _FastCudaLauncher/_FastXpuLauncher - a promise no PrivateUse1 backend has signed. The ACCELERATOR label overpromised, and the test linter accordingly forbids only_for on ACCELERATOR classes. Once pytorch#204896 lands the tuple labels, the honest end state is (CUDA, XPU) and this classification follows suit; - TestFastLauncherXpuOnly, the mixins and the CUDA-only compile class are unchanged. Test Plan - TEST_LINTER simulated with the file's allowlist entry removed: all ten errors owned by these two classes (eight device_param plus two only_for) clear; the remaining file errors belong to sibling PRs pytorch#198437/pytorch#198438/pytorch#198436; - cpu-wheel venv: skip/pass profile consistent with the pristine base (wheel-vs-trunk drift artifacts reproduce identically); CUDA/XPU legs run on the respective CI shards.
…r device injection Summary The automated review on pytorch#205277 flagged the `ACCELERATOR` -> `CUDA` relabel of `TestFastLauncher` and `TestFastLauncherFallbackCompileResult` as a blocking mislabel, and this commit agrees with it after checking the mechanism in the code. Both classes are still instantiated with `only_for=("cuda", "xpu")`, `allow_xpu=True`, and `get_hw_classification` reads the attribute with `getattr`, so the generated XPU variants inherited the `CUDA` label: on an XPU host `--hw-classification ACCELERATOR XPU` would have dropped these tests, and because the test linter only checks the declaration on a device-specific class, the two `only_for` errors those classes report vanished with the label instead of with a fix. Both declarations go back to `ACCELERATOR`, matching the structure that landed through pytorch#198439/pytorch#198440. The consequence is that this file's entry in `tools/linter/adapters/test_linter_allowlist.json` has to stay until pytorch#204896 adds tuple labels, which is the only end state where `(CUDA, XPU)` can drop both the allowlist entry and the device restriction. What clears the errors honestly is the device injection, which is completed here rather than relabeled around: `_fast_launcher_cls`, `_stream` and `_store_sum_launcher` take an optional `device` defaulting to `GPU_TYPE`, and the `TestFastLauncher` tests pass their injected device at every helper call site, including the three `_make_launcher` calls that still fell back to the global. `test_build_fast_launcher_launches` now derives `device_props` from the injected device instead of `GPU_TYPE`, which is what `_build_fast_launcher` compares against `xpu`/`cuda`/`hip`. The defaults leave `TestFastLauncherXpuOnly`, which takes no device parameter, on exactly its old path. The fallback class docstring no longer claims "every accelerator". Test Plan Checked on a CPU-only host; the CUDA and XPU legs run on their CI shards. Simulated the linter over this file with its allowlist entry removed, by importing the in-tree adapter and clearing its allowlist set: ``` python3 -I - <<'EOF' import importlib.util, sys spec = importlib.util.spec_from_file_location( "test_linter", "tools/linter/adapters/test_linter.py") mod = importlib.util.module_from_spec(spec) sys.modules["test_linter"] = mod spec.loader.exec_module(mod) mod._allowlist = set() for m in mod.check_file("test/inductor/test_static_triton_launcher.py"): print(m.name, m.line) EOF ``` main reports 13 findings (8 `device_param`, 2 `only_for`, and 3 `hw_classification` in class regions owned by sibling PRs); this head reports 5 (the same 2 `only_for` plus those 3). The 8 `device_param` findings are gone because the methods take `device`, not because of any label. With the allowlist as it stands in CI today, the file is clean: ``` python3 tools/linter/adapters/test_linter.py -- test/inductor/test_static_triton_launcher.py ``` The RUFF and PYFMT adapters, run through `uv` the way `.lintrunner.toml` does and falsification-checked against planted violations first, report nothing on this file. ``` python3 -I -m py_compile test/inductor/test_static_triton_launcher.py python -m pytest --collect-only -q test_static_triton_launcher.py ``` The collection run used the nightly cpu-wheel venv (`env-pytorch-2.16-20261029-cpu`), from outside the source tree so the wheel `torch` is the one imported: 60 tests collected, no errors, and the collected set is identical to the ones from main and from the previous head. On a host with neither CUDA nor XPU, `instantiate_device_type_tests` generates no device-suffixed variants at all, so variant generation for `allow_xpu=True` is verified by the fact that the instantiate calls are untouched here and by the respective CI shards.
…mixin helpers (#205277) ## Summary Follow-up to #198439/#198440 for the fast-launcher classes: the `TestFastLauncher` tests build their launcher, stream and C extension from the injected `device` instead of the `GPU_TYPE` global. An earlier version of this PR also relabeled `TestFastLauncher` and `TestFastLauncherFallbackCompileResult` from `ACCELERATOR` to `CUDA`. That relabel is reverted here: both classes are back at `ACCELERATOR`, which is what #198439/#198440 landed. Both classes generate cuda *and* xpu variants (`only_for=("cuda", "xpu")`, `allow_xpu=True`), and `get_hw_classification` reads the attribute with `getattr`, so a `CUDA` label is inherited by the generated XPU variants: on an XPU host `--hw-classification ACCELERATOR XPU` would drop these tests, and because the test linter checks nothing beyond the declaration on a device-specific class, the label hid the two `only_for` findings these classes produce instead of resolving them. `CUDA` is still where these classes belong long term: their extension selection needs `_FastCudaLauncher`/`_FastXpuLauncher`, a promise no PrivateUse1 backend has signed, so `ACCELERATOR` overpromises. The label that says both is the tuple `(CUDA, XPU)` from #204896, which is open and still under discussion. Until that lands, `ACCELERATOR` plus this file's entry in `tools/linter/adapters/test_linter_allowlist.json` is the correct interim state, and **the allowlist entry has to stay**: an `ACCELERATOR` class may not pass `only_for`, so removing the entry before #204896 would fail the lint on those two findings. Removing this file's entry is therefore a follow-up after #204896, not part of this PR, and this PR does not touch the allowlist. ## Changes One file, `test/inductor/test_static_triton_launcher.py`: 80 additions, 76 deletions against the base. No `hw_classification` line differs from the base after the revert, and the four `instantiate_device_type_tests` calls are untouched. - `_FastLauncherMixin._fast_launcher_cls`, `_stream` and `_store_sum_launcher` take an optional `device` that defaults to `GPU_TYPE`; `_make_fast_launcher` forwards it. `TestFastLauncherXpuOnly` passes no device, so it keeps its current behavior. - All 13 `TestFastLauncher` tests pass their injected device to the helpers they call, including the three `_make_launcher` calls that previously fell back to the global (`test_float_scalars`, `test_bfloat16_scalar`, `test_grid_2d`). `test_build_fast_launcher_launches` derives `device_props.type` from the injected device, which is the value `_build_fast_launcher` matches against `xpu`/`cuda`/`hip`. - The `TestFastLauncherFallbackCompileResult` docstring says the behavior is shared by the CUDA and XPU fast launchers rather than by "every accelerator", which is what the `ACCELERATOR` label claims. ## Motivation Part of #185590: tests should take their device from the instantiation machinery instead of a process-wide global, so the same class can be selected for more than one accelerator, and a hardware classification must describe the variants a class actually generates. ## Test Plan Checked on a CPU-only host; the CUDA and XPU legs run on the respective CI shards. Simulated the test linter over this file with its allowlist entry removed, by importing `tools/linter/adapters/test_linter.py` and clearing its `_allowlist` set (the allowlist file itself is unchanged in this PR): - base: 13 findings. 8 `device_param` and 2 `only_for` belong to these two classes; the other 3 are `hw_classification` findings on `TestStaticTritonLauncherUnit`, `TestStaticTritonLauncher` and `TestStaticTritonCompileResult`, in class regions this PR does not touch (owned by #198436/#198437, and for the compile-result class a declaration that has since landed on main). - the head before this round, with the `CUDA` labels: 3 findings, i.e. all 10 class-owned findings were gone, 8 of them from the device parameters and 2 from the label alone. - the current head, `ACCELERATOR` plus full injection: 5 findings, the 2 `only_for` ones that the allowlist suppresses until #204896 plus those same 3. So this PR clears 8 findings with the signatures, and the remaining 2 of its own are the ones only a tuple label can clear. With the allowlist as it stands in CI today, the file reports nothing, using the same command lintrunner runs: ``` python3 tools/linter/adapters/test_linter.py -- test/inductor/test_static_triton_launcher.py ``` The RUFF and PYFMT adapters, invoked through `uv` the way `.lintrunner.toml` does and checked against planted violations first to confirm they are not no-ops, report nothing on this file. ``` python3 -I -m py_compile test/inductor/test_static_triton_launcher.py python -m pytest --collect-only -q test_static_triton_launcher.py ``` The collection ran in the nightly cpu-wheel venv (`env-pytorch-2.16-20261029-cpu`), from outside the source tree so the wheel `torch` is the one imported: 60 tests collected, no errors, and the collected set is identical to the base and to the previous head. On a host with neither CUDA nor XPU, `instantiate_device_type_tests` generates no device-suffixed variants for these classes at all, so variant generation for `allow_xpu=True` rests on the untouched instantiate calls here and on the respective CI shards. ## Linked issue or supporting maintainer Part of #185590 (test case refactoring initiative) - hardware-decoupling slice. Pull Request resolved: #205277 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…mixin helpers (pytorch#205277) ## Summary Follow-up to pytorch#198439/pytorch#198440 for the fast-launcher classes: the `TestFastLauncher` tests build their launcher, stream and C extension from the injected `device` instead of the `GPU_TYPE` global. An earlier version of this PR also relabeled `TestFastLauncher` and `TestFastLauncherFallbackCompileResult` from `ACCELERATOR` to `CUDA`. That relabel is reverted here: both classes are back at `ACCELERATOR`, which is what pytorch#198439/pytorch#198440 landed. Both classes generate cuda *and* xpu variants (`only_for=("cuda", "xpu")`, `allow_xpu=True`), and `get_hw_classification` reads the attribute with `getattr`, so a `CUDA` label is inherited by the generated XPU variants: on an XPU host `--hw-classification ACCELERATOR XPU` would drop these tests, and because the test linter checks nothing beyond the declaration on a device-specific class, the label hid the two `only_for` findings these classes produce instead of resolving them. `CUDA` is still where these classes belong long term: their extension selection needs `_FastCudaLauncher`/`_FastXpuLauncher`, a promise no PrivateUse1 backend has signed, so `ACCELERATOR` overpromises. The label that says both is the tuple `(CUDA, XPU)` from pytorch#204896, which is open and still under discussion. Until that lands, `ACCELERATOR` plus this file's entry in `tools/linter/adapters/test_linter_allowlist.json` is the correct interim state, and **the allowlist entry has to stay**: an `ACCELERATOR` class may not pass `only_for`, so removing the entry before pytorch#204896 would fail the lint on those two findings. Removing this file's entry is therefore a follow-up after pytorch#204896, not part of this PR, and this PR does not touch the allowlist. ## Changes One file, `test/inductor/test_static_triton_launcher.py`: 80 additions, 76 deletions against the base. No `hw_classification` line differs from the base after the revert, and the four `instantiate_device_type_tests` calls are untouched. - `_FastLauncherMixin._fast_launcher_cls`, `_stream` and `_store_sum_launcher` take an optional `device` that defaults to `GPU_TYPE`; `_make_fast_launcher` forwards it. `TestFastLauncherXpuOnly` passes no device, so it keeps its current behavior. - All 13 `TestFastLauncher` tests pass their injected device to the helpers they call, including the three `_make_launcher` calls that previously fell back to the global (`test_float_scalars`, `test_bfloat16_scalar`, `test_grid_2d`). `test_build_fast_launcher_launches` derives `device_props.type` from the injected device, which is the value `_build_fast_launcher` matches against `xpu`/`cuda`/`hip`. - The `TestFastLauncherFallbackCompileResult` docstring says the behavior is shared by the CUDA and XPU fast launchers rather than by "every accelerator", which is what the `ACCELERATOR` label claims. ## Motivation Part of pytorch#185590: tests should take their device from the instantiation machinery instead of a process-wide global, so the same class can be selected for more than one accelerator, and a hardware classification must describe the variants a class actually generates. ## Test Plan Checked on a CPU-only host; the CUDA and XPU legs run on the respective CI shards. Simulated the test linter over this file with its allowlist entry removed, by importing `tools/linter/adapters/test_linter.py` and clearing its `_allowlist` set (the allowlist file itself is unchanged in this PR): - base: 13 findings. 8 `device_param` and 2 `only_for` belong to these two classes; the other 3 are `hw_classification` findings on `TestStaticTritonLauncherUnit`, `TestStaticTritonLauncher` and `TestStaticTritonCompileResult`, in class regions this PR does not touch (owned by pytorch#198436/pytorch#198437, and for the compile-result class a declaration that has since landed on main). - the head before this round, with the `CUDA` labels: 3 findings, i.e. all 10 class-owned findings were gone, 8 of them from the device parameters and 2 from the label alone. - the current head, `ACCELERATOR` plus full injection: 5 findings, the 2 `only_for` ones that the allowlist suppresses until pytorch#204896 plus those same 3. So this PR clears 8 findings with the signatures, and the remaining 2 of its own are the ones only a tuple label can clear. With the allowlist as it stands in CI today, the file reports nothing, using the same command lintrunner runs: ``` python3 tools/linter/adapters/test_linter.py -- test/inductor/test_static_triton_launcher.py ``` The RUFF and PYFMT adapters, invoked through `uv` the way `.lintrunner.toml` does and checked against planted violations first to confirm they are not no-ops, report nothing on this file. ``` python3 -I -m py_compile test/inductor/test_static_triton_launcher.py python -m pytest --collect-only -q test_static_triton_launcher.py ``` The collection ran in the nightly cpu-wheel venv (`env-pytorch-2.16-20261029-cpu`), from outside the source tree so the wheel `torch` is the one imported: 60 tests collected, no errors, and the collected set is identical to the base and to the previous head. On a host with neither CUDA nor XPU, `instantiate_device_type_tests` generates no device-suffixed variants for these classes at all, so variant generation for `allow_xpu=True` rests on the untouched instantiate calls here and on the respective CI shards. ## Linked issue or supporting maintainer Part of pytorch#185590 (test case refactoring initiative) - hardware-decoupling slice. Pull Request resolved: pytorch#205277 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…via instantiate_device_type_tests Summary Completes the device-agnostic migration of the CUDA-facing tests in TestStaticTritonLauncher on top of the post-pytorch#198439/pytorch#198440 reality: - the class becomes ACCELERATOR-classified and instantiated (except_for="cpu", allow_xpu=True); the class-level @requires_gpu_and_triton decorator is replaced by per-test Triton skips so the instantiated variants keep the same effective guard set; - float/scalar/ABI tests that were missing the injected device now take it (test_float_scalars, test_bfloat16_scalar, and both oversized-shared-memory tests), replacing GPU_TYPE in the bodies; - the six XPU-specific tests move to a dedicated XPU-classified TestStaticTritonLauncherXpuOnly instantiated with only_for="xpu", mirroring TestFastLauncherXpuOnly from pytorch#198439 - XPU capsule/ABI behavior is accelerator-specific and does not belong in an ACCELERATOR class; - the mixin helpers already gained device parameters via pytorch#198439/pytorch#198440, so this PR no longer touches them; the XPU-only tests pytorch#198439 added to the old class are preserved verbatim (in their new home). Test Plan - cpu-wheel venv (no accelerator here): collection and skip profile reviewed; remaining failures are wheel-vs-trunk drift artifacts reproduced identically on the pristine base file; - the XPU-specific split is covered by the CI xpu shards (only_for="xpu") - no local XPU hardware here; - lintrunner and the in-tree test linter clean for this class region with the allowlist entry for the file removed.
…via instantiate_device_type_tests (#198437) ## Current state (2026-12-02) - Head `879a6d25a2f3`, rebased onto main on Dec 1. One file changed: `test/inductor/test_static_triton_launcher.py`. - All 213 checks on the head are completed with nothing failing (208 success, 4 skipped, 1 neutral), and none waiting for approval. - All 16 review threads are resolved. Each carries a reply, and the two that still cited a pre-rebase head were re-verified against this head today with line numbers. - Labels: `topic: not user facing`, `ready for review`, `module: tests/graph`, `ciflow/inductor`, `ciflow/xpu`. - Waiting on one approving review from a member of the merge-rules approver lists. The two content approvals so far (lizhihai137 on Nov 2, KarhouTam on Dec 1) are from contributors outside those lists, so the merge bot still reports the PR as needing additional approval. ## Summary Launcher-migration slice of the static-launcher file (the original #192893 monolith has been re-cut into dependency-free, review-sized PRs per #198436's review request; this PR is +363/-324 in one file; the unit-class splits are in #203548 (Triton-gated autotuner), #203550 (RoCm scratch trio), #203551 (cubin metadata pair), each with its own correctly-scoped class; merge in any order). ## Changes (one file: test/inductor/test_static_triton_launcher.py) `TestStaticTritonLauncher` on main is a `@requires_gpu_and_triton` class with 24 test methods bound to `GPU_TYPE`. It is made device-agnostic via `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` with `hw_classification = HardwareClassification.ACCELERATOR`. All 24 tests are kept; where each one lives: - 13 general launcher tests stay in `TestStaticTritonLauncher` (ACCELERATOR). All 13 now take the injected `device` and pass it to `self._make_launcher(compiled_kernel, device)`, so the binary key (`cubin`/`zebin`/`npubin`/`hsaco`), the launcher class and the load interface resolve from the device under test instead of `GPU_TYPE`. `test_bfloat16_scalar` swaps its process-wide `@skipIfRocm` / `@unittest.skipIf(not HAS_XPU_AND_TRITON and not SM80OrLater, ...)` guards for the device-aware `@skipCUDAIfRocm` / `@skipCUDAIf(not SM80OrLater, ...)` from `common_device_type`. - The removed class-level `@requires_gpu_and_triton` is replaced by a `setUp` gate that is per-device rather than process-wide: `has_triton_for_device(self.device_type)` so a backend without Triton skips even when another backend has it, and `is_registered_static_launch_device(self.device_type)` (only cuda, hip and xpu register a static launcher) so Triton-capable but launcher-less backends skip instead of raising. - The 8 `test_xpu_*` tests move to a new `TestStaticTritonLauncherXpuOnly` (`hw_classification = XPU`, keeps the class-level `@requires_gpu_and_triton` and its per-test `@unittest.skipUnless(HAS_XPU_AND_TRITON, ...)` decorators), instantiated `only_for="xpu", allow_xpu=True`, mirroring `TestFastLauncherXpuOnly` from #198439. - The two oversized-shared-memory tests (`test_oversized_shared_mem`, `test_too_high_oversized_shared_mem`, both on main via #199309; their helper reads `torch.cuda.get_device_properties`) move to a new `TestStaticTritonLauncherCudaOversized` (`hw_classification = CUDA`), instantiated `only_for=("cuda",)` with a `setUp` skip for `self.device_type != "cuda"` (plus a runtime `has_triton_for_device` skip), the way `TestCudaStaticTritonCompileResult` is scoped. Their `@skipIfRocm` is kept; `@skipIfXpu` and the body-level `SkipTest` guards are dropped because the class is CUDA-only. - `test_launcher_keeps_module_owner_alive_until_release` moves into `TestStaticTritonLauncherUnit`, the host-side unit class, so the module-owner lifetime check runs once without a working Triton device. - The `instantiate_device_type_tests` calls for the three launcher classes sit in the file's single trailing group, the shape #198440 established. No helper or other class is touched: `StaticLauncherTestMixin` already takes optional `device` arguments on main (landed via #198439/#198440), and `TestFastLauncher` plus the compile-result classes keep their current scoping. ## Notes - No dependency on the sibling split PRs; the overlapping import lines collapse to one copy at rebase. - MTIA: the ACCELERATOR class is instantiated for accelerator device types with `except_for="cpu"`; no MTIA base is registered, so no MTIA variants are generated. This is a coverage note for #198436's open question, not a regression on currently-tested devices. ## Verification - [x] CPU wheel env (torch 2.16.0.dev20261029+cpu): `TestStaticTritonLauncherUnit` failure set identical to the pre-change head (28 tests; the two failures are preexisting wheel-vs-trunk artifacts already present before this PR's edits, 3 skips) ``` python test/inductor/test_static_triton_launcher.py TestStaticTritonLauncherUnit ``` - [x] `ast.parse` clean; ruff 0.14.4 with the repo config: `check` and `format --check` clean on the file; in-tree `test_linter` run with this file's allowlist entry temporarily removed: no findings in this PR's three launcher classes (the remaining file-level findings belong to the unit-class and fast-launcher regions tracked in #198436 and the fast-launcher follow-up) - [ ] `ciflow/xpu` label requested so this PR's CI actually exercises the XPU instantiations (the 13 ACCELERATOR tests on xpu and the 8-test XPU-only class); CUDA CI covers the cuda instantiations and the new CUDA-only class - No XPU, CUDA or NPU device is available in this environment, so the device-generic skips above are static-reasoning plus CI, not test-run evidence. ## Linked issue or supporting maintainer Part of #185590 (test case refactoring initiative), hardware-decoupling slice. Pull Request resolved: #198437 Approved by: https://github.com/lizhihai137, https://github.com/KarhouTam, https://github.com/jansel
Summary
Split
TestFastLauncherCompileResultinto a mixin, an accelerator class and a CUDA-only class.This is one of the per-test-class splits of the closed umbrella #192893 (refactoring
test/inductor/test_static_triton_launcher.pyfor out-of-tree accelerator support); eachpiece is an independent PR.
Changes
test/inductor/test_static_triton_launcher.py:_FastLauncherCompileMixinholding the sharedsetUp/tearDownconfig patch(
use_static_triton_launcher/strict_static_triton_launcher/use_fast_triton_launcher) and the_patch_build_fast_launcherhelper that records,for every
_build_fast_launchercall, whether a fast launcher was built.TestFastLauncherFallbackCompileResult(new,ACCELERATOR, instantiatedonly_for=("cuda", "xpu"),allow_xpu=True): the two device-agnostic end-to-endchecks.
test_basic_compileasserts that a fast launcher is built and the outputmatches eager (correctness plus
any(results)over the tracked build calls);test_disable_fast_launcherasserts that no fast launcher is built with the configoff. Nothing in these bodies is CUDA-specific: inductor builds a fast launcher on XPU
too (
_build_fast_launcherselects_FastXpuLauncherfor XPU devices intorch/_inductor/runtime/triton_heuristics.py), so this class keeps the cuda + xpucoverage the pre-split class had through
GPU_TYPE/@requires_gpu_and_triton.TestFastCudaLauncherCompileResultis the CUDA-only class (hw_classification = CUDA, instantiatedonly_for=("cuda",)), holding onlytest_device_tma_gemm_falls_back_from_fast_launcher: CUDA device-side TMAglobal-scratch kernels must fall back to the regular static launcher, so the test
asserts that
_build_fast_launcheris reached but that no fast launcher is built.Its pre-split
@skipIfXpuis superseded by the CUDA-only instantiation.GPU_TYPE/device="cuda"hardcodes in the threetests become the injected
deviceargument.Notes
instantiate_device_type_testsandHardwareClassificationimports), so it istestable standalone.
@requires_gpu_and_tritonclass gate intentionally stays on both concreteclasses; its skip condition covers CUDA, XPU and MTIA Triton devices
(
torch/testing/_internal/triton_utils.py).common_device_type.py, so these instantiationsgenerate no MTIA variants. A coverage note, not a regression on the cuda + xpu device
set this PR runs.
only_forscopes should widen to PrivateUse1 backends is a separatemaintainer decision requested from @jansel in a PR comment; this PR preserves the
device set the pre-split class ran on (cuda + xpu).
Motivation
The static Triton launcher tests were gated by
@requires_gpu_and_triton, which skipsunless a CUDA, XPU or MTIA Triton device is available, so a class gated only by it never
runs on out-of-tree accelerators registered via
PrivateUse1, and the pre-split testsallocated on the process-wide
GPU_TYPEinstead of an instantiated device. Migratingthe class to
instantiate_device_type_tests+hw_classificationmakes the testsdevice-agnostic and classifiable by
--hw-classificationfiltering.Test Plan
No torch build or lintrunner env was available on the machine that prepared the top
commit, so its local verification was static:
plus an AST check of the final class membership (
TestFastLauncherFallbackCompileResult:test_basic_compile+test_disable_fast_launcher;TestFastCudaLauncherCompileResult: the TMA test only) and line-length/ASCII checks onthe changed lines. The mixin's config patch is the same three keys the pre-split class
decorator had, so CUDA behavior is unchanged. CI coverage: this PR carries no
ciflow/xpulabel, so PR CI exercises the CUDA variants of both classes; theOnXPUvariants need a host with an XPU and Triton.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @FFrog