Repository navigation
[Inductor][ROCm] Enable decompose_k by default on ROCm - #203875
jananisriram wants to merge 9 commits into
Conversation
[ghstack-poisoned]
PR Status: in progressPlease 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:
Findings (5): Reviewed commit: 🔗 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 ( 🟡 GREEN LIGHT - PR requires human review:
reason: 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. |
This PR needs a
|
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]
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]
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
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]
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 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
…ounds; #203875 restacked, wording only [ghstack-poisoned]
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
…ounds; #203875 restacked, wording only [ghstack-poisoned]
|
@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
[ghstack-poisoned]
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 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
[ghstack-poisoned]
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 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@pytorchbot review |
There was a problem hiding this comment.
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.
pytorch/torch/_inductor/config.py
Line 2718 in fde7c86
🔴 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
pytorch/torch/_inductor/config.py
Line 2718 in fde7c86
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)
pytorch/torch/_inductor/config.py
Line 2718 in fde7c86
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)) |
There was a problem hiding this comment.
⚪ 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.
| 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 |
There was a problem hiding this comment.
⚪ 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.
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_splitsto 10, the same as CUDA, so decompose_k is offered on all ROCm archs under the samedecompose_k_thresholdrule. SettingTORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITSstill overrides it.Test Plan:
Agent details
Drafted with an AI assistant (Claude); pending author review.
test_max_autotune_decompose_k_envvarsadds a default-config case. The zero-splits branch now reads the effectiveconfig.triton.num_decompose_k_splits, soTORCHINDUCTOR_NUM_DECOMPOSE_K_SPLITS=0in the environment doesn't break it.test_max_autotune.py -k decompose60 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