Repository navigation
[Testcase Refactoring] Keep XPU coverage and classify TestFastLauncher hw classes - #198439
gavinwang269 wants to merge 1 commit into
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:
Findings (6): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198439
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit d392424 with merge base 7d191ca ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/graph" |
5668908 to
6ade2c7
Compare
6ade2c7 to
3439246
Compare
3439246 to
f4c4cf1
Compare
|
@jansel could you approve and run the workflows here, and skim it if you have a minute? All five ( What it does, in one file (
One point I would rather hand to a reviewer than settle myself: For context on where this family stands: four device-decoupling PRs of ours landed this week (#192435, #198353, #196250, #198355). Four other open PRs touch this same file (#198440, #203548, #203551, plus #198437 which is a larger rewrite), so they will land one after another with trivial rebases in between; #198439 is self-contained — it adds the module scaffold it needs itself rather than depending on another PR landing first. |
…r hw classes (pytorch#198439) Follow-up to the automated review (5913183375) on the CUDA-only instantiation of TestFastLauncher. Both blocking findings are resolved with the combined option the review offered: the five test_xpu_* tests move to a new TestFastLauncherXpuOnly class (hw_classification XPU, instantiated with only_for="xpu" and allow_xpu=True, per-test skipUnless guards kept), so they run on XPU again and collect empty elsewhere, and the shared class gains hw_classification ACCELERATOR with only_for=("cuda", "xpu"), allow_xpu=True. only_for=("cuda", "xpu") was chosen over except_for="cpu" because the static launcher registry only has cuda/hip/xpu entries (torch/_inductor/runtime/static_triton_launcher.py), so an unfiltered instantiation 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. ACCELERATOR (not CUDA) is the honest label after the split because every remaining test is device-generic across cuda and xpu; a CUDA label would drop the class under --hw-classification XPU. The four fast-launcher helpers move into a private _FastLauncherMixin shared by both classes; StaticLauncherTestMixin (kept byte-identical with pytorch#198437) is untouched. Test Plan: - Syntax: ``` python -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())" ``` - CPU-only import probe (real import plus a recording stub over instantiate_device_type_tests) asserting both classes, their hw_classification values, test placement (5 xpu tests only in the XPU class), helper resolution, skip guards, the exact instantiate kwargs, and filter_by_hw_classification keep/drop behavior: 49 checks pass. - Collection, same CPU-only wheel (2.16.0.dev20261102+cpu): ``` cd /tmp && python -I -m pytest /gavin-ai/workspace/wt-198439/test/inductor/test_static_triton_launcher.py --collect-only -q ``` 58 tests collected, identical to the pre-fix head; no instantiated TestFastLauncher* variants on a CPU host, as intended. - Execution: ``` cd /tmp && python -I -m pytest /gavin-ai/workspace/wt-198439/test/inductor/test_static_triton_launcher.py -q ``` 22 passed, 34 skipped, 2 failed. The 2 failures are in TestStaticTritonLauncherUnit (untouched by this diff) and reproduce identically on the pre-fix head in the same environment (wheel-vs-trunk TritonBundler drift), so the change is CPU-neutral. - Lint with the CI-pinned toolchain: ``` 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 ``` All clean (the file is in the test_linter allowlist, like the only_for=("cuda", "xpu") + ACCELERATOR precedent files test_comparison_utils.py, test_gpu_trace.py, test/dynamo/test_after_aot.py). - No CUDA or XPU device on the verification host: the XPU side is verified at the collection level only; on-device CUDA/XPU runs are left to CI. Authored with an AI assistant; the change was reviewed against the diff by the author before pushing.
|
Responses to the non-blocking findings (no code churn in this slice beyond that, per review scope); drafted with an AI assistant and reviewed by me before posting.
|
|
@pytorchbot review |
|
cc @jansel Two asks below: (1) a favor on CI, (2) a skim if you have a few minutes. I also What this is One review-sized slice of the Shape and size
The CI favor Right now 0 of the CI checks have actually run. The four checks on the fork The two open threads The two unresolved review threads are the ones where our replies are the last
One thing to flag so the link is not misleading: both replies pointed at commit The skim If you have a few minutes, I would value a quick read of this one class. On a Thanks! |
|
@pytorchbot merge |
|
Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra. |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…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
Make
TestFastLauncherintest/inductor/test_static_triton_launcher.pyhardware-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
TestFastCudaLaunchertoTestFastLauncherand moved the shared helpers intoStaticLauncherTestMixin.Changes
TestFastLauncherdeclareshw_classification = HardwareClassification.ACCELERATORand is instantiated withonly_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 injecteddeviceargument; the remaining tests resolveGPU_TYPE, which equals the running device on the CUDA and XPU single-device-type CI runners.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 newTestFastLauncherXpuOnlyclass:hw_classification = HardwareClassification.XPU, instantiated withonly_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)._fast_launcher_cls,_make_fast_launcher,_stream,_store_sum_launcher) move into a file-private_FastLauncherMixinshared by the two classes.StaticLauncherTestMixinis unchanged; its_make_launcher/write_cubin_to_tmpdevice-optional form stays byte-identical with the sibling [Testcase Refactoring] Make TestStaticTritonLauncher device-agnostic via instantiate_device_type_tests #198437 so whichever lands first supplies them.Why
only_for=("cuda", "xpu")instead ofexcept_for="cpu": the static launcher registry (torch/_inductor/runtime/static_triton_launcher.py) only hascuda/hip/xpuentries, soexcept_for="cpu"would generate MPS/PrivateUse1 variants that hard-error in_make_launcherinstead of skipping;cuda+xpuis exactly the device set the pre-seriesGPU_TYPEgating covered.Notes
TestFastLauncher.test_xbecomesTestFastLauncherCUDA.test_x_cuda(and aTestFastLauncherXPU...._xpuvariant on XPU runners); the XPU-specific tests becomeTestFastLauncherXpuOnlyXPU.test_xpu_*_xputhere. No in-tree DISABLED/slow-test entries reference the old names (greppedtest/,.ci/,tools/).write_cubin_to_tmphelper in this diff gains annpubinbinary key alongsidezebin/cubin/hsacofor the out-of-tree NPU backends that motivate this series; having the backend supply its binary key viaregister_statically_launched_kernelis a plausible follow-up.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 viaPrivateUse1never run them. Migrating each class toinstantiate_device_type_tests+hw_classificationmakes the tests device-agnostic and classifiable by--hw-classificationfiltering. This PR makes that true forTestFastLauncherwithout dropping its existing XPU coverage.Test Plan
CPU-only host (torch
2.16.0.dev20261102+cpuwheel; no CUDA or XPU device available):TestFastLauncher*variants on a CPU-only host, as designed.TestStaticTritonLauncherUnit(the CPU wheel carries no_FastXpuLauncherextension, 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.instantiate_device_type_testsasserts both generic classes, theirhw_classificationvalues, the exact test placement (the 5test_xpu_*tests only inTestFastLauncherXpuOnly), helper resolution through_FastLauncherMixin, the retained skip guards, and the instantiate kwargs;filter_by_hw_classificationis exercised directly ({ACCELERATOR}keeps the shared class,{XPU}keepsTestFastLauncherXpuOnly).test_linter.pyreports 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
TestFastLauncherCompileResultclass (untouched here) and gathered the file'sinstantiate_device_type_testscalls 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 (headd3924245614); diff +61/-33 -> +57/-33; no scope change.