Repository navigation
[Testcase Refactoring] Move RoCm-scratch unit tests into a CUDA-classified class - #203550
gavinwang269 wants to merge 3 commits 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 (2): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203550
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 2498ab3 with merge base 06a91f0 ( NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following job failed, but the AI CI Advisor judged the failure not to be evidence against this change:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant.
9581e4b to
de24471
Compare
|
@pytorchbot label "module: tests/graph" |
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant.
de24471 to
aa11a3b
Compare
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant.
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant.
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant. Rebase notes (onto main after pytorch#199309): main's two new oversized shared memory tests (test_oversized_shared_mem, test_too_high_oversized_shared_mem) are kept and converted to this PR's per-device form: injected device argument, per-test Triton gate, and a CUDA-only SkipTest guard since the shared helper _oversized_shared_mem_limits() reads torch.cuda device properties. The from pathlib import Path import is restored because test_make_launcher_reuses_loaded_kernel_after_cache_context still calls Path(); without it the PR head raises NameError (undefined-name check on the pre-rebase head confirms this predates the rebase).
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant. Rebase notes (onto main after pytorch#199309): main's two new oversized shared memory tests (test_oversized_shared_mem, test_too_high_oversized_shared_mem) are kept and converted to this PR's per-device form: injected device argument, per-test Triton gate, and a CUDA-only SkipTest guard since the shared helper _oversized_shared_mem_limits() reads torch.cuda device properties. The from pathlib import Path import is restored because test_make_launcher_reuses_loaded_kernel_after_cache_context still calls Path(); without it the PR head raises NameError (undefined-name check on the pre-rebase head confirms this predates the rebase). Rebase notes (onto main after pytorch#198440): pytorch#198440 refactored the unrelated TestFastLauncherCompileResult class and moved the file's instantiate_device_type_tests calls into a single trailing group; this PR's TestStaticTritonLauncher instantiation now joins that group. The import-block and tail hunks merged accordingly; nothing inside the decoupled class changed.
…via instantiate_device_type_tests Independent slice (launcher migration only; the three unit-class splits moved out of this PR to their own dependency-free PRs pytorch#203548 pytorch#203550 pytorch#203551): class-level @requires_gpu_and_triton replaced by per-test Triton gates and instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True); 12 of 14 tests gain the injected device argument; write_cubin_to_tmp picks the binary key per device (npubin alongside zebin/cubin/hsaco); the JITFunction getitem save becomes unconditional (module scope) and the patch install moves into setUp/tearDown of every instantiated device variant.
…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.
aa11a3b to
b0514af
Compare
…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.
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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-aarch64-cuda13.2-py3.12-gcc13-sm100 / test (smoke_b200, 1, 1, nv-l-arm64grace-16-200-gb300). Blocking jobs that the merge waited on for a Dr.CI or AI CI Advisor classification: 1. Details for Dev Infra teamRaised by workflow job |
|
@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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-aarch64-cuda13.2-py3.12-gcc13-sm100 / test (smoke_b200, 1, 1, nv-l-arm64grace-16-200-gb300) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
…ssified unit class The three global-scratch unit tests in TestStaticTritonLauncherUnit are RoCm-incompatible (@skipIfRocm or hip-only) and keep the otherwise device-independent unit class from being declared GENERIC. pytorch#203548 already established TestStaticTritonLauncherUnitCuda for exactly this purpose and pre-delegated the _global_scratch_kernel helper, so the tests move there verbatim instead of introducing a second class. Test Plan: python -m pytest test/inductor/test_static_triton_launcher.py -q
…ncherUnitCuda b334498 moved test_rocm_rejects_global_scratch into TestStaticTritonLauncherUnitCuda, which made the class docstring wrong: it claimed the class cannot run on RoCm, that TestStaticTritonLauncherUnit was left with only device-independent tests (the two skipIfRocm metadata-group tests stay there until pytorch#203551 moves them), and named a CUDAAutotuner that exists nowhere; the code uses CachingAutotuner. The "not instantiated" sentence also never held after the class landed with instantiate_parametrized_tests and a parametrize-decorated test. Shorten the docstring accordingly, keeping only statements that hold at this commit: CUDA-family (CUDA and ROCm) launcher unit tests split out of the unit class, shared helpers delegated by reference. Test Plan: python3 -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())" Docstring-only diff; no behavior to exercise beyond the AST check.
…cstring f72c3ea described the class as covering the CUDA-family launcher runtime "(CachingAutotuner / StaticallyLaunchedCudaKernel)". CachingAutotuner is not CUDA-family: it lives in the device-generic Triton runtime (torch/_inductor/runtime/triton_heuristics.py) and the sibling TestStaticTritonLauncherUnit exercises it device-independently, e.g. test_build_fast_launcher_unsupported_device with "privateuseone". What this class covers are the CUDA/ROCm paths of CachingAutotuner and StaticallyLaunchedCudaKernel: the autotuner fast-launcher build with device_props type "cuda", StaticallyLaunchedCudaKernel scratch rejection, and the hip-only global-scratch test. Reword the docstring around that, note once that CachingAutotuner itself is device-generic, and keep the split-from-unit-class and by-reference helper delegation statements. Test Plan: python3 -I -c "import ast; ast.parse(open('test/inductor/test_static_triton_launcher.py').read())" Docstring-only diff (+5/-5); no behavior to exercise beyond the AST check.
|
Successfully rebased |
daeb4da to
2498ab3
Compare
|
@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 |
|
@pytorchbot drci |
…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
|
@pytorchbot merge |
|
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 |
|
@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 |
|
Landed as |
Summary
Slice 2 of 4 of the static-launcher re-cut (independent; any order; original monolith #198437).
Moves three scratch-space tests out of
TestStaticTritonLauncherUnitinto the existing CUDA-classified classTestStaticTritonLauncherUnitCuda, established by #203548:test_global_scratch_allocation,test_fast_launcher_rejects_global_scratch(both@skipIfRocm) andtest_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 aCUDAAutotunerthat does not exist; it now describes the class as covering the CUDA/ROCm paths ofCachingAutotunerandStaticallyLaunchedCudaKernel, noting thatCachingAutotuneritself is device-generic.(+50/-55, one file; relocation of the three test bodies plus the docstring fix)
What classifies
TestStaticTritonLauncherUnitThis slice does not declare
hw_classificationon the source class. The unit class still holds the last two device-gated tests,test_static_launch_takes_cubin_from_metadata_groupandtest_static_launch_rejects_ambiguous_metadata_group(@skipIfRocm); slice 3 (#203551) moves those intoTestStaticTritonLauncherUnitMetadataGroup(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
f72c3ea88139: build plus all 8defaultshards pass onlinux-noble-rocm-py3.11-mi300;test_rocm_rejects_global_scratchran on shard 1/8 and passed, per the shard's junit report (56 tests, 0 skipped, 0 failed). The current headdaeb4dafbdf3only rewords the class docstring, no behavioral change. Theciflow/rocm-mi300label madetest_rocm_rejects_global_scratchactually execute. It runs becauserocm-mi300.ymlruns thedefaultconfig, which discovers this file (it is in neither the job'stests-to-excludenor theROCM_BLOCKLISTintest/run_test.py), and ROCm jobs excludeGENERICclasses only, so the CUDA-classified class runs. The earlier review round suggestedciflow/inductor-rocm-mi300instead; that workflow runs theinductorconfig, whosetest_inductor_shardin.ci/pytorch/test.shnever includestest_static_triton_launcher.tools/linter/adapters/test_linter_allowlist.json, andcheck_fileintools/linter/adapters/test_linter.pyreturns early for allowlisted paths, so the regular lintrunner path verifies nothing here. The file leaves the allowlist when the family-wide classification completes.cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben
Linked issue or supporting maintainer
Part of #185590 (test case refactoring initiative) - hardware-decoupling slice.