Skip to content

[ROCm] Update CK submodule to pick up the ppc64le FastGeluAsm fix - #203671

Closed
alugorey wants to merge 6 commits into
pytorch:mainfrom
ROCm:jeffdaily/ck-bump-ppc64le-fastgeluasm
Closed

alugorey wants to merge 6 commits into
pytorch:mainfrom
ROCm:jeffdaily/ck-bump-ppc64le-fastgeluasm

Conversation

@alugorey

@alugorey alugorey commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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_DEVICE overloads 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_kernel 5a74dec -> c57609f165, the fix commit itself (the oldest commit that contains it; the 11 later develop commits are gfx1250/gfx117 and CK-internal work).
  • Define USE_NEW_UNIFIED_FRAMEWORK=0 for the ck_sdpa target, AsyncMM.hip, and the ck_gemm target (for ck_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.
  • One C++ change: on device passes for targets other than gfx942/gfx950, the trap Kernel in ck_tile_group_gemm.hip is a standalone struct instead of deriving from GroupedGemmKernel. The new CK static_asserts against eight-wave CompV3 configs on gfx11/gfx12 targets (gfx1250 included) unless CK_TILE_USE_WMMA is 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.
  • Behaviour note: ck_tile UniversalGemmKernel::IsSupportedArgument now rejects operands of 2 GiB or more without LargeTensors, so symm_mem::_async_input_mm raises 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=1 on 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.

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

Also compiled ck_tile_group_gemm.hip for gfx90a, gfx942, gfx950, gfx1100, gfx1201 and gfx1250 at both hashes, and built RX 7900 (gfx1100) with USE_ROCM_CK_SDPA_GFX11=1 at 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

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

pytorch-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - 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.

Findings (3):

[minor] caffe2/CMakeLists.txt:721
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.

[minor] aten/src/ATen/native/hip/ck_tile_group_gemm.hip:123
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.

[info] aten/src/ATen/native/hip/ck_tile_group_gemm.hip:128
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().

Reviewed commit: 2d5a6f4

Review run

🐛 Report a bad review

🔗 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 Failure

As of commit 2d5a6f4 with merge base 20c4d4c (image):

NEW FAILURE - The following job has failed:

  • trunk / linux-jammy-cuda13.2-py3.11-gcc11 / test (default, 7, 14, mt-l-x86aavx2-11-41-l4) (gh)
    test/test_autograd.py::TestAutogradDeviceTypeCUDA::test_advanced_indexing_backwards_large_cuda

    AI verdict: AI verdict: probably not related

    The PR changes only ROCm-only code: a .hip trap kernel, ROCm-gated CMake definitions, and the composable_kernel submodule bump. None of it is compiled into the CUDA 13.2 build. So for CUDA, the PR head is the same as the merge base, where shard 7 passed. The failure is nondeterministic (different elements fail on each rerun), which points to a runner/GPU problem or a race, not a code regression.

    Full reasoning on HUD →

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

@pytorch-bot pytorch-bot Bot added module: rocm AMD GPU support for Pytorch topic: not user facing topic category labels Nov 5, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator

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.
@jeffdaily jeffdaily added ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request labels Nov 11, 2026
@pytorch-bot

pytorch-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@pytorch-bot

pytorch-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/trunk
  • ciflow/rocm-mi300

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.

@jeffdaily

Copy link
Copy Markdown
Collaborator

I merged viable/strict and pushed a maintainer commit, 2d5a6f4. At the new CK, the device-trap Kernel in ck_tile_group_gemm.hip (from #203715) failed to compile for gfx1100, gfx1201 and gfx1250: it derived from GroupedGemmKernel, which instantiates the CompV3 pipeline, and the new CK static_asserts against eight-wave CompV3 on wave32 targets. The trap Kernel is now a standalone struct with only kBlockSize, BlockSize() and a trapping operator(). The default CK GEMM arch list doesn't include those targets, but any build that does would break. I revalidated on MI300X, MI355X and RX 7900 at both CK hashes with identical per-test outcomes, including the fp32 grouped GEMM configs from #202073 and a gfx11 CK SDPA build, and the file now compiles for all six arches at both hashes.

@jeffdaily
jeffdaily marked this pull request as ready for review November 11, 2026 15:28
@github-actions
github-actions Bot requested a review from jeffdaily November 11, 2026 15:30
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 11, 2026
@pytorch-bot pytorch-bot Bot added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 11, 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 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

COMPILE_DEFINITIONS "USE_ROCM_ASYNC_MM;USE_NEW_UNIFIED_FRAMEWORK=0"

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() &lt; 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.


using Kernel = ck_tile::GroupedGemmKernel<TilePartitioner, GemmPipeline, GemmEpilogue>;

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.


static constexpr index_t kBlockSize = Config::M_Warp * Config::N_Warp * Config::K_Warp * 64;

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

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

This branch was previously deployed

1 inactive deployment
bedrock — 2d5a6f46 Deployed Nov 11, 2026 by jeffdaily
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request in progress PR is being worked on by the author, until the automated review accepts it Merged module: rocm AMD GPU support for Pytorch open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ROCm] USE_ROCM_CK_SDPA=1 build fails with AMD clang 23 due to FastGeluAsm in-class template specializations

4 participants