Skip to content

[Inductor][ROCm] Enable decompose_k by default on ROCm - #203875

Open
jananisriram wants to merge 9 commits into
gh/jananisriram/129/basefrom
gh/jananisriram/129/head
Open

jananisriram wants to merge 9 commits into
gh/jananisriram/129/basefrom
gh/jananisriram/129/head

Conversation

@jananisriram

@jananisriram jananisriram commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

decompose_k was disabled on ROCm by default "pending perf testing" (#169948). On MI350X it beats hipBLASLt and the Triton mm template on many large-K GEMMs. This sets the ROCm default of num_decompose_k_splits to 10, the same as CUDA, so decompose_k is offered on all ROCm archs under the same decompose_k_threshold rule. Setting TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS still overrides it.

Test Plan:

python test/inductor/test_max_autotune.py -k decompose_k_envvars

Agent details

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

  • The earlier description covered a gfx950-only default with its own offer rule, which was dropped. Its MI350X numbers were scored against that rule, so they were removed. MI350X numbers for this version still need to be measured.
  • Restacked onto main, so this no longer depends on [Inductor][ROCm] Flush L2 + Infinity Cache with a read in InductorBenchmarker #203681. [Inductor] Filter decompose-K splits by output tiles and workspace #195939's split bound (gfx950: at least 32 output tiles of 64x64, at most 64 MiB of FP32 workspace) still applies.
  • test_max_autotune_decompose_k_envvars adds a default-config case. The zero-splits branch now reads the effective config.triton.num_decompose_k_splits, so TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS=0 in the environment doesn't break it.
  • B200 (CUDA, which this doesn't change): test_max_autotune.py -k decompose 60 passed.

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

Differential Revision: D131834107

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

PR Status: in progress

Please address review feedback on your PR either with a code/PR description change. If a review comment is irrelevant, react with 👎 on that specific comment to reject it, and leave a short reply explaining why. The change must pass any running CI and existing failures must be classified as unrelated (see status below in this comment).

Passing automated review does not guarantee that this PR will be merged. It still requires maintainer review and may be closed if its design or direction does not align with the project.

To minimize iteration time, feel free to run the pr-review skill from the repo locally. To trigger a fresh automated review, make a new push or comment @pytorchbot review. To bypass automated review, please add the "no automated review" label.

🟡 AUTOMATED REVIEW - Changes requested:

The PR changes the ROCm default of `config.triton.num_decompose_k_splits` from 0
to 10, matching CUDA, and adds a default-config case to
`test_max_autotune_decompose_k_envvars`. Recommendation: Request Changes. The
blocking point is that the PR removes the "pending performance validation" gate
with no performance data, and it applies to ROCm archs that have no split
bounds.

Findings (5):

[major] torch/_inductor/config.py:2718
Blocking (continuing from the last review): the PR removes the "pending
performance validation" gate but provides no performance data for what ships.
The description says "MI350X numbers for this version still need to be
measured", and the earlier ~1.9x compile-time figure was dropped. On HIP,
`keep_triton_mm` is always true (kernel/mm.py:700-706), so choices are only
added: every qualifying mm under max-autotune gets up to 10 extra subgraph
choices to compile and benchmark. `decompose_k_split_bounds` returns (0, 0) for
every HIP arch except gfx950, so gfx90a, gfx942, RDNA and gfx1250 have no limit
on split size. Example: fp16 M=N=4096, K=131072 gives splits [8, 16, 32], which
need 512 MiB, 1 GiB and 2 GiB of FP32 workspace. The winner is picked on speed
alone, so peak memory can grow. Even on gfx950 the fallback to split 8 needs 512
MiB. ciflow/rocm-mi200 is not on the PR, so gfx90a is never tested. Open
question: gate this to gfx950 via `config.rocm` data checked in
`use_decompose_k_choice`. Fix: measure the shipped default on at least gfx942
and gfx950 (runtime geomean, regressions, compile-time ratio, peak memory; e.g.
ciflow/inductor-perf-test-nightly-rocm-mi300/-mi350), then post the results or
limit the default to the archs you measured.

[minor] test/inductor/test_max_autotune.py:3518
Non-blocking: the `None` case can't catch a regression in the default this PR
changes. The zero branch now follows the effective config, so if the ROCm
default went back to 0 the test would take the `assertEqual(decompose_count, 0)`
branch and still pass. With the default of 10, both shapes give the same split
counts as the `20` case, so the new case adds no coverage. Fix: when the env var
is unset, assert `config.triton.num_decompose_k_splits > 0` in the `None` case.

[minor] test/inductor/test_max_autotune.py:3548
Minor: check `<= 0` instead of `== 0` here. A negative env value disables
decompose_k (utils.py:3528) but still takes the `assertGreater` branch.

[minor] torch/_inductor/config.py:2718
Non-blocking, low confidence: with the opt-in CK BLAS backend
(`preferred_blas_library("ck")`), every decompose_k choice now fails during
autotuning. The partial `torch.bmm(..., out_dtype=torch.float32)`
(kernel/decompose_k.py:82) hits the CK-only TORCH_CHECK in
aten/src/ATen/cuda/CUDABlas.cpp:827-830 / 855-858. Autotuning turns each failure
into an infinite timing, so nothing crashes, but by default CK users get up to
10 log.error lines per GEMM. Fix: skip decompose_k when the preferred BLAS
backend is CK.

[minor] torch/_inductor/config.py:2718
Non-blocking: this changes a user-visible default for every ROCm max-autotune
user, and the PR has no `release notes:` or `topic:` label. Effects: longer
compile time, possibly higher peak memory, and different FP32-accumulated
numerics whenever a split wins. bc-guidelines.md asks for changed defaults to be
documented in release notes. Fix: add the label and mention
`TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS=0` as the way to restore the old behavior.

Reviewed commit: fde7c86

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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 fde7c86 with merge base ed2f237 (image):

🟡 GREEN LIGHT - PR requires human review:

  • User-facing surface
    • torch/_inductor/config.py changes the ROCm default of triton.num_decompose_k_splits from 0 to 10
    • Users set this through torch._inductor.config and TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS, so a default change is a hard stop
    • The description says MI350X numbers for this version still need to be measured
  • Correctness
    • No defect found: utils.py reads the config at lines 3528 and 3561, and the new None test case exercises the default path
    • test_max_autotune_decompose_k_envvars checks the effective config inside the config.patch block and adds assertGreater

reason: needs_socialization
Reviewed commit: fde7c86

Inference job

🐛 Report a wrong verdict

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.

@pytorch-bot pytorch-bot Bot added module: inductor module: rocm AMD GPU support for Pytorch labels Nov 6, 2026
@pytorch-bot

pytorch-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@pytorch-bot pytorch-bot Bot added ciflow/b200 ciflow/h100 ciflow/inductor ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/torchtitan Run TorchTitan integration tests labels Nov 7, 2026
jananisriram added a commit that referenced this pull request Nov 7, 2026
On MI350X (gfx950), decompose_k beats hipBLASLt and the Triton mm template on many large-K GEMMs, but it is off on ROCm. This turns it on by default on gfx950 only (`num_decompose_k_splits=-1`, the new ROCm default, resolves to 10 splits there and 0 elsewhere).

With the default, decompose_k is offered when:
- K >= 8 * max(M, N)
- 8192 <= K <= 2M
- the unsplit GEMM has fewer than 32 output tiles of 256x256

Splits are pruned to at least 32 output tiles of 64x64 and at most 64 MiB of FP32 workspace. The bounds are in `config.rocm.decompose_k_*`.

CUDA, other ROCm archs, and any explicit `TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS` keep today's behavior.

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

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

MI350X, 241 shapes that pass the arch-gated rule before the K and tile caps. Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681). The rule above is re-scored from those measurements:
- geomean dk-on / dk-off pick: 0.967; 60 shapes >3% faster
- 5 shapes >3% slower beyond the re-timing noise of aten itself (3-15%, all autotune misranks between aten and decompose_k)
- 0 degraded shapes where Triton was the dk-off pick (Triton won 1 shape; +1.8% with dk on, within noise)
- fp32 within 4e-6 of aten
- compile time on offered GEMMs about 1.9x

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
Pending on MI350X (waiting for a free GPU). Lint is clean, and a CPU check of the gating shows that CUDA, gfx942 and explicit split counts are unchanged.


ghstack-source-id: 40147a2
Pull-Request: #203875
[ghstack-poisoned]
jananisriram added a commit that referenced this pull request Nov 9, 2026
On MI350X (gfx950), decompose_k beats hipBLASLt and the Triton mm template on many large-K GEMMs, but it is off on ROCm. This turns it on by default on gfx950 only (`num_decompose_k_splits=-1`, the new ROCm default, resolves to 10 splits there and 0 elsewhere).

With the default, decompose_k is offered when:
- K >= 8 * max(M, N)
- 8192 <= K <= 2M
- the unsplit GEMM has fewer than 32 output tiles of 256x256

Splits are pruned to at least 32 output tiles of 64x64 and at most 64 MiB of FP32 workspace. The bounds are in `config.rocm.decompose_k_*`.

CUDA, other ROCm archs, and any explicit `TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS` keep today's behavior.

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

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

MI350X, 241 shapes that pass the arch-gated rule before the K and tile caps. Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681). The rule above is re-scored from those measurements:
- geomean dk-on / dk-off pick: 0.967; 60 shapes >3% faster
- 5 shapes >3% slower beyond the re-timing noise of aten itself (3-15%, all autotune misranks between aten and decompose_k)
- 0 degraded shapes where Triton was the dk-off pick (Triton won 1 shape; +1.8% with dk on, within noise)
- fp32 within 4e-6 of aten
- compile time on offered GEMMs about 1.9x

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
Pending on MI350X (waiting for a free GPU). Lint is clean, and a CPU check of the gating shows that CUDA, gfx942 and explicit split counts are unchanged.


ghstack-source-id: 71885d3
Pull-Request: #203875
[ghstack-poisoned]
jananisriram added a commit that referenced this pull request Nov 11, 2026
On MI350X (gfx950), decompose_k beats hipBLASLt and the Triton mm template on many large-K GEMMs, but it is off on ROCm. This turns it on by default on gfx950 only (`num_decompose_k_splits=-1`, the new ROCm default, resolves to 10 splits there and 0 elsewhere).

With the default, decompose_k is offered when:
- K >= 8 * max(M, N)
- 8192 <= K <= 2M
- the unsplit GEMM has fewer than 32 output tiles of 256x256

Splits are pruned to at least 32 output tiles of 64x64 and at most 64 MiB of FP32 workspace. The bounds are in `config.rocm.decompose_k_*`.

CUDA, other ROCm archs, and any explicit `TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS` keep today's behavior.

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

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

MI350X, 241 shapes that pass the arch-gated rule before the K and tile caps. Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681). The rule above is re-scored from those measurements:
- geomean dk-on / dk-off pick: 0.967; 60 shapes >3% faster
- 5 shapes >3% slower beyond the re-timing noise of aten itself (3-15%, all autotune misranks between aten and decompose_k)
- 0 degraded shapes where Triton was the dk-off pick (Triton won 1 shape; +1.8% with dk on, within noise)
- fp32 within 4e-6 of aten
- compile time on offered GEMMs about 1.9x

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
Passes on MI350X (60 tests; test_lookup_table -k decompose and test_benchmarking also pass). Lint is clean, and a CPU check of the gating shows that CUDA, gfx942 and explicit split counts are unchanged.

ghstack-source-id: 3c6ebe4
Pull-Request: #203875
Comment thread torch/_inductor/config.py Resolved
Comment thread torch/_inductor/utils.py Resolved
Comment thread test/inductor/test_max_autotune.py Resolved
[ghstack-poisoned]
jananisriram added a commit that referenced this pull request Nov 12, 2026
On MI350X (gfx950), decompose_k beats hipBLASLt and the Triton mm template on many large-K GEMMs, but it is off on ROCm. This turns it on by default on gfx950 only (`num_decompose_k_splits=-1`, the new ROCm default, resolves to 10 splits there and 0 elsewhere).

With the default, decompose_k is offered when:
- K >= 8 * max(M, N)
- 8192 <= K <= 2M
- the unsplit GEMM has fewer than 32 output tiles of 256x256

Splits are pruned to at least 32 output tiles of 64x64 and at most 64 MiB of FP32 workspace. The bounds are in `config.rocm.decompose_k_*`.

CUDA, other ROCm archs, and any explicit `TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS` keep today's behavior.

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

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

MI350X, 241 shapes that pass the arch-gated rule before the K and tile caps. Ground truth is the median over 8 input allocations of summed device kernel time after a read flush (#203681). The rule above is re-scored from those measurements:
- geomean dk-on / dk-off pick: 0.967; 60 shapes >3% faster
- 5 shapes >3% slower beyond the re-timing noise of aten itself (3-15%, all autotune misranks between aten and decompose_k)
- 0 degraded shapes where Triton was the dk-off pick (Triton won 1 shape; +1.8% with dk on, within noise)
- fp32 within 4e-6 of aten
- compile time on offered GEMMs about 1.9x

Test Plan:
```
python test/inductor/test_max_autotune.py -k decompose
```
Passes on MI350X (60 tests; test_lookup_table -k decompose and test_benchmarking also pass). Lint is clean, and a CPU check of the gating shows that CUDA, gfx942 and explicit split counts are unchanged.

ghstack-source-id: a5fb432
Pull-Request: #203875
[ghstack-poisoned]
jananisriram added a commit that referenced this pull request Nov 12, 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; this PR does not add that pruning on ROCm. 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: 71cefa3
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.

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 13, 2026
@jananisriram
jananisriram marked this pull request as ready for review November 14, 2026 00:18
@pytorchgreenlight pytorchgreenlight Bot added the GL/human GreenLight marked as needing human review label Nov 14, 2026
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 14, 2026
github-actions[bot]

This comment was marked as outdated.

…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 added a commit that referenced this pull request Nov 19, 2026
…ounds; #203875 restacked, wording only

[ghstack-poisoned]
github-actions[bot]

This comment was marked as outdated.

@jananisriram jananisriram changed the title [Inductor][ROCm] Enable decompose_k by default on gfx950 [Inductor][ROCm] Enable decompose_k by default on ROCm Nov 19, 2026
@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.

github-actions[bot]

This comment was marked as outdated.

@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.

@jananisriram

Copy link
Copy Markdown
Contributor Author

@pytorchbot review

@pytorch-bot pytorch-bot Bot added in progress PR is being worked on by the author, until the automated review accepts it and removed in progress PR is being worked on by the author, until the automated review accepts it labels Dec 1, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review of fde7c86: changes requested before human review.

The PR changes the ROCm default of config.triton.num_decompose_k_splits from 0 to 10, matching CUDA, and adds a default-config case to test_max_autotune_decompose_k_envvars. Recommendation: Request Changes. The blocking point is that the PR removes the "pending performance validation" gate with no performance data, and it applies to ROCm archs that have no split bounds.

⚪ 2 non-blocking findings are attached to the code below, collapsed.

os.environ.get("TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS", "10")

🔴 Blocking (continuing from the last review): the PR removes the "pending performance validation" gate but provides no performance data for what ships. The description says "MI350X numbers for this version still need to be measured", and the earlier ~1.9x compile-time figure was dropped. On HIP, keep_triton_mm is always true (kernel/mm.py:700-706), so choices are only added: every qualifying mm under max-autotune gets up to 10 extra subgraph choices to compile and benchmark. decompose_k_split_bounds returns (0, 0) for every HIP arch except gfx950, so gfx90a, gfx942, RDNA and gfx1250 have no limit on split size. Example: fp16 M=N=4096, K=131072 gives splits [8, 16, 32], which need 512 MiB, 1 GiB and 2 GiB of FP32 workspace. The winner is picked on speed alone, so peak memory can grow. Even on gfx950 the fallback to split 8 needs 512 MiB. ciflow/rocm-mi200 is not on the PR, so gfx90a is never tested. Open question: gate this to gfx950 via config.rocm data checked in use_decompose_k_choice. Fix: measure the shipped default on at least gfx942 and gfx950 (runtime geomean, regressions, compile-time ratio, peak memory; e.g. ciflow/inductor-perf-test-nightly-rocm-mi300/-mi350), then post the results or limit the default to the archs you measured.

An earlier comment near this line has replies: #203875 (comment)

⚪ 2 non-blocking findings

os.environ.get("TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS", "10")

Non-blocking, low confidence: with the opt-in CK BLAS backend (preferred_blas_library("ck")), every decompose_k choice now fails during autotuning. The partial torch.bmm(..., out_dtype=torch.float32) (kernel/decompose_k.py:82) hits the CK-only TORCH_CHECK in aten/src/ATen/cuda/CUDABlas.cpp:827-830 / 855-858. Autotuning turns each failure into an infinite timing, so nothing crashes, but by default CK users get up to 10 log.error lines per GEMM. Fix: skip decompose_k when the preferred BLAS backend is CK.

An earlier comment near this line has replies: #203875 (comment)


os.environ.get("TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS", "10")

Non-blocking: this changes a user-visible default for every ROCm max-autotune user, and the PR has no release notes: or topic: label. Effects: longer compile time, possibly higher peak memory, and different FP32-accumulated numerics whenever a split wins. bc-guidelines.md asks for changed defaults to be documented in release notes. Fix: add the label and mention TORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS=0 as the way to restore the old behavior.

An earlier comment near this line has replies: #203875 (comment)

Please address the findings and push; a new commit normally gets a fresh automated review.

Disagree with a finding? Reply with your reasoning, then comment @pytorchbot review to request a re-review. This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

)
@parametrize("num_decompose_k_splits", (0, 5, 20))
# None keeps the default number of splits, which enables decompose_k on CUDA and ROCm
@parametrize("num_decompose_k_splits", (None, 0, 5, 20))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Non-blocking: the None case can't catch a regression in the default this PR changes.

The zero branch now follows the effective config, so if the ROCm default went back to 0 the test would take the assertEqual(decompose_count, 0) branch and still pass. With the default of 10, both shapes give the same split counts as the 20 case, so the new case adds no coverage. Fix: when the env var is unset, assert config.triton.num_decompose_k_splits &gt; 0 in the None case.

Report this finding

K // M < decompose_k_threshold
or K // N < decompose_k_threshold
or num_decompose_k_splits == 0
or config.triton.num_decompose_k_splits == 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Non-blocking: Minor: check <= 0 instead of == 0 here.

A negative env value disables decompose_k (utils.py:3528) but still takes the assertGreater branch.

Report this finding

This branch has not been deployed

No deployments
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/human GreenLight marked as needing human review in progress PR is being worked on by the author, until the automated review accepts it module: inductor module: rocm AMD GPU support for Pytorch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants