Repository navigation
[ROCm] Drop CK GEMM instances with K1 >= 32 on pre-gfx950 targets - #203869
pablo-garay wants to merge 3 commits into
Conversation
CK's GridwiseGemmMultiD_xdl_cshuffle_v3::IsValidCompilationParameter returns false for AK1 >= 32 or BK1 >= 32 unless the device pass is gfx950, so on gfx942 those instances compile to an empty kernel body. The host-side IsSupportedArgument does not check this, so the instance launches, returns success, and never writes the output. Being empty, it also benchmarks as the fastest choice and wins autotuning. The CK fp8 library offers 57 such instances for the RCR layout (and 43 with K1 = 16), so on MI300 TestCKRowwiseScaleCUDA.test_singleton_column_scale selects one and returns whatever was in the output buffer: zeros under AOTI, stale data (up to ~4e11) under JIT. The mismatch is bit-identical across reruns that picked different instances, which is what an unwritten output looks like. MI350 (gfx950) builds the kernel body and passes. Filter these instances in CKGemmTemplate.filter_op using the same condition CK uses, so autotuning only sees instances that do work on the device. Test Plan: ``` ruff check torch/_inductor/codegen/rocm/ck_universal_gemm_template.py ruff format --diff torch/_inductor/codegen/rocm/ck_universal_gemm_template.py ``` Not run on a GPU; the MI300 regression is PYTORCH_TEST_WITH_ROCM=1 python test/inductor/test_ck_backend.py TestCKRowwiseScaleCUDA Signed-off-by: Pablo Garay <[email protected]>
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203869
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 Cancelled Jobs, 1 Unrelated FailureAs of commit 8be9e24 with merge base 557419b ( 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:
CANCELLED JOBS - The following jobs were cancelled. Please retry:
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. |
The K1 >= 32 filter compared only the current device's arch. Inductor compiles CK kernels for config.rocm.arch when it is set (AOTI packaging, cross-compiling for gfx942 on a gfx950 host, or a multi-arch list), so the empty-body instances could still be selected for a non-gfx950 target. Derive the targets the same way compile_command.py does and keep K1 >= 32 instances only when every target is gfx950. Authored with Claude.
|
I pushed a small follow-up commit (91e6671) on top of yours so the filter also covers cross-compiles. My agent came up with this analysis, but I've read and approved it.
|
inductor's set linter rejects builtin sets. Same logic: drop K1 >= 32 instances when any compile target is not gfx950. Authored with Claude.
|
@pytorchbot merge -i |
Merge failedReason: This PR needs a If not, please add the To add a label, you can comment to pytorchbot, for example For more information, see Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 3 checks: Lint / Test collect_env (older_python_version, linux.24_04.4x), Lint / Test collect_env (without_torch, linux.24_04.4x), Lint / Test collect_env (with_torch, linux.24_04.4x) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
spin fixlint)Linked issue or supporting maintainer
Supported by @jeffdaily
Tracking issues: https://github.com/jithunnair-amd/sandbox/issues/11439, https://github.com/jithunnair-amd/sandbox/issues/11440, https://github.com/jithunnair-amd/sandbox/issues/11441, https://github.com/jithunnair-amd/sandbox/issues/11442
BC-breaking?
No
Summary (human written only)
Fix
TestCKRowwiseScaleCUDA.test_singleton_column_scaleon MI300: CK compiles GEMM instances withAK1/BK1 >= 32to an empty kernel body on anything but gfx950, but itsIsSupportedArgumentstill accepts them, so on gfx942 they launch without writing the output, benchmark as fastest and win autotuning. Filter them out inCKGemmTemplate.filter_opwith the same condition CK uses.Agent details (if applicable)
The root-cause analysis (CI logs plus CK source at the pinned commit
e2daf44), the code change and this description were drafted with an AI agent. The evidence is that on MI300 the mismatch is bit-identical across reruns that selected different CK instances (max abs diff 388694540288.0 at (359, 2099) under JIT, and an all-zero output under AOTI). That points to an output that is never written, not to a numerical error.GridwiseGemmMultiD_xdl_cshuffle_v3::IsValidCompilationParameterreturns false forK1 >= 32when__gfx950__is not defined, and the pinned fp8 RCR library has 57K1=32and 43K1=16instances, so gfx942 keeps 43 candidates. Onlyruff checkandruff formatwere run on the changed file. This was not run on a GPU.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