Skip to content

[Testcase Refactoring] Make TestStaticTritonLauncher device-agnostic via instantiate_device_type_tests - #198437

Closed
gavinwang269 wants to merge 7 commits into
pytorch:mainfrom
gavinwang269:stl/p-launcher
Closed

gavinwang269 wants to merge 7 commits into
pytorch:mainfrom
gavinwang269:stl/p-launcher

Conversation

@gavinwang269

@gavinwang269 gavinwang269 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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 [Testcase Refactoring] Keep XPU coverage and classify TestFastLauncher hw classes #198439.
  • The two oversized-shared-memory tests (test_oversized_shared_mem, test_too_high_oversized_shared_mem, both on main via [Inductor] Support oversized shared memory in the static CUDA launcher and AOTI #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 [Testcase Refactoring] Split TestFastLauncherCompileResult into mixin, accelerator and CUDA-only classes #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

Verification

  • 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
  • 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 [Testcase Refactoring] Declare TestStaticTritonLauncherUnit as a GENERIC hardware-classification class #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.

@pytorch-bot

pytorch-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:

The PR makes TestStaticTritonLauncher device-generic (an ACCELERATOR class
instantiated with except_for="cpu", allow_xpu=True) and redistributes its 24
tests with none lost; the prior blocking finding and all maintainer requests are
addressed. Recommendation: Approve  only a non-blocking docstring wording point
remains.

Findings (1):

[minor] test/inductor/test_static_triton_launcher.py:773
Non-blocking: the `test_basic` docstring is wrong (predates this PR). It says
the test "wraps it in `_FastCudaLauncher`, then invokes via vectorcall", but
`_make_launcher(compiled_kernel, device)` returns a
`StaticallyLaunchedCudaKernel`/`StaticallyLaunchedXpuKernel`, and `launcher.run`
dispatches through `C_impl._launch_kernel`, i.e.
`_StaticCudaLauncher`/`_StaticXpuLauncher`
(`torch/_inductor/runtime/static_triton_launcher.py:470-547`); it never goes
through `_FastCudaLauncher`. Since the method is already being edited and the
class now runs on XPU too, consider rewording it to describe the device-generic
static launcher.

Reviewed commit: afb2f42 (NOT the current head 879a6d2)

Review run

🐛 Report a bad review

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198437

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 879a6d2 with merge base 0f719e8 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot

pytorch-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@gavinwang269

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "module: tests/graph"

@gavinwang269
gavinwang269 force-pushed the stl/p-launcher branch 2 times, most recently from 3299800 to 77f9e7a Compare November 5, 2026 06:53
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 5, 2026
… into its own CUDA-classified class

First independent slice of the static-launcher split (per pytorch#198436 review: the
unit class mixes device-gated tests with a GENERIC label; original monolith
pytorch#198437 at 505 lines). Moves test_tensor_memory_autotuner_retries_without_pipelining
(CUDAAutotuner + StaticallyLaunchedCudaKernel internals, Triton-gated and RoCm-
skipped) into a new CUDA-classified class TestStaticTritonLauncherUnitCuda -- not
instantiated, since running CUDA-internal mock behavior under XPU/PrivateUse1
class variants would produce meaningless duplicates (the shape flagged in
pytorch#198359/pytorch#198360 review). Shared helpers stay on the unit class, delegated by
reference (staticmethod-wrapped); nothing is copied.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 6, 2026
… into its own CUDA-classified class

First independent slice of the static-launcher split (per pytorch#198436 review: the
unit class mixes device-gated tests with a GENERIC label; original monolith
pytorch#198437 at 505 lines). Moves test_tensor_memory_autotuner_retries_without_pipelining
(CUDAAutotuner + StaticallyLaunchedCudaKernel internals, Triton-gated and RoCm-
skipped) into a new CUDA-classified class TestStaticTritonLauncherUnitCuda -- not
instantiated, since running CUDA-internal mock behavior under XPU/PrivateUse1
class variants would produce meaningless duplicates (the shape flagged in
pytorch#198359/pytorch#198360 review). Shared helpers stay on the unit class, delegated by
reference (staticmethod-wrapped); nothing is copied.
@gavinwang269
gavinwang269 force-pushed the stl/p-launcher branch 2 times, most recently from 8dda50b to b5da55e Compare November 12, 2026 07:54
@gavinwang269
gavinwang269 marked this pull request as ready for review November 13, 2026 00:16
@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @aorenste, could you give this an approving review? It needs one approval from someone in the merge-rules approver lists; the two content approvals so far (lizhihai137 Nov 2, KarhouTam Dec 1) are from contributors outside those lists, so the bot still reports it as needing additional approval.

This is the launcher slice of the static-launcher testcase family. It makes TestStaticTritonLauncher device-agnostic: the CUDA-only and XPU-only groups move into classes gated on runtime capabilities instead of device-name decorators, so an out-of-tree backend can run the same checks. One file, test/inductor/test_static_triton_launcher.py, +368/-327, no source changes.

State on the current head 879a6d2, rebased onto main on Dec 1: every check on it has completed with nothing failing (209 checks, 206 green, 2 skipped, 1 neutral), and the label set is complete (topic: not user facing, ready for review). Sibling slices are #203550 and #203551, #198436 stays a draft until the family lands. If test refactors in inductor are not your area, a pointer to the right reviewer works too. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

@pytorchbot triage

@pytorch-bot pytorch-bot Bot added bot-retriage Re-run Auto PR Triage and removed triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Dec 2, 2026
@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @lezcano - this one is squarely in torch.testing territory so one more ping: TestStaticTritonLauncher becomes device-agnostic via common_utils gating, one test file, no source changes. CI green on the same head since Nov 25, all threads resolved. It is the tail of the static-launcher split family (#203548 landed). Approvals so far on this PR came from contributors outside the merge-rules lists, so one approving review from the Core or Testing list lands it. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @jansel - you approved the split family predecessor (#203548). This is the sibling testcase slice: TestStaticTritonLauncher becomes device-agnostic via common_utils gating, one test file, no source changes. CI green on the current head since Nov 25, all threads resolved, and the earlier approvals on it (KarhouTam, lizhihai137) are unfortunately outside the merge-rules lists for this path, so one approve from you lands it. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @soulitzer - could you approve if the approach looks right? TestStaticTritonLauncher becomes device-agnostic (one test file, no source changes) so out-of-tree backends exercise the static launcher path instead of skipping it. CI green on the same head since Nov 25, threads resolved. It is the tail of the static-launcher split family (#203548 landed). One merge-rules approve lands it. Thanks!

pytorchmergebot pushed a commit that referenced this pull request Dec 2, 2026
… a device-generic class (#203551)

## Summary

Slice 3 of 4 of the static-launcher re-cut (independent; any order; original monolith #198437).

The two ROCm-gated cubin metadata-group tests move out of `TestStaticTritonLauncherUnit` into `TestStaticTritonLauncherUnitMetadataGroup`, classified `HardwareClassification.GENERIC`. Both fake the compiled kernel (SimpleNamespace plus temp files), pass `device_type` to `can_statically_launch` as data (it selects the binary extension from `GPU_KERNEL_BIN_EXTS`), and `reload_cubin_path` with `device=0` initializes no device, so they run and pass on a CPU-only wheel and fit the Generic profile in test/REVIEW.md. The class is not instantiated. The two tests already sat at the end of the unit class, so the diff against main is 13 added lines of class scaffolding with no deletions; `_can_statically_launch` stays on the unit class, delegated by reference: hoisting it to a module-level helper or mixin would edit the unit class region owned by the sibling slice, so that refactor is left to a family-wide cleanup.

## Test Plan

- [x] CPU wheel (torch 2.16.0.dev20261029+cpu, triton not installed), both tests run and pass:
  ```
  python test/inductor/test_static_triton_launcher.py TestStaticTritonLauncherUnitMetadataGroup -v
  ```
- [x] In-tree test linter: this file is listed in `tools/linter/adapters/test_linter_allowlist.json`, so the regular lintrunner path checks nothing for it. Re-running `tools/linter/adapters/test_linter.py` over the file with the allowlist entry removed in memory reports 0 findings in the new class region; the 13 remaining findings in the file live in class regions owned by the sibling slices.

## Linked issue or supporting maintainer

Part of #185590 (test case refactoring initiative) - hardware-decoupling slice.

Pull Request resolved: #203551
Approved by: https://github.com/lizhihai137, https://github.com/jansel
@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @jansel - thanks again for landing #203551 minutes ago. The sibling testcase slice is this one: TestStaticTritonLauncher becomes device-agnostic via common_utils gating, one test file, no source changes. CI green on the same head since Nov 25, all threads resolved. Same family, same pattern you already approved (predecessors 198438/198439/198440/203548). One approve here and merge takes it the same way. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @anijain2305 - you already have the sibling context from #206704; this is the tail of the static-launcher testcase split: TestStaticTritonLauncher becomes device-agnostic via common_utils gating, one test file, no source changes. CI green on the same head since Nov 25, all threads resolved. One merge-rules approve lands it (#203551 and #206703 in the same family merged this way). Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @bdhirsh - new face here so one line of context: this makes TestStaticTritonLauncher device-agnostic (one test file, no source changes) so out-of-tree backends exercise the static launcher path instead of a CUDA-only class gate. It is the tail of a split family already landed by you-adjacent reviewers (#203548, #203551, #206703). CI green on the same head since Nov 25, threads resolved. One merge-rules approve lands it. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @eqy - you're mid-window so a short ping: this is the remaining testcase tail of the static-launcher split (the sibling #203551 with the same file merged yesterday). One test file, no source changes: TestStaticTritonLauncher becomes device-agnostic via common_utils gating. CI 208/208 green on the same head since Nov 25, all threads resolved. An approving review lands it the same way as #203551. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @ezyang - flagging the tail of the static-launcher testcase split before your noon window: TestStaticTritonLauncher becomes device-agnostic (one test file, no source changes) so out-of-tree backends get the launcher coverage. The family is landing one by one (#203548, #206703, #203551 merged), this is the last standing slice with CI 208/208 green since Nov 25 and all threads resolved. One merge-rules approve closes it. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

Hi @jbschlosser - this one lives in common_utils device-gating territory which you own: TestStaticTritonLauncher becomes device-agnostic via common_utils gating (one test file, no source changes) so out-of-tree backends run the launcher tests instead of skipping them. Sibling slices already landed (#203548, #203551, #206703). CI 208/208 green on the same head since Nov 25, threads resolved. One approving review from the Core list lands the family tail. Thanks!

@gavinwang269

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 3, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@gavinwang269

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

1 similar comment
@gavinwang269

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@github-project-automation github-project-automation Bot moved this from Backlog to Done in PyTorch Test Refactoring Dec 3, 2026
pytorchmergebot pushed a commit that referenced this pull request Dec 3, 2026
…ified class (#203550)

## Summary

Slice 2 of 4 of the static-launcher re-cut (independent; any order; original monolith #198437).

Moves three scratch-space tests out of `TestStaticTritonLauncherUnit` into the existing CUDA-classified class `TestStaticTritonLauncherUnitCuda`, established by #203548: `test_global_scratch_allocation`, `test_fast_launcher_rejects_global_scratch` (both `@skipIfRocm`) and `test_rocm_rejects_global_scratch` (ROCm-only). No new class: the three bodies move verbatim, and the scratch-kernel factory is delegated by reference, never copied. The class docstring, inherited stale from main, is corrected in this PR: it claimed the class cannot run on RoCm and named a `CUDAAutotuner` that does not exist; it now describes the class as covering the CUDA/ROCm paths of `CachingAutotuner` and `StaticallyLaunchedCudaKernel`, noting that `CachingAutotuner` itself is device-generic.

(+50/-55, one file; relocation of the three test bodies plus the docstring fix)

## What classifies `TestStaticTritonLauncherUnit`

This slice does not declare `hw_classification` on the source class. The unit class still holds the last two device-gated tests, `test_static_launch_takes_cubin_from_metadata_group` and `test_static_launch_rejects_ambiguous_metadata_group` (`@skipIfRocm`); slice 3 (#203551) moves those into `TestStaticTritonLauncherUnitMetadataGroup` (GENERIC). Once that lands no device-gated test remains in the unit class, and its GENERIC declaration is the final slice of this re-cut, which is not opened yet. REVIEW.md Scenario 1 permits the multi-PR split; this section is the split explanation the rule asks for.

## Test Plan

- [x] cpu wheel venv (previous head): failure set identical to base; the two commits added after it each change only the class docstring (AST-verified), no behavioral diff
- [x] ROCm run: green. Run 46792320695 (<https://github.com/pytorch/pytorch/actions/runs/46792320695>), triggered by head `f72c3ea88139`: build plus all 8 `default` shards pass on `linux-noble-rocm-py3.11-mi300`; `test_rocm_rejects_global_scratch` ran on shard 1/8 and passed, per the shard's junit report (56 tests, 0 skipped, 0 failed). The current head `daeb4dafbdf3` only rewords the class docstring, no behavioral change. The `ciflow/rocm-mi300` label made `test_rocm_rejects_global_scratch` actually execute. It runs because `rocm-mi300.yml` runs the `default` config, which discovers this file (it is in neither the job's `tests-to-exclude` nor the `ROCM_BLOCKLIST` in `test/run_test.py`), and ROCm jobs exclude `GENERIC` classes only, so the CUDA-classified class runs. The earlier review round suggested `ciflow/inductor-rocm-mi300` instead; that workflow runs the `inductor` config, whose `test_inductor_shard` in `.ci/pytorch/test.sh` never includes `test_static_triton_launcher`.
- [ ] in-tree test linter: not a meaningful check for this file yet. It is listed in `tools/linter/adapters/test_linter_allowlist.json`, and `check_file` in `tools/linter/adapters/test_linter.py` returns early for allowlisted paths, so the regular lintrunner path verifies nothing here. The file leaves the allowlist when the family-wide classification completes.

## Linked issue or supporting maintainer

Part of #185590 (test case refactoring initiative) - hardware-decoupling slice.

Pull Request resolved: #203550
Approved by: https://github.com/lizhihai137, https://github.com/jansel

This branch was previously deployed

1 inactive deployment
bedrock — 879a6d25 Deployed Dec 2, 2026 by pytorch-bot[bot] via analyze #47209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-retriage Re-run Auto PR Triage ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks Merged module: inductor module: tests/graph This label covers all test cases within the Graph sheet. open source ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category

Projects

Status: No status
Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants