Repository navigation
Conversation
Fixes pytorch#192650. With ROCm 7.14's AMD clang 23 on ppc64le, the host compilation pass of every CK SDPA translation unit fails in CK's `FastGeluAsm` ("reference to local variable 'c1' declared in enclosing function"). Its two `CK_TILE_DEVICE` overloads hold device-only AMDGPU inline assembly that is still parsed in the host pass, where clang 23 targeting ppc64le rejects it. The fix, ROCm/rocm-libraries#11474, wraps those overloads in `__HIP_DEVICE_COMPILE__` so the host pass never sees them; it is commit c57609f165 in the ROCm/composable_kernel mirror. The current pin (5a74dec, pytorch#191245) predates it. This moves `third_party/composable_kernel` to c57609f165, the fix commit itself, which is the oldest commit containing it. The 11 develop commits after it are gfx1250/gfx117 enablement, dispatcher heuristics and CK-internal cmake changes that PyTorch does not need, so they are left out. The mirror re-split develop on 2026-08-17: 5a74dec now lives on an archive branch, and its content twin on the new develop (479b65c, an empty diff) is 162 commits behind c57609f165. PyTorch has to keep building against the old pin too, because Meta's internal build uses an older CK. The one PyTorch change is a build define. The new CK flips ck_tile's `USE_NEW_UNIFIED_FRAMEWORK` default from 0 to 1. With it on, ck_tile needs the GPU target at compile time through `CK_CMAKE_GPU_TARGET_IDS`, which only honours the first arch and so cannot describe PyTorch's multi-arch CK builds. Without it, CK falls back to the current compilation pass's target, so the host pass sees HOST while the device pass sees the real arch, and it warns about that in every CK SDPA translation unit (1124 times per build). This defines `USE_NEW_UNIFIED_FRAMEWORK=0` for the `ck_sdpa` target and for `AsyncMM.hip`, the two places PyTorch compiles ck_tile code, which keeps the WarpGemm path the old pin uses. CK only sets the default under `#ifndef` and the old pin already defaults to 0, so the define changes nothing there. The C++ APIs PyTorch uses change only additively over this range, so no SFINAE guard is needed: `fmha_fwd_args` gains a defaulted first member (PyTorch value-initializes it and assigns fields by name), `fmha_bwd_launcher::prepare_workspace_async` keeps an overload taking the old pinned-host allocator argument that aiter's mha_bwd still passes, and the ck_tile GEMM traits/epilogue templates gain defaulted parameters. The CK SDPA codegen emits the same 556 instances at both hashes. One behaviour change: ck_tile's `UniversalGemmKernel::IsSupportedArgument` now rejects operands of 2 GiB or more unless the pipeline opts into `LargeTensors`, so `symm_mem::_async_input_mm` raises its "arguments not supported by the CK tile kernel" error for such operands instead of launching with 32-bit offsets. Test Plan: The ppc64le failure cannot be reproduced on x86_64 (clang 23 there accepts the code). Containment of the fix: ``` git -C third_party/composable_kernel merge-base --is-ancestor c57609f165 HEAD ``` Built at both CK hashes on MI300X (gfx942) and MI355X (gfx950) from the same PyTorch tree (with this change applied), then ran the same tests at each hash and compared outcomes per test id: ``` python tools/amd_build/build_amd.py PYTORCH_ROCM_ARCH=gfx950 USE_ROCM_CK_SDPA=1 USE_ROCM_CK_GEMM=1 USE_FLASH_ATTENTION=1 USE_MEM_EFF_ATTENTION=1 BUILD_TEST=0 pip install -e . -v --no-build-isolation # old hash: git -C third_party/composable_kernel checkout 5a74dec07a894484b9489d0c0e00cd3b52652d18, then the same two commands python -m pytest test/test_transformers.py -k ck TORCH_ROCM_FA_PREFER_CK=1 python -m pytest test/test_transformers.py -k "TestSDPAAcceleratorCUDA and (flash or mem_eff or ck)" python -m pytest test/test_linalg.py -k "ck_blas_library or grouped_mm" python -m pytest test/test_matmul_cuda.py -k grouped python -m pytest test/distributed/test_symmetric_memory.py -k native ``` Plus a script comparing CK GEMM against hipBLAS, CK SDPA fwd/bwd against the math backend, and `symm_mem::_async_input_mm` against a reference matmul. Results were identical at the old and new hash on both arches (apart from `test_grouped_gemm_rocm_ck_flag`, which is flaky at both hashes). pytorch#200307 (CK-Tile grouped GEMM) also applies, builds and passes its tests on top of this bump. Authored with Claude.
pytorch#200307 added `ck_tile_group_gemm.hip` to the `ck_gemm` target, a third place where PyTorch compiles ck_tile code. Give it the same `USE_NEW_UNIFIED_FRAMEWORK=0` define as the `ck_sdpa` target and `AsyncMM.hip`. Authored with Claude.
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Findings (3): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203671
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 2d5a6f4 with merge base 20c4d4c ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…4le-fastgeluasm Authored with Claude.
…-bump-ppc64le-fastgeluasm
|
Holding this until I revalidate. The change at this head is what I validated on MI300X and MI355X, but #202073, #203715, #203869 and #203095 all touched CK code on main since that base, and the merge is textually clean so nothing would flag it. I'll merge viable/strict, rerun the old/new CK comparison with the new ck_tile grouped GEMM fp32 and config coverage tests plus a gfx11 CK SDPA build, then add ciflow/rocm-mi300 and ciflow/trunk so the ROCm tests run here. The dynamo-cpython-build failure is a runner credentials error and unrelated. |
On device passes for targets other than gfx942/gfx950, the trap Kernel derived from GroupedGemmKernel, which instantiates GemmPipeline. The CK this PR moves to static_asserts against eight-wave CompV3 configs on gfx11/gfx12 targets (gfx1250 included) unless CK_TILE_USE_WMMA is set, so any build that compiles ck_tile_group_gemm.hip for those targets fails. Give the trap Kernel only what kentry and the launch code need (kBlockSize, BlockSize(), a trapping operator()) so the pipeline is never instantiated there. Host code and gfx942/gfx950 device code still use GroupedGemmKernel unchanged. Test Plan: compiled ck_tile_group_gemm.hip for gfx90a, gfx942, gfx950, gfx1100, gfx1201 and gfx1250 at the old and new CK pins, with and without this change, and reran the grouped GEMM tests on MI355X. Authored with Claude.
|
|
|
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. |
|
I merged viable/strict and pushed a maintainer commit, 2d5a6f4. At the new CK, the device-trap |
There was a problem hiding this comment.
Automated review of 2d5a6f4: nothing blocking; ready for human review.
This PR moves third_party/composable_kernel to c57609f165 to pick up the ppc64le FastGeluAsm fix, sets USE_NEW_UNIFIED_FRAMEWORK=0 for the ck_sdpa, ck_gemm and AsyncMM.hip builds, and makes the device-pass trap Kernel in ck_tile_group_gemm.hip a standalone struct. Recommendation: Approve. Nothing blocks the PR, and the review labels every point it raises non-blocking.
⚪ 3 non-blocking findings
Line 721 in 2d5a6f4
Non-blocking: the size guard in torch/csrc/distributed/c10d/hip/AsyncMM.hip:274-278 is out of date after this bump. It allows up to INT32_MAX elements per operand (about 4 GiB for bf16, the only dtype the op accepts). The PR description says the new CK's IsSupportedArgument rejects operands of 2 GiB or more. So a bf16 operand with 2^30 to 2^31-1 elements passes the check, gets copied by b.contiguous(), and then fails with the vague "arguments not supported by the CK tile kernel" message. The Python gate _should_use_fused_all_gather_matmul_native checks no byte sizes. In _fused_all_gather_matmul_native_rocm, the error comes after peer copies and signal writes are queued on backend_stream, so it skips the stream rejoin and the final symm_mem.barrier(). In practice only B can reach this size (e.g. bf16 B of 32768x32768), and the path is opt-in via TORCH_SYMM_MEM_ENABLE_NATIVE_ASYNC_TP. Suggested fix: limit each operand to under 2 GiB in bytes with a specific error message, or add B.numel() * B.element_size() < 2**31 to the Python gate so these shapes fall back to the decomposed path. Either way, builds against older and newer CK would behave the same.
Non-blocking, low confidence: there's no 2 GiB check matching the new CK limit in ck_tile_group_gemm.hip:713-722. Neither those checks nor ck_tile_group_gemm_supported (GroupedBlas.cpp:750-756) limits bytes per group. They only keep sizes and leading strides within int32. The per-group arguments are built on the device, so IsSupportedArgument is never called. The bump is a good time to check whether the new CK's 2 GiB limit reflects a real 32-bit addressing limit in GroupedGemmKernel. If it does, per-group operands of 2 GiB or more could launch with no check. This gap existed before the PR, the path is opt-in (ROCM_ALLOW_GROUP_GEMM_CK_TILE, gfx942/gfx950 only), and the reviewer couldn't check it without the CK source.
Non-blocking: the hard-coded * 64 in kBlockSize has no explanation. It works because the host pass always uses the real GroupedGemmKernel::BlockSize(), so 64 keeps the trap kernel's launch bounds equal to the host launch size even on wave32 device passes. Code elsewhere uses ck_tile::get_warp_size(), which would halve those bounds on wave32 device passes. Suggested fix: add a one-line comment, e.g. "64 = host-pass warp size, matching GroupedGemmKernel::BlockSize()", so a later cleanup doesn't swap in get_warp_size().
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: trunk / linux-jammy-cuda13.2-py3.11-gcc11 / test (default, 7, 14, mt-l-x86aavx2-11-41-l4) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Linked issue or supporting maintainer
Fixes #192650
Supported by @jeffdaily
BC-breaking?
No
Summary (human written only)
Bumps CK to pick up the ppc64le FastGeluAsm build fix, keeping PyTorch buildable against both the old and new CK.
Agent details (if applicable)
Problem: with ROCm 7.14's AMD clang 23 on ppc64le, the host pass of every CK SDPA translation unit fails in CK's
FastGeluAsm(#192650).Cause: its
CK_TILE_DEVICEoverloads hold device-only AMDGPU inline assembly that the host pass still parses. Fixed upstream in ROCm/rocm-libraries#11474, which is ROCm/composable_kernel c57609f165; the current pin 5a74dec predates it.Change:
third_party/composable_kernel5a74dec -> c57609f165, the fix commit itself (the oldest commit that contains it; the 11 later develop commits are gfx1250/gfx117 and CK-internal work).USE_NEW_UNIFIED_FRAMEWORK=0for theck_sdpatarget,AsyncMM.hip, and theck_gemmtarget (forck_tile_group_gemm.hip, added by [ROCm] Added CK-Tile based Group-GEMM backend for ROCm #200307). The new CK defaults it to 1 (feat(ck-tile): Enabled the unification framework ROCm/rocm-libraries#11646), which needs a single compile-time GPU target (CK_CMAKE_GPU_TARGET_IDS, first arch only) that multi-arch builds cannot give, so CK falls back to HOST in the host pass and warns in every CK SDPA TU. 0 is the old pin's default (set under#ifndef), so builds against older CK, such as Meta's internal one, are unchanged.Kernelinck_tile_group_gemm.hipis a standalone struct instead of deriving fromGroupedGemmKernel. The new CK static_asserts against eight-wave CompV3 configs on gfx11/gfx12 targets (gfx1250 included) unlessCK_TILE_USE_WMMAis set, and deriving instantiated the pipeline, so compiling that file for those targets failed. Otherwise the CK APIs PyTorch uses (fmha_fwd_args,fmha_bwd_launcher, ck_tile GEMM traits/epilogue) change only additively over this range, and the FMHA codegen emits the same 556 instances at both hashes.UniversalGemmKernel::IsSupportedArgumentnow rejects operands of 2 GiB or more withoutLargeTensors, sosymm_mem::_async_input_mmraises its existing "not supported" error for those instead of launching.Test plan, done with Claude: the ppc64le failure cannot be reproduced on x86_64. Built with
USE_ROCM_CK_SDPA=1 USE_ROCM_CK_GEMM=1on MI300X (gfx942) and MI355X (gfx950) at the new CK hash and at 5a74dec, ran the same tests at each and compared outcomes per test id: identical at both hashes, and the CK target warning count went from 1124 to 0.Also compiled
ck_tile_group_gemm.hipfor gfx90a, gfx942, gfx950, gfx1100, gfx1201 and gfx1250 at both hashes, and built RX 7900 (gfx1100) withUSE_ROCM_CK_SDPA_GFX11=1at both hashes with identical test outcomes.#200307 (CK-Tile grouped GEMM) applies, builds and passes its tests on top of this.
cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang