Skip to content

[Inductor] Filter decompose-K splits by output tiles and workspace - #195939

Closed
jananisriram wants to merge 34 commits into
gh/jananisriram/38/basefrom
gh/jananisriram/38/head
Closed

jananisriram wants to merge 34 commits into
gh/jananisriram/38/basefrom
gh/jananisriram/38/head

Conversation

@jananisriram

@jananisriram jananisriram commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Decompose-K autotunes up to 10 split choices for each large-K mm, and most of them never win. This filters out splits that launch too few output tiles (split * ceil(M/64) * ceil(N/64)) or need a large FP32 workspace (split * M * N * 4 bytes).

The bounds depend on the device:

  • SM100+: enough output tiles to fill one wave (half the SM count)
  • Other NVIDIA GPUs: at least 8 output tiles, with at most 8 MiB of workspace
  • Everything else: no filter

The filter only removes candidates and never removes all of them. It is skipped for symbolic shapes and the EXHAUSTIVE search space. TORCHINDUCTOR_DECOMPOSE_K_MIN_OUTPUT_TILE_SIZE sets the tile size used for the estimate (default 64; 0 turns the filter off).

On H100, across 64 decompose-K shapes, it removes 27% of split choices without losing any split that beats ATen, and cuts autotune time by 31% on 10 held-out shapes.

Test plan:
python test/inductor/test_max_autotune.py -k decompose (54 tests, H100)

Agent details

Drafted with an AI assistant (Claude); pending author review.

gfx950 (MI350X) also gets a bound: at least 32 output tiles and at most 64 MiB of FP32 workspace, gated on rocm_gfx_arch() == "gfx950". Other ROCm targets stay unfiltered. Across 241 MI350X decompose-K shapes it keeps 77% of split choices, and no shape gets more than 2% slower than with every split.

Differential Revision: D121710493

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 39eba0c with merge base ed2f237 (image):
💚 Looks good so far! There are no failures yet. 💚

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Triviality
    • New autotune pruning heuristic: filter_decompose_k_splits and decompose_k_split_bounds in torch/_inductor/heuristics/template/decompose_k.py
    • On by default: _get_template_configs_impl now drops split candidates for static shapes on CUDA and gfx950
    • Not a bugfix, refactor, or established pattern, so it fits no trivial change class
  • New user configuration
    • Adds triton.decompose_k_min_output_tile_size and env var TORCHINDUCTOR_DECOMPOSE_K_MIN_OUTPUT_TILE_SIZE in torch/_inductor/config.py
  • Correctness (no defect found)
    • Imported helpers (get_num_sms, rocm_gfx_arch, ceildiv, DeviceProperties.create) exist; the filter never returns an empty list for a non-empty input
    • The tests in test_max_autotune.py cover the filter, the per-device bounds, and the symbolic-shape skip

reason: not_trivial
Reviewed commit: 084dfba (NOT the current head 39eba0c)

Inference job

🐛 Report a wrong verdict

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

[ghstack-poisoned]
@jananisriram jananisriram changed the title [Inductor] Improve Blackwell decompose-K split candidates [Inductor] Improve Blackwell ATen decompose-K split candidates Sep 3, 2026
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@jananisriram jananisriram added the topic: not user facing topic category label Sep 11, 2026
@jananisriram
jananisriram marked this pull request as ready for review November 14, 2026 00:17
@pytorchgreenlight pytorchgreenlight Bot added the GL/human GreenLight marked as needing human review label Nov 14, 2026
…ounds; #203875 restacked, wording only

[ghstack-poisoned]
jananisriram added a commit that referenced this pull request Nov 19, 2026
decompose_k was off by default on ROCm pending perf validation (#169948). On MI350X it beats hipBLASLt and the Triton mm template on many large-K GEMMs, so this uses the same default as CUDA (`num_decompose_k_splits=10`).

## Agent details
Drafted with an AI assistant (Claude); pending author review.

Stacked on #195939 and #203681 (the read-flush benchmarker the numbers below were measured with).

MI350X, 172 GEMMs that pass the default `decompose_k_threshold` (K >= 32 * max(M, N)). Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681):
- geomean dk-on / dk-off pick: 0.971; 58 shapes >3% faster
- 7 shapes >3% slower beyond the re-timing noise of aten itself (all autotune misranks between aten and decompose_k)
- fp32 within 4e-6 of aten

These were measured with splits pruned to at least 32 output tiles of 64x64 and at most 64 MiB of workspace, which #195939's split bound applies on gfx950; other ROCm archs are not pruned. Other ROCm archs (MI300/gfx942, gfx90a, RDNA) are not measured.

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
`test_max_autotune_decompose_k_envvars` gains a default-splits case that checks decompose_k is offered.

ghstack-source-id: 570fd87
Pull-Request: #203875
@jananisriram

Copy link
Copy Markdown
Contributor Author

@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@jananisriram

Copy link
Copy Markdown
Contributor Author

@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

jananisriram added a commit that referenced this pull request Nov 19, 2026
decompose_k was off by default on ROCm pending perf validation (#169948). On MI350X it beats hipBLASLt and the Triton mm template on many large-K GEMMs, so this uses the same default as CUDA (`num_decompose_k_splits=10`).

## Agent details
Drafted with an AI assistant (Claude); pending author review.

Stacked on #195939 and #203681 (the read-flush benchmarker the numbers below were measured with).

MI350X, 172 GEMMs that pass the default `decompose_k_threshold` (K >= 32 * max(M, N)). Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681):
- geomean dk-on / dk-off pick: 0.971; 58 shapes >3% faster
- 7 shapes >3% slower beyond the re-timing noise of aten itself (all autotune misranks between aten and decompose_k)
- fp32 within 4e-6 of aten

These were measured with splits pruned to at least 32 output tiles of 64x64 and at most 64 MiB of workspace, which #195939's split bound applies on gfx950; other ROCm archs are not pruned. Other ROCm archs (MI300/gfx942, gfx90a, RDNA) are not measured.

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
`test_max_autotune_decompose_k_envvars` gains a default-splits case that checks decompose_k is offered.

ghstack-source-id: e11cf66
Pull-Request: #203875
@jananisriram

Copy link
Copy Markdown
Contributor Author

@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

jananisriram added a commit that referenced this pull request Nov 19, 2026
decompose_k was off by default on ROCm pending perf validation (#169948). On MI350X it beats hipBLASLt and the Triton mm template on many large-K GEMMs, so this uses the same default as CUDA (`num_decompose_k_splits=10`).

## Agent details
Drafted with an AI assistant (Claude); pending author review.

Stacked on #195939 and #203681 (the read-flush benchmarker the numbers below were measured with).

MI350X, 172 GEMMs that pass the default `decompose_k_threshold` (K >= 32 * max(M, N)). Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681):
- geomean dk-on / dk-off pick: 0.971; 58 shapes >3% faster
- 7 shapes >3% slower beyond the re-timing noise of aten itself (all autotune misranks between aten and decompose_k)
- fp32 within 4e-6 of aten

These were measured with splits pruned to at least 32 output tiles of 64x64 and at most 64 MiB of workspace, which #195939's split bound applies on gfx950; other ROCm archs are not pruned. Other ROCm archs (MI300/gfx942, gfx90a, RDNA) are not measured.

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
`test_max_autotune_decompose_k_envvars` gains a default-splits case that checks decompose_k is offered.

ghstack-source-id: f917151
Pull-Request: #203875
@jananisriram

Copy link
Copy Markdown
Contributor Author

@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@jananisriram

Copy link
Copy Markdown
Contributor Author

@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

[ghstack-poisoned]
jananisriram added a commit that referenced this pull request Dec 1, 2026
decompose_k was off by default on ROCm pending perf validation (#169948). On MI350X it beats hipBLASLt and the Triton mm template on many large-K GEMMs, so this uses the same default as CUDA (`num_decompose_k_splits=10`).

## Agent details
Drafted with an AI assistant (Claude); pending author review.

Stacked on #195939 and #203681 (the read-flush benchmarker the numbers below were measured with).

MI350X, 172 GEMMs that pass the default `decompose_k_threshold` (K >= 32 * max(M, N)). Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681):
- geomean dk-on / dk-off pick: 0.971; 58 shapes >3% faster
- 7 shapes >3% slower beyond the re-timing noise of aten itself (all autotune misranks between aten and decompose_k)
- fp32 within 4e-6 of aten

These were measured with splits pruned to at least 32 output tiles of 64x64 and at most 64 MiB of workspace, which #195939's split bound applies on gfx950; other ROCm archs are not pruned. Other ROCm archs (MI300/gfx942, gfx90a, RDNA) are not measured.

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
`test_max_autotune_decompose_k_envvars` gains a default-splits case that checks decompose_k is offered.

ghstack-source-id: 60f9963
Pull-Request: #203875
@jananisriram

Copy link
Copy Markdown
Contributor Author

@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@pytorchgreenlight pytorchgreenlight Bot added GL/superseded GreenLight review is superseded by changes and removed GL/human GreenLight marked as needing human review labels Dec 1, 2026
@jananisriram

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/b200 ciflow/h100 ciflow/inductor ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request GL/superseded GreenLight review is superseded by changes Merged module: inductor topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants