Repository navigation
[Testcase Refactoring] Make test_bisect_pre_grad_graph device-agnostic via instantiate_device_type_tests - #198359
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 (3): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198359
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 20908a7 with merge base 38a1839 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/graph" |
c9ff297 to
3f7bd77
Compare
|
@claude review these changes |
|
Claude finished @jansel's task in 50s —— View job Requesting changes: when Full reviewPR Review: #198359SummaryThis PR moves
Infrastructure
Code Quality
RecommendationRequest Changes Restore the Triton skip so the test's previous gating still holds on the device-generic class. Then fix the blank lines and update the PR description to say this PR only moves the method. |
3f7bd77 to
0b057b8
Compare
|
Agreed on the Triton gate — added |
…device migrations Rebased onto latest main (scaffold + migrated debuginfo from pytorch#198361 are kept). Drops the seven methods whose device versions arrive in the parallel move pieces pytorch#198354 (test_bad_decomp), pytorch#198355 (test_joint_graph), pytorch#198356 (test_rng), pytorch#198357 (test_emulate_precision_casts), pytorch#198358 (test_bad_lowering), pytorch#198359 (test_bisect_pre_grad_graph) and pytorch#198360 (test_cudagraph_bisect_max); keeps test_pre_grad, test_crossref and test_eager_backend. Marks the remaining class GENERIC, renames test_ns to bisector_ns (a class attribute named test_* would otherwise be collected by instantiate_device_type_tests), slims tearDown and removes get_lib. Must merge LAST in the series, only after every sibling move above has landed; otherwise the deleted GPU tests lose their replacements. Also fixes the lint failures on the previous revision: removes imports that are unused at this point in the series (contextmanager, import_module, _prims_common, preserve_rng_state, module-level config) and normalizes the blank-line runs left by the method removals. These imports are intentionally not kept for the siblings; each move piece brings back exactly what it uses. Signed-off-by: gavinwang269 <[email protected]>
| self.assertIn(expected_result, output.stdout) | ||
|
|
||
| @unittest.skipIf(not has_triton(), "requires Triton") | ||
| @config.patch( |
There was a problem hiding this comment.
Before modification, the feature in Triton belonged to the class level, but now it is refined to the test case level. If all test cases require it, it can remain consistent with the previous approach and be placed at the class level.
There was a problem hiding this comment.
Same story as #198357: the class-level Triton gate lands there; after it merges, this PR rebases onto main and inherits the class-level decorator. The current method-level gate (09c3138) is a transitional state from resolving the rebase with #198358 bad_lowering landing on main. NPU real-hardware run: test_bisect_pre_grad_graph_npu passes (22.7s).
| from torch.library import _scoped_library, Library | ||
| from torch.testing._internal.common_device_type import instantiate_device_type_tests | ||
| from torch.testing._internal.common_utils import HardwareClassification, requires_cuda | ||
| from torch.testing._internal.inductor_utils import GPU_TYPE, HAS_GPU |
There was a problem hiding this comment.
For the last PR, remember to delete information like GPU_TYPE, HAS_GP, etc.
There was a problem hiding this comment.
Confirmed: the GPU_TYPE/HAS_GPU imports drop in the cleanup PR #198362 once the last test leaves the legacy class.
0b057b8 to
09c3138
Compare
|
The two findings from the latest automated review are addressed in 3a532a9:
|
|
Ready for review of the current head ( |
|
@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 |
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitRoCm, classified CUDA and intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices.
… 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.
… 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.
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitRoCm, classified CUDA and intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices.
…c via instantiate_device_type_tests (pytorch#198359) `test/dynamo/test_compiler_bisector.py` gated its accelerator tests with `@unittest.skipIf(not HAS_GPU, ...)` and built tensors on the module-level `GPU_TYPE`, so one import-time boolean decided the inventory for every device. The device-dependent classes are now instantiated through `instantiate_device_type_tests(<cls>, globals(), except_for="cpu", allow_xpu=True)` -- the form `test/inductor/test_selective_lowering.py` and `test/inductor/test_symm_mem_registry.py` already use -- each test takes `device`, and the Triton requirement is checked per device with `has_triton_for_device(self.device_type)` instead of the process-wide `HAS_GPU`. `except_for` rather than `only_for` because `test/REVIEW.md` Rule 4 forbids `only_for` on an ACCELERATOR class. Two things this revision deliberately does not carry, both because they landed elsewhere first: - The per-device Triton probe is not re-implemented here. `has_triton_for_device` and its interface-level helper are already in `torch/utils/_triton.py` on main, together with the registry-contract, index-awareness and error-propagation cases in `test/inductor/test_utils.py`, so this file only consumes them. - Consequently only this test file is touched. Measured on the base commit's tree: not run locally. The wheels available here predate the `has_triton_for_device` that now lives on main, so importing this file against them would test an environment that no longer matches the PR's base; the CI shards are the evidence for execution, and the description claims nothing beyond what the code does. Pull Request resolved: pytorch#198359 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…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]>
…skip leak Root cause of the blocker: instantiate_device_type_tests registers each test under a device-suffixed name (e.g. test_disable_static_triton_launcher_cuda) and deletes the generic names, so comparing _testMethodName for equality against the generic name could never fire, and the static-launcher registry gate also skipped on devices without a registered launcher -- the out-of-tree accelerator case this PR targets. Match on prefix instead. The gates also move before super().setUp(): tearDown never runs when setUp raises SkipTest, so skipping after the base setUp leaked the Dynamo trace_log NullHandler and the check_sparse_tensor_invariants flag; gate-before-super also matches the merged pytorch#198359 pattern in test_compiler_bisector.py. The manual __enter__/__exit__ config-patch pair becomes enterContext (precedent: test_nested_reduction.py), whose cleanup runs even when setUp raises, so the mixin tearDown goes away. TestCudaStaticTritonCompileResult gains a device_type != "cuda" skip (Rule 5 permits it in CUDA-classified classes): PYTORCH_TESTING_DEVICE_FOR_CUSTOM re-adds matching device bases after only_for is applied, so the CUDA class could still get a PrivateUse1 variant whose oversized-shared-memory test would read torch.cuda device properties instead of skipping. 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 grep of the class/instantiate wiring and line-length/ASCII checks on changed lines. pytest --collect-only could not run (torch import broken). 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]>
…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]>
…skip leak Root cause of the blocker: instantiate_device_type_tests registers each test under a device-suffixed name (e.g. test_disable_static_triton_launcher_cuda) and deletes the generic names, so comparing _testMethodName for equality against the generic name could never fire, and the static-launcher registry gate also skipped on devices without a registered launcher -- the out-of-tree accelerator case this PR targets. Match on prefix instead. The gates also move before super().setUp(): tearDown never runs when setUp raises SkipTest, so skipping after the base setUp leaked the Dynamo trace_log NullHandler and the check_sparse_tensor_invariants flag; gate-before-super also matches the merged pytorch#198359 pattern in test_compiler_bisector.py. The manual __enter__/__exit__ config-patch pair becomes enterContext (precedent: test_nested_reduction.py), whose cleanup runs even when setUp raises, so the mixin tearDown goes away. TestCudaStaticTritonCompileResult gains a device_type != "cuda" skip (Rule 5 permits it in CUDA-classified classes): PYTORCH_TESTING_DEVICE_FOR_CUSTOM re-adds matching device bases after only_for is applied, so the CUDA class could still get a PrivateUse1 variant whose oversized-shared-memory test would read torch.cuda device properties instead of skipping. 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 grep of the class/instantiate wiring and line-length/ASCII checks on changed lines. pytest --collect-only could not run (torch import broken). CI exercises the CUDA variants of both classes. Authored with AI assistance and reviewed by the PR owner before submission. Co-Authored-By: gavinwang269 <[email protected]>
…stic via instantiate_device_type_tests (#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
… 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.
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitRoCm, classified CUDA and intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices.
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitCUDA (renamed from a RoCm-specific name since the class is classified CUDA and its bodies exercise CUDA/ROCm launcher internals through mocks), intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices. Test Plan: ```bash python -m pytest test/inductor/test_static_triton_launcher.py --collect-only -q # 24/60 tests collected, renamed class present ```
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitCUDA (renamed from a RoCm-specific name since the class is classified CUDA and its bodies exercise CUDA/ROCm launcher internals through mocks), intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices. Test Plan: ```bash python -m pytest test/inductor/test_static_triton_launcher.py --collect-only -q # 24/60 tests collected, renamed class present ``` Co-Authored-By: Claude Code <[email protected]>
test/dynamo/test_compiler_bisector.pygated its accelerator tests with@unittest.skipIf(not HAS_GPU, ...)and built tensors on the module-levelGPU_TYPE,so one import-time boolean decided the inventory for every device. The device-dependent
classes are now instantiated through
instantiate_device_type_tests(<cls>, globals(), except_for="cpu", allow_xpu=True)-- theform
test/inductor/test_selective_lowering.pyandtest/inductor/test_symm_mem_registry.pyalready use -- each test takes
device, and the Triton requirement is checked per devicewith
has_triton_for_device(self.device_type)instead of the process-wideHAS_GPU.except_forrather thanonly_forbecausetest/REVIEW.mdRule 4 forbidsonly_foron anACCELERATOR class.
Two things this revision deliberately does not carry, both because they landed elsewhere
first:
has_triton_for_deviceand itsinterface-level helper are already in
torch/utils/_triton.pyon main, together with theregistry-contract, index-awareness and error-propagation cases in
test/inductor/test_utils.py, so this file only consumes them.Measured on the base commit's tree: not run locally. The wheels available here predate the
has_triton_for_devicethat now lives on main, so importing this file against them wouldtest an environment that no longer matches the PR's base; the CI shards are the evidence
for execution, and the description claims nothing beyond what the code does.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98