Repository navigation
[Inductor] Support oversized shared memory in the static CUDA launcher and AOTI - #199309
mattteochen 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 (5): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/199309
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4a991bc with merge base f34bbf7 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@pytorchbot label "topic: not user facing" |
|
cc: @shino16 for review |
shino16
left a comment
There was a problem hiding this comment.
FYI, since triton-lang/triton#12128 Triton sets ALLOW_OVERSIZED for every kernel above 48 KiB (3.8.0; main limits this to cc 10.7).
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
14bb42c to
2b749a0
Compare
kshitij12345
left a comment
There was a problem hiding this comment.
Overall, the fix looks good.
I was wondering if shared helpers and constants can be moved to cpp_wrapper/device_internal/cuda.h which is used by static_launcher/cuda.h and also AOTI. This should avoid some drift of this logic between different subsystems. Wdyt?
Thank you @kshitij12345 . Yes it's indeed better. |
| // CU_SHARED_MEMORY_MODE_ALLOW_OVERSIZED_SHARED_MEMORY. | ||
| constexpr int kDeviceAttrMaxOversizedSharedMemoryPerBlock = 150; | ||
| constexpr int kFuncAttrSharedMemoryMode = 17; | ||
| constexpr int kSharedMemoryModeAllowOversized = 3; |
There was a problem hiding this comment.
What happens if these are not supported by the driver?
There was a problem hiding this comment.
In that case, deviceGetAttribute does not return CUDA_SUCCESS for kDeviceAttrMaxOversizedSharedMemoryPerBlock=150. The other 2 values are never set if we're in this condition.
…r and AOTI Some GPUs (sm_107) allow more shared memory per block than CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN, but only when a function opts into the oversized shared memory mode (CU_FUNC_ATTRIBUTE_SHARED_MEMORY_MODE = CU_SHARED_MEMORY_MODE_ALLOW_OVERSIZED_SHARED_MEMORY, up to CU_DEVICE_ATTRIBUTE_MAX_OVERSIZED_SHARED_MEMORY_PER_BLOCK). Triton compiles and launches kernels against that larger limit, but Inductor's launchers only knew the opt-in limit: - Static CUDA launcher: such a kernel fails to load with OutOfMemoryError, and compile_by_disabling_pipelining silently recompiles it with num_stages=1, so the run succeeds with a much slower kernel. Default autotuning configs are affected, e.g. bf16 mm (128, 128, 128, 4, 8). - AOTI / cpp_wrapper: the generated loadKernel always sets CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, which cannot exceed the opt-in limit, so launching such a kernel fails with "CUDA driver error: invalid argument". Changes: - static_launcher/cuda.cpp: count static + dynamic shared memory. When a kernel needs more than the opt-in limit and fits the oversized limit, set the oversized shared memory mode instead of MAX_DYNAMIC_SHARED_SIZE_BYTES. Kernels within the opt-in limit take the existing path, also using static + dynamic for the 48 KB gate, and a kernel needing exactly the limit is accepted (<=, as on ROCm). The error message reports the limit that applies. - AOTI: both generated loadKernel overloads call a setKernelSharedMemory helper that applies the same rule to static + dynamic shared memory, guarded by #if !defined(USE_ROCM). - Attribute values are spelled out so older CUDA headers still build; a driver that does not know the attribute keeps the old behaviour. Tests (skipped on devices without oversized shared memory): - test_static_triton_launcher.py: test_oversized_shared_mem loads and runs a kernel between the two limits; test_too_high_oversized_shared_mem checks that a kernel above the oversized limit fails with that limit in the message; test_oversized_shared_mem_mm_template checks the mm template is not recompiled with num_stages=1. - test_aot_inductor.py: test_triton_kernel_oversized_shared_mem checks that an AOTI-compiled Triton matmul between the two limits matches eager. - test_cpp_wrapper_hipify.py: expected header updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…her and AOTI Addresses review feedback. The CUDA 13 attribute values and the oversized shared memory rule were duplicated in static_launcher/cuda.cpp and in the kernel_driver() code generated for AOTI / cpp_wrapper, and the two copies had already drifted: the generated code switched to the oversized mode whenever a kernel exceeded the opt-in limit, without checking that the device has an oversized limit at all. The constants and a sharedMemoryLimit() helper now live in cpp_wrapper/device_internal/cuda.h, which aoti_include/cuda.h, cpp_wrapper/cuda.h and static_launcher/cuda.h all include. The helper returns the max static + dynamic shared memory per block for a kernel; a result above the opt-in limit means the kernel must use the oversized mode. It takes the cuDeviceGetAttribute entry point as a parameter because the static launcher reaches the driver through nvrtc() while the generated code calls libcuda directly. Sharing only a driver-free predicate was the alternative, but then "query the oversized limit, fall back on old drivers" would still be duplicated, and that is the part that drifted. Static launcher behaviour is unchanged. The generated code now enables the oversized mode only when the device reports an oversized limit above the opt-in limit, like the static launcher; otherwise it keeps the MAX_DYNAMIC_SHARED_SIZE_BYTES path it had before this PR. Test Plan: ``` python test/inductor/test_cpp_wrapper_hipify.py ``` Run with this branch's device_op_overrides.py loaded over an existing torch build (main @ 8c12b70). It passes, and the updated test fails against the previously generated code. On a GB200 (sm_100, whose oversized limit equals its opt-in limit), compiled the new device_internal/cuda.h together with the generated kernel_driver() code into a standalone driver test (-Wall -Wextra, no warnings). It loads and launches a kernel with 0 B, 1 KiB, 64 KiB and the opt-in maximum of dynamic shared memory, rejects one past the maximum, and checks sharedMemoryLimit() against a fake cuDeviceGetAttribute that reports an sm_107-style oversized limit, an unknown attribute, or no extra memory. static_launcher/cuda.cpp was compiled with -fsyntax-only using the build's compile flags. Not run on sm_107 or ROCm; the sm_107 tests added in the previous commit skip on this machine. This commit was authored with an AI assistant (Claude Code). Co-Authored-By: Claude Opus 5.5 <[email protected]>
5b08f22 to
d3cb239
Compare
There was a problem hiding this comment.
Automated review of d3cb239: nothing blocking; ready for human review.
The PR lets the CUDA static launcher and AOTI/cpp_wrapper loadKernel load kernels whose shared memory is above the opt-in limit but within the oversized limit (sm_107) by setting CU_FUNC_ATTRIBUTE_SHARED_MEMORY_MODE to ALLOW_OVERSIZED. The review's recommendation is Approve: it found no blocking issues, and every point it raises is non-blocking.
⚪ 5 non-blocking findings
Non-blocking: AOTI no longer catches a kernel that is too big when it loads. sharedMemoryLimit (device_internal/cuda.h:23-39) returns the oversized limit whenever the kernel needs more than the opt-in limit, but never checks whether the need is also above the oversized limit. The generated setKernelSharedMemory then sets oversized mode and returns without checking, so a kernel above the oversized limit loads and fails only at cuLaunchKernel, with a vaguer driver error. Before this PR, cuFuncSetAttribute(MAX_DYNAMIC_SHARED_SIZE_BYTES, sharedMemBytes) rejected it at load. The static launcher does check this (cuda.cpp:232-241). This mostly shows up when a package is deployed to a different device. Cleaner fix, as kshitij12345 asked: put the whole decision (limit check, mode or max-dynamic setting, cache config) in one helper in device_internal/cuda.h and call it from both loaders. The copies have already drifted: the static launcher applies PREFER_SHARED based on static + dynamic memory (cuda.cpp:253), while AOTI still uses dynamic-only sharedMemBytes > 49152 (line 131).
Non-blocking: the hard-coded CUDA enum values (150 / 17 / 3) are never checked against the real headers. If any is wrong, the driver either quietly reports the attribute as unsupported (so the old behaviour comes back) or sets a different function attribute. Nothing would flag it: every new oversized test skips unless the device has more oversized than opt-in shared memory, and there is no sign CI has sm_107 runners. Fix: add static_assert(kX == CU_...) for all three values, guarded on the CUDA toolkit version that introduced the enums. The tree already uses #if CUDA_VERSION >= 13000 guards (e.g. aten/src/ATen/cuda/CUDAGraph.cpp:595). CUDA_VERSION is defined in both places that include the header, since <cuda.h> comes in through aoti_runtime/utils_cuda.h.
Non-blocking: the comments and PR description don't match the new behaviour. Both oversized branches (cuda.cpp:243-250, device_op_overrides.py:117-123) return before cuFuncSetCacheConfig(CU_FUNC_CACHE_PREFER_SHARED) and without setting MAX_DYNAMIC_SHARED_SIZE_BYTES. The comment at device_op_overrides.py:69-71 ("loadKernel prefers shared memory to L1 for kernels that use more than 48 KB") and the block at cuda.cpp:213-218 describe only the old path. Please say in a comment whether skipping PREFER_SHARED is intentional, for example because oversized mode forces the largest carveout anyway. The description says the mode is enabled "the same way Triton's own launcher does". shino16 pointed out that Triton sets ALLOW_OVERSIZED for every kernel above 48 KiB (on main, only on cc 10.7), and the author has not replied. Please correct the description, or explain why enabling it only above the opt-in limit is right.
Non-blocking: test_oversized_shared_mem_mm_template can pass even with the fix reverted. The opt_in < 262144 + 1024 <= oversized gate uses an estimate of the template's shared memory, not the compiled kernel's actual value. If Triton allocates fewer pipeline buffers than assumed, the kernel fits in the opt-in limit and takes the old path, so the test passes without exercising oversized mode. Fix: check the generated template kernel's real shared value against opt_in, as test_triton_kernel_oversized_shared_mem does with .metadata.shared.
Non-blocking: test_too_high_oversized_shared_mem compares limits from two different sources. The expected Hardware limit:{oversized} comes from Triton's max_shared_mem, while the C++ side prints shared_limit, which comes from CUDA attribute 150 via sharedMemoryLimit. If the two values ever differ, the test fails for reasons unrelated to this code, or oversized + 4 loads without raising at all. Fix: either match only out of resource: simple_kernel Required: {oversized + 4}, or read the limit the same way the C++ code does. (Low confidence: Triton's source isn't in the checkout, so the reviewer couldn't confirm whether the two values agree on sm_107.)
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
Main extracted static-launcher resource errors into throwOutOfResourceError while this branch changed the CUDA shared-memory limit calculation. Resolve the overlap by using the shared error helper with the oversized limit and static-plus-dynamic memory requirement, preserving the inclusive boundary and oversized-mode setup. Keep ROCm's opt-in check and retain the TMA test decorators on the existing TMA test. Accept whitespace in the oversized error test to match the shared helper's error format. A merge preserves the existing PR commits and avoids rewriting the branch. Test Plan: ```bash git diff --cached --check main git ls-files -u git diff --name-only ``` Passed; no unresolved files or unstaged changes. Python AST parsing passed for all four changed Python files. ```bash lintrunner -a --data-path /Users/kaiximatteoc/nvidia/dev/pytorch/agent_space/pr199309/lint-data --paths-from ../pr-files.txt ``` Attempted; blocked by missing clang-format, clang-tidy and pyrefly, plus local linter compatibility failures. No build or GPU runtime tests were run. The user reviewed and approved the resolution with these limitations. Authored with an AI assistant (Codex).
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…r and AOTI (pytorch#199309) # Fixing an Issue Before submitting, please review: - [The Ultimate Guide to PyTorch Contributions](https://github.com/pytorch/pytorch/wiki/The-Ultimate-Guide-to-PyTorch-Contributions#getting-started-with-pull-requests) - [AI-Assisted Development](https://github.com/pytorch/pytorch/blob/main/AI_POLICY.md) policy Go through the following checklist - [x] Passes lint (`spin fixlint`) - [x] Added/updated tests - [ ] Updated documentation (if applicable) - [ ] Included benchmark results (for PRs impacting perf) --- ## Issue being fixed Fixes pytorch#199308 ## BC-breaking? No ## Summary (human written only) On sm_107, Triton can give a kernel more shared memory than the per-block opt-in limit by enabling CUDA's oversized shared memory mode, but Inductor's static launcher and the AOTI/cpp_wrapper loader only knew the opt-in limit. The static launcher then fell back to recompiling such kernels with `num_stages=1`, silently slowing down affected autotune configs, and AOTI failed with `invalid argument`. This change enables the oversized mode in both loaders, only when a kernel needs more than the opt-in limit, the same way Triton's own launcher does. ## Agent details (if applicable) Written with Claude Code (Claude Opus 5.5); I have read and tested the change. Its summary of the change and testing: > **Change** > - `static_launcher/cuda.cpp`: count static + dynamic shared memory. When a kernel needs > more than the opt-in limit and fits the oversized limit > (`CU_DEVICE_ATTRIBUTE_MAX_OVERSIZED_SHARED_MEMORY_PER_BLOCK`), set > `CU_FUNC_ATTRIBUTE_SHARED_MEMORY_MODE = CU_SHARED_MEMORY_MODE_ALLOW_OVERSIZED_SHARED_MEMORY` > instead of `MAX_DYNAMIC_SHARED_SIZE_BYTES`, as Triton's own launcher does. Kernels within > the opt-in limit take the existing path; a kernel needing exactly the limit is accepted > (`<=`, as on ROCm); the error reports the limit that applies. > - AOTI / cpp_wrapper: both generated `loadKernel` overloads call a `setKernelSharedMemory` > helper with the same rule, guarded by `#if !defined(USE_ROCM)`. > - Attribute values are spelled out so older CUDA headers still build; a driver that doesn't > know the attribute keeps the old behaviour. > > **Tests** (skip on devices without oversized shared memory) > - `test_static_triton_launcher.py`: `test_oversized_shared_mem`, > `test_too_high_oversized_shared_mem`, `test_oversized_shared_mem_mm_template` > (no `num_stages=1` fallback). > - `test_aot_inductor.py`: `test_triton_kernel_oversized_shared_mem`. > - `test_cpp_wrapper_hipify.py`: expected header updated. > > **Testing done** on a source build of this branch on an sm_107 GPU: all new tests pass and > each fails with the fix removed; no new failures in `test_static_triton_launcher.py`, an AOTI > subset (254 tests) or a GPU cpp_wrapper subset (55 tests). `spin fixlint` is clean > except clang-tidy, which needs a configured build and could not run locally. Pull Request resolved: pytorch#199309 Approved by: https://github.com/shino16, https://github.com/kshitij12345, https://github.com/desertfire Co-authored-by: Claude Opus 5.5 <[email protected]>
…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.
…ss tests (#205060) Summary: The subprocess tests in `test/inductor/test_gpu_cpp_wrapper.py` ran with their Inductor cache dir as the working directory, which Python puts first on `sys.path`, so a cache entry directory could shadow a real module. Depending on the generated code's hashes, an entry such as `z3/` can shadow the `z3` package, which made `test_lazy_compile_kernel_name_collision_across_modules` fail with #199309 in some environments. Keep the cache in an `inductor_cache/` subdirectory instead. Test-only change. Test Plan: CI Differential Revision: D132158104 Pull Request resolved: #205060 Approved by: https://github.com/pytorchgreenlight, https://github.com/desertfire
…6, deeper 128x256 On sm_107 the Blackwell warp-specialized persistent TMA template leaves FP8 scaled_mm performance on the table. It always double-buffers the TMEM accumulator, so a 256x256 fp32 tile needs 1,024 of 576 TMEM columns and fails to compile, although a single copy (512 columns) fits. And the scaled_mm config list has the 128x256x128 tile only at 3 stages. BlackwellGPUGemmConfig gets disallow_acc_multi_buffer (default False). When set, the template passes disallow_acc_multi_buffer=True to tl.range; configs without it render exactly as before. On sm_107 the scaled_mm WS heuristic adds a 256x256x128 4-stage single-accumulator config and 128x256x128 at 5 and 6 stages. They need sm_107's oversized shared memory mode, which the static launcher supports since pytorch#199309. With rowwise scales the 6-stage config needs more shared memory than even that mode allows, so it is offered only when both scales are tensorwise. The configs are chosen when the config generator is built, from the current device's capability, rather than when the heuristic singleton is created, so a process that first compiles for another GPU still gets them on sm_107. Test Plan: CPU tests of the sm_107 config list and of the tensorwise-only filter (device capability mocked), and sm_107 GPU tests that the single-accumulator flag reaches the kernel and that the 6-stage config is offered only for tensorwise scales, both failing on a num_stages=1 fallback. Run on a VR NVL72 (sm_107) with the 2.16.0.dev20261123+cu135 nightly plus this change, in nvcr.io/nvidia/pytorch:26.11-py3: ``` python test/inductor/test_max_autotune_blackwell.py -v -k sm107 -k SM107 \ -k test_autows_configs_follow_current_mode -k test_scaled_blackwell_tma_uses \ -k scaled_mm_per_tensor_persistent_tma -k scaled_mm_per_row_persistent_tma ``` All 37 selected tests pass; the same selection from the unchanged test file passes on the nightly without this change. Performance: FP8 e4m3 -> bf16 torch._scaled_mm compiled with max_autotune, max_autotune_gemm_backends="TRITON" and persistent TMA, timed with CUDA graphs, base and patched runs alternated on the same GPU. Up to 1.27x faster (e.g. 8192^3 tensorwise 1.24x, rowwise 1.21x); geomean 1.06-1.11x over squares and DeepSeek-V3 projection shapes. With the default backends (ATEN,TRITON), 8192^3 rowwise now picks the 128x256x128 5-stage config over cuBLASLt (1.29x). Authored with Claude Code (Claude Opus 5.5). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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
Fixing an Issue
Before submitting, please review:
Go through the following checklist
spin fixlint)Issue being fixed
Fixes #199308
BC-breaking?
No
Summary (human written only)
On sm_107, Triton can give a kernel more shared memory than the per-block opt-in limit by enabling CUDA's oversized shared memory mode, but Inductor's static launcher and the AOTI/cpp_wrapper loader only knew the opt-in limit. The static launcher then fell back to recompiling such kernels with
num_stages=1, silently slowing down affected autotune configs, and AOTI failed withinvalid argument. This change enables the oversized mode in both loaders, only when a kernel needs more than the opt-in limit, the same way Triton's own launcher does.Agent details (if applicable)
Written with Claude Code (Claude Opus 5.5); I have read and tested the change. Its summary of the change and testing:
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo