Skip to content

[Testcase Refactoring] Make TestStaticTritonCompileResult device-agnostic via instantiate_device_type_tests - #198438

Closed
gavinwang269 wants to merge 1 commit into
pytorch:mainfrom
gavinwang269:stl/p-compile-result
Closed

gavinwang269 wants to merge 1 commit into
pytorch:mainfrom
gavinwang269:stl/p-compile-result

Conversation

@gavinwang269

@gavinwang269 gavinwang269 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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 [Testcase Refactoring] Split TestFastLauncherCompileResult into mixin, accelerator and CUDA-only classes #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 [Testcase Refactoring] Make test_bisect_pre_grad_graph device-agnostic via instantiate_device_type_tests #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
    [Testcase Refactoring] Split TestFastLauncherCompileResult into mixin, accelerator and CUDA-only classes #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.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @FFrog

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.

@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 moves TestStaticTritonCompileResult to instantiate_device_type_tests with
ACCELERATOR classification and splits the two CUDA-only tests into a new
TestCudaStaticTritonCompileResult class, with a shared setUp-gating mixin.
Recommendation: Approve. The earlier blocking finding is fixed, and the only
remaining point (a stale PR description) is non-blocking.

Findings (1):

[minor] test/inductor/test_static_triton_launcher.py:1394
Non-blocking: the PR description (which becomes the commit message) no longer
matches HEAD. Please update it: (1) Triton gate is now one
has_triton_for_device(self.device_type) check in
_StaticTritonCompileResultMixin.setUp plus an is_registered_static_launch_device
skip exempting test_disable_static_triton_launcher, not per-test skipIf(not
has_triton()). (2) Config patch uses self.enterContext(...), with no tearDown.
(3) Only 7 tests remain in the ACCELERATOR class; the new
TestCudaStaticTritonCompileResult and its two tests are not mentioned. (4) The @​
skipIfXpu to @​ skipXPUIf(True, ...) change on
test_custom_op_bad_fake_dtype_fails_fast is not mentioned. (5) Rebase note's
in-test CUDA SkipTest guard, head SHA, +53/-29 diffstat and 'no other scope
change' are stale. (6) Imports: it adds has_triton_for_device,
is_registered_static_launch_device, skipXPUIf, not has_triton. (7) The
class-decorator rationale is wrong: ContextDecorator.__call__ returns a TestCase
subclass; the real issue is instantiate_device_type_tests reads test_* from the
class's own __dict__, which is empty on the wrapper. (8) Test Plan's NPU '21/24'
is from # 192893; at HEAD a PrivateUse1 variant skips all but
test_disable_static_triton_launcher unless it registers a launcher.

Reviewed commit: 1ff6807 (NOT the current head eac52d7)

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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

✅ No Failures

As of commit eac52d7 with merge base d29e9dd (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

Copy link
Copy Markdown
Contributor Author

Rebased onto current main after #198440 landed (5ad9c39, one commit). The only conflict was the trailing instantiate_device_type_tests group that #198440 introduced; this PR's instantiation(s) now join that group and the previously-added import lines dedup against main. Scope is unchanged This rebase additionally converts test_oversized_shared_mem_mm_template (added on main since the branch cut) to the class's per-device form; rationale in the Rebase note below. - details and the diffstat delta are recorded in the PR body and the commit message.

All CI workflows on the new head (Lint, BC Lint, docs-build, pull) are sitting at action_required, so nothing has run yet - could someone with write access approve the runs?

@gavinwang269
gavinwang269 marked this pull request as ready for review November 16, 2026 09:23
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot missing actionable issue A PR without a linked actionable issue or maintainer sponsor triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 16, 2026
@gavinwang269

Copy link
Copy Markdown
Contributor Author

cc @jansel

Two asks below: (1) a favor on CI, (2) a skim if you have a few minutes.

What this is

One review-sized slice of the test/inductor/test_static_triton_launcher.py
refactor that we split out of umbrella #192893 (now closed): the rule for that
split was "one test class per PR, zero overlap", which is exactly what this PR
follows. It converts a single class, TestStaticTritonCompileResult, from the
@requires_gpu_and_triton / GPU_TYPE style to instantiate_device_type_tests,
and it only touches that test file. The rest of the series (#198436, #198437,
#198439, #198440) are same-batch siblings of that split, each converting a
different class; I am naming them only to place this PR in the batch, not as
prerequisites or as an "already implemented here" reference.

Shape and size

  • Diff vs main: 1 file (test/inductor/test_static_triton_launcher.py),
    +53/-29, single commit, on top of main at 7d191ca.
  • Test-side only: no production module changes.
  • Form: TestStaticTritonCompileResult is decorated with
    hw_classification = HardwareClassification.ACCELERATOR and instantiated with
    instantiate_device_type_tests(TestStaticTritonCompileResult, globals(), except_for="cpu", allow_xpu=True).
    Inside the class the per-test GPU_TYPE uses become the injected device
    argument, and the config that used to sit on the decorator moves into a
    setUp/tearDown lifecycle.
  • One method that main added to this class after our branch was cut,
    test_oversized_shared_mem_mm_template, was also converted to the same
    per-device form; its CUDA-specific helper path stays behind a CUDA-only
    SkipTest guard so it behaves correctly under the new non-CPU instantiation.

The CI favor

Right now 0 of the CI checks have actually run. The four checks on the fork
(BC Lint, Lint, docs-build, and pull) are parked at action_required,
which means they are waiting for someone with write access to approve running
workflows from this fork. As an outside contributor I do not have that
permission and cannot start them myself. Could you approve the run so the fork
workflows can execute? Until then the merge box is blocked only on those unrun
checks, not on any result.

The skim

If you have a few minutes, I would value a quick read of this one class. It is
small and self-contained by design, and it is part of making these launcher
tests device-agnostic and hardware-classifiable so out-of-tree accelerators can
run them without monkey-patches. On a CPU-only host this file collects cleanly
(69 tests, rc=0) with no device-variant leakage, and the recorded full CPU run on
the identical file is 22 passed / 45 skipped / 2 failed, the 2 failures being
pre-existing on main (CPU-wheel TritonBundler/_FastXpuLauncher gaps, unrelated to
this PR). CUDA/XPU/NPU execution of the instantiated variants cannot be judged on
this host, so it is left to the CI you would be approving.

Thanks!

@jansel jansel added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 16, 2026
github-actions[bot]

This comment was marked as outdated.

gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 16, 2026
…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]>
@gavinwang269

Copy link
Copy Markdown
Contributor Author

@pytorchbot review

@pytorch-bot pytorch-bot Bot added in progress PR is being worked on by the author, until the automated review accepts it and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 16, 2026
github-actions[bot]

This comment was marked as outdated.

…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.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 17, 2026
…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.
@gavinwang269

Copy link
Copy Markdown
Contributor Author

cc @jansel - the CompileResult companion of the classes you approved in #198439/#198440: TestStaticTritonCompileResult becomes ACCELERATOR-classified and instantiated (except_for cpu, allow_xpu), all nine tests already take the injected device, Triton gating moved to per-device skipIf. +128/-77, one file, rebased onto current main. Ready for your review and merge.

gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 18, 2026
…t in static launcher tests

Summary

Follow-up fixups on the rebased head of this PR; restores content this
PR's own description says is present but the current pushed head lacks:

- the rebase conflict resolution dropped the module-level
  `from pathlib import Path` import while `Path(compile_path)` is still
  used in test_make_launcher_reuses_loaded_kernel_after_cache_context
  (latent NameError);
- the two oversized-shared-memory tests lost their per-device
  conversion (injected device argument, CUDA-only SkipTest guard ahead
  of the shared helper's torch.cuda.current_device(), per-test Triton
  gate);
- TestStaticTritonLauncherXpuOnly did not inherit
  StaticLauncherTestMixin although its tests call self._make_launcher
  and self.write_cubin_to_tmp (AttributeError on the XPU shard);
- two XPU-specific tests, test_xpu_non_default_warp_size and
  test_xpu_launch_rejects_non_kernel_capsule, were deleted instead of
  moved when the XPU-only tests split into that class; they are
  restored verbatim, so the class holds all eight XPU-specific tests
  of the old launcher class.

Test Plan

- python -m py_compile on the patched file;
- in-tree test linter (tools/linter/adapters/test_linter.py) with the
  file's allowlist entry removed: zero errors in this PR's class
  regions; the remaining 12 file errors belong to pytorch#198436 (Unit
  declaration), pytorch#198438 (CompileResult) and pytorch#205277 (fast launcher),
  identical to the pre-fixup attribution;
- cpu wheel (torch-2.16.0.dev20261102+cpu) venv run of the patched
  file: failure set byte-identical to the unpatched pushed head (10
  known wheel-vs-trunk drift artifacts), i.e. no regression;
- the eight XpuOnly tests execute on the CI XPU shards only
  (only_for="xpu"); no local XPU hardware here.
@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 Nov 18, 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

@github-project-automation github-project-automation Bot moved this from Backlog to Done in PyTorch Test Refactoring Nov 18, 2026
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 18, 2026
…t in static launcher tests

Summary

Follow-up fixups on the rebased head of this PR; restores content this
PR's own description says is present but the current pushed head lacks:

- the rebase conflict resolution dropped the module-level
  `from pathlib import Path` import while `Path(compile_path)` is still
  used in test_make_launcher_reuses_loaded_kernel_after_cache_context
  (latent NameError);
- the two oversized-shared-memory tests lost their per-device
  conversion (injected device argument, CUDA-only SkipTest guard ahead
  of the shared helper's torch.cuda.current_device(), per-test Triton
  gate);
- TestStaticTritonLauncherXpuOnly did not inherit
  StaticLauncherTestMixin although its tests call self._make_launcher
  and self.write_cubin_to_tmp (AttributeError on the XPU shard);
- two XPU-specific tests, test_xpu_non_default_warp_size and
  test_xpu_launch_rejects_non_kernel_capsule, were deleted instead of
  moved when the XPU-only tests split into that class; they are
  restored verbatim, so the class holds all eight XPU-specific tests
  of the old launcher class.

Test Plan

- python -m py_compile on the patched file;
- in-tree test linter (tools/linter/adapters/test_linter.py) with the
  file's allowlist entry removed: zero errors in this PR's class
  regions; the remaining 12 file errors belong to pytorch#198436 (Unit
  declaration), pytorch#198438 (CompileResult) and pytorch#205277 (fast launcher),
  identical to the pre-fixup attribution;
- cpu wheel (torch-2.16.0.dev20261102+cpu) venv run of the patched
  file: failure set byte-identical to the unpatched pushed head (10
  known wheel-vs-trunk drift artifacts), i.e. no regression;
- the eight XpuOnly tests execute on the CI XPU shards only
  (only_for="xpu"); no local XPU hardware here.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 18, 2026
…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.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 20, 2026
… Triton device

Summary

Review feedback: test_launcher_keeps_module_owner_alive_until_release
builds fake kernel-owner and launcher objects, never touches the device
argument it receives, and only checks weakref/gc lifetime behavior, yet
it lived in TestStaticTritonLauncher, whose except_for="cpu"
instantiation and per-test Triton skip mean the ownership check cannot
run on a CPU-only shard.

Upstream has no host launcher test file yet, so move the test as-is
into TestStaticTritonLauncherUnit in the same file, the device-agnostic
unit class that already hosts the adjacent fake-owner lifetime checks,
and drop the unused device parameter and the Triton gate. The test body
is otherwise byte-identical.

Test Plan

- python -m py_compile on the patched file;
- in-tree test linter (tools/linter/adapters/test_linter.py) with the
  file's allowlist entry removed: 11 findings on the patched file,
  identical to the previous head (all pre-existing, attributed to
  pytorch#198436 Unit hw_classification declaration, pytorch#198438 and pytorch#205277),
  i.e. zero new violations from this move;
- AST scan: single definition of the moved test, no undefined names, no
  doubled decorators; gc/weakref/has_triton imports remain referenced
  elsewhere in the file;
- no built torch in this environment, so the moved test was not
  executed locally; as a device-less unit test it now runs in CI on CPU
  shards.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Nov 20, 2026
… XPU-only launcher class

Summary

Two inline review items at bef2f7b:

TestStaticTritonLauncher gates its compile-on-device launcher cases with a
process-wide has_triton() skipIf, but the class is instantiated for multiple
backends, so a backend without Triton would still run these cases whenever
any other accelerator has Triton. Replace the thirteen per-test decorators
with one per-device gate in setUp using has_triton_for_device, the same
convention _StaticTritonCompileResultMixin already uses in this file; the
two compiling cases that carried no Triton gate (test_float_scalars,
test_bfloat16_scalar) are covered as a side effect, and skipping ahead of
super() keeps the mixin's XPU JITFunction patch from being applied.

The instantiate_device_type_tests call for TestStaticTritonLauncherXpuOnly
passed only_for="xpu" without allow_xpu, so no XPU class was ever emitted:
XPUTestBase joins the candidate bases only under allow_xpu=True, and the
filter then removed everything else. Pass allow_xpu=True, matching the
file's five other instantiations, so the restored XPU-only launcher tests
collect on XPU shards.

Test Plan

- python -m py_compile and ast.parse on the patched file.
- CPU wheel venv (torch 2.16.0.dev20261029+cpu, torch_npu installed so
  PrivateUse1=npu instantiates): module collection is 50 tests with no
  loader errors, unchanged from the pre-change head; the instantiated
  TestStaticTritonLauncherNPU test now skips via the new gate ("requires
  Triton on npu"); the device-free TestStaticTritonLauncherUnit result set
  is identical to the pre-change head (28 run, 23 pass, 3 skip, 2 known
  wheel-vs-trunk drift failures).
- allow_xpu verified against the helper with XPU availability simulated:
  get_desired_device_type_test_bases(only_for="xpu") returns no bases
  without allow_xpu and the xpu base with it; instantiating a dummy
  template with the new kwargs emits its XPU class while the old kwargs
  emit none. This host has no XPU hardware, so real XPU collection runs
  on the CI XPU shards.
- in-tree test linter (tools/linter/adapters/test_linter.py) with the
  file's allowlist entry removed: 11 findings on the patched file,
  identical to the previous head (all pre-existing, attributed to
  pytorch#198436 Unit hw_classification declaration, pytorch#198438 and pytorch#205277),
  i.e. zero new violations from these fixes.

Authored with the assistance of an AI coding assistant.
pytorchmergebot pushed a commit to gavinwang269/pytorch that referenced this pull request Nov 26, 2026
…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.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Dec 1, 2026
…t in static launcher tests

Summary

Follow-up fixups on the rebased head of this PR; restores content this
PR's own description says is present but the current pushed head lacks:

- the rebase conflict resolution dropped the module-level
  `from pathlib import Path` import while `Path(compile_path)` is still
  used in test_make_launcher_reuses_loaded_kernel_after_cache_context
  (latent NameError);
- the two oversized-shared-memory tests lost their per-device
  conversion (injected device argument, CUDA-only SkipTest guard ahead
  of the shared helper's torch.cuda.current_device(), per-test Triton
  gate);
- TestStaticTritonLauncherXpuOnly did not inherit
  StaticLauncherTestMixin although its tests call self._make_launcher
  and self.write_cubin_to_tmp (AttributeError on the XPU shard);
- two XPU-specific tests, test_xpu_non_default_warp_size and
  test_xpu_launch_rejects_non_kernel_capsule, were deleted instead of
  moved when the XPU-only tests split into that class; they are
  restored verbatim, so the class holds all eight XPU-specific tests
  of the old launcher class.

Test Plan

- python -m py_compile on the patched file;
- in-tree test linter (tools/linter/adapters/test_linter.py) with the
  file's allowlist entry removed: zero errors in this PR's class
  regions; the remaining 12 file errors belong to pytorch#198436 (Unit
  declaration), pytorch#198438 (CompileResult) and pytorch#205277 (fast launcher),
  identical to the pre-fixup attribution;
- cpu wheel (torch-2.16.0.dev20261102+cpu) venv run of the patched
  file: failure set byte-identical to the unpatched pushed head (10
  known wheel-vs-trunk drift artifacts), i.e. no regression;
- the eight XpuOnly tests execute on the CI XPU shards only
  (only_for="xpu"); no local XPU hardware here.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Dec 1, 2026
… Triton device

Summary

Review feedback: test_launcher_keeps_module_owner_alive_until_release
builds fake kernel-owner and launcher objects, never touches the device
argument it receives, and only checks weakref/gc lifetime behavior, yet
it lived in TestStaticTritonLauncher, whose except_for="cpu"
instantiation and per-test Triton skip mean the ownership check cannot
run on a CPU-only shard.

Upstream has no host launcher test file yet, so move the test as-is
into TestStaticTritonLauncherUnit in the same file, the device-agnostic
unit class that already hosts the adjacent fake-owner lifetime checks,
and drop the unused device parameter and the Triton gate. The test body
is otherwise byte-identical.

Test Plan

- python -m py_compile on the patched file;
- in-tree test linter (tools/linter/adapters/test_linter.py) with the
  file's allowlist entry removed: 11 findings on the patched file,
  identical to the previous head (all pre-existing, attributed to
  pytorch#198436 Unit hw_classification declaration, pytorch#198438 and pytorch#205277),
  i.e. zero new violations from this move;
- AST scan: single definition of the moved test, no undefined names, no
  doubled decorators; gc/weakref/has_triton imports remain referenced
  elsewhere in the file;
- no built torch in this environment, so the moved test was not
  executed locally; as a device-less unit test it now runs in CI on CPU
  shards.
gavinwang269 added a commit to gavinwang269/pytorch that referenced this pull request Dec 1, 2026
… XPU-only launcher class

Summary

Two inline review items at bef2f7b:

TestStaticTritonLauncher gates its compile-on-device launcher cases with a
process-wide has_triton() skipIf, but the class is instantiated for multiple
backends, so a backend without Triton would still run these cases whenever
any other accelerator has Triton. Replace the thirteen per-test decorators
with one per-device gate in setUp using has_triton_for_device, the same
convention _StaticTritonCompileResultMixin already uses in this file; the
two compiling cases that carried no Triton gate (test_float_scalars,
test_bfloat16_scalar) are covered as a side effect, and skipping ahead of
super() keeps the mixin's XPU JITFunction patch from being applied.

The instantiate_device_type_tests call for TestStaticTritonLauncherXpuOnly
passed only_for="xpu" without allow_xpu, so no XPU class was ever emitted:
XPUTestBase joins the candidate bases only under allow_xpu=True, and the
filter then removed everything else. Pass allow_xpu=True, matching the
file's five other instantiations, so the restored XPU-only launcher tests
collect on XPU shards.

Test Plan

- python -m py_compile and ast.parse on the patched file.
- CPU wheel venv (torch 2.16.0.dev20261029+cpu, torch_npu installed so
  PrivateUse1=npu instantiates): module collection is 50 tests with no
  loader errors, unchanged from the pre-change head; the instantiated
  TestStaticTritonLauncherNPU test now skips via the new gate ("requires
  Triton on npu"); the device-free TestStaticTritonLauncherUnit result set
  is identical to the pre-change head (28 run, 23 pass, 3 skip, 2 known
  wheel-vs-trunk drift failures).
- allow_xpu verified against the helper with XPU availability simulated:
  get_desired_device_type_test_bases(only_for="xpu") returns no bases
  without allow_xpu and the xpu base with it; instantiating a dummy
  template with the new kwargs emits its XPU class while the old kwargs
  emit none. This host has no XPU hardware, so real XPU collection runs
  on the CI XPU shards.
- in-tree test linter (tools/linter/adapters/test_linter.py) with the
  file's allowlist entry removed: 11 findings on the patched file,
  identical to the previous head (all pre-existing, attributed to
  pytorch#198436 Unit hw_classification declaration, pytorch#198438 and pytorch#205277),
  i.e. zero new violations from these fixes.

Authored with the assistance of an AI coding assistant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged missing actionable issue A PR without a linked actionable issue or maintainer sponsor 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 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants