Skip to content

[ROCm] Added CK-Tile based Group-GEMM backend for ROCm - #200307

Closed
TheRealMichaelWang wants to merge 27 commits into
pytorch:mainfrom
ROCm:mwang105-add-cktile-groupgemm
Closed

TheRealMichaelWang wants to merge 27 commits into
pytorch:mainfrom
ROCm:mwang105-add-cktile-groupgemm

Conversation

@TheRealMichaelWang

@TheRealMichaelWang TheRealMichaelWang commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue or supporting maintainer

Supported by @jeffdaily

This PR adds a minimal CK-Tile based group GEMM backend, that can be enabled via the env var flag ROCM_ALLOW_GROUP_GEMM_CK_TILE. Note that this is the first PR in a series of more PRs that will gradually add more capability, support, performance, etc... The goal of this PR is just to get things to a working state.

Currently in this implementation:

  • The only data types supported are fp16 and bf16. float32 will be added in later PRs
  • Primarily tested on gfx942 and gfx950 (mi300 and mi355x).

Follow-up (not in this PR): In the future add support to have _grouped_mm_cuda respect torch.backends.cuda.preferred_blas_library("ck"), using ck_tile where supported and falling back otherwise. Once the old CK grouped gemm kernel replaced/removed, remove the ROCM_ALLOW_GROUP_GEMM_CK / ROCM_ALLOW_GROUP_GEMM_CK_TILE env vars.

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

@pytorch-bot pytorch-bot Bot added ciflow/b200 ciflow/h100 ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 module: rocm AMD GPU support for Pytorch labels Oct 8, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

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/200307

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 46841fc with merge base adc4a41 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@pytorch-bot

pytorch-bot Bot commented Oct 8, 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 Oct 8, 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/rocm-mi300
  • ciflow/h100
  • ciflow/b200

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.

@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot missing actionable issue A PR without a linked actionable issue or maintainer sponsor triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Oct 8, 2026
@TheRealMichaelWang TheRealMichaelWang changed the title Added CK-Tile based Group-GEMM backend for ROCm [ROCm] Added CK-Tile based Group-GEMM backend for ROCm Oct 8, 2026
@TheRealMichaelWang
TheRealMichaelWang marked this pull request as draft October 8, 2026 19:28
@TheRealMichaelWang

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Oct 12, 2026
@TheRealMichaelWang
TheRealMichaelWang marked this pull request as ready for review October 12, 2026 16:54

@jeffdaily jeffdaily left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My agent came up with this analysis, but I've read and approved it.

  1. Odd N (column-major B in 2D/3D or 3D/3D) and jagged N (3D/2D) select Cfg16_256x128x64_Pad, whose 2-wide C store at a row's or group's last column writes into the neighbor's first column. Commit 40f1701 fixed this and was reverted; please restore that fix.
  2. Please restore the numerics tests reverted in 24aec87 (all 4 ops, both layouts, configs, empty groups, K=0) plus the odd-N test. The remaining test only checks the kernel name.
  3. With ROCM_ALLOW_GROUP_GEMM_CK_TILE=1, fp32 inputs, >1024 groups, mixed dtypes and misaligned dims now raise instead of using group_gemm_ck or _grouped_mm_fallback, and since ck_tile is checked first this also breaks fp32 users who set both flags. Gate the dispatch in GroupedBlas.cpp on a supported-inputs check and fall through otherwise. Please also add benchmark numbers against the default path.

@slayton58

Copy link
Copy Markdown
Contributor

Question: Why is this wanted? Is this intended to replace another backend? Add new functionality? I'm asking to make sure we actually want to add another optional backend, rather than just shift over to a new one for supported cases and slowly move out the old..

@TheRealMichaelWang

Copy link
Copy Markdown
Contributor Author

Question: Why is this wanted? Is this intended to replace another backend? Add new functionality? I'm asking to make sure we actually want to add another optional backend, rather than just shift over to a new one for supported cases and slowly move out the old..

Hi slayton58! The addition of the CK-Tile backend for grouped GEMM is ultimately meant to supplant/replace the current CK-Tile backend. The CK-Tile backend currently outperforms the default backend on a shapes that are smaller than a certain threshold (dependent on GPU), and the eventual goal is to use a heuristic to decide when to dispatch the CK-Tile backend or not for grouped GEMM.

This PR, for now, adds the CK-Tile backend as an extra backend for grouped gemm. This is a first step, just meant to get the functionality there. There will be more PRs in the future.

@slayton58

Copy link
Copy Markdown
Contributor

Can we use a BlasBackend, along with the existing selector in torch.backends.cuda.*? That'll be cleaner than an env variable

TheRealMichaelWang and others added 6 commits October 20, 2026 22:10
…for ATen and caffe2 to not build ck-tile group gemm for architectures that ck-tile doesn't supportt
…d CMake for ATen and caffe2 to not build ck-tile group gemm for architectures that ck-tile doesn't supportt"

This reverts commit 9b6cc17.
…rrors when users use old ck-tile versions without the new tempalte overloads
@TheRealMichaelWang
TheRealMichaelWang force-pushed the mwang105-add-cktile-groupgemm branch from 3cebb7a to 32d0d1c Compare October 20, 2026 22:10
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -f "all UTs passing except Meta internal which we got approval on slack from slayton58 to try the merge again"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

jeffdaily added a commit to ROCm/pytorch that referenced this pull request Oct 26, 2026
Resolve the conflict with pytorch#200307 in gemm_internal_ck<BFloat16> and gemm_internal_ck<Half>: keep main's supported_archs check and this branch's bool return from the gfx9 dispatch.

Authored with Claude.
jeffdaily added a commit to ROCm/pytorch that referenced this pull request Oct 30, 2026
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.
pytorchmergebot pushed a commit that referenced this pull request Nov 2, 2026
…p-Gemm Backend (#200640)

This PR adds config structs for each input and output type and platform combination. Each config struct stores kernel configs (things like M, N, K output tile size, the MFMA M, K, N sizes, etc...) for the CK-Tile group GEMM backend. This PR builds on top of #200307
- Only configs for bf16/fp16 on the mi300 and mi350 will be added in this PR. Support for fp32 on mi300 and mi350 will be added in subsequent PRs
- PR adds support for a load-cost heuristic that is used to select configs for CK-Tile
- Additionally performance work was done to bring CK-Tile group gemm performance back to where it was on ROCm 7.2.0.
  - For more details on the 7.2.0 regression see AIPYTORCH-1471 on amd jira.
  - To be clear the regression was only known to happen for bf16 on the mi350.

### Linked issue or supporting maintainer
Supported by @jeffdaily

Also tracked internally at AMD (AIPYTORCH-1471): CK-Tile grouped GEMM lost performance on MI350 (gfx950) going from ROCm 7.2.0 to ROCm 10.1.

### Performance
`F.grouped_mm` 2D x 3D over 396 MoE shapes, CK-Tile at this PR vs its merge base, and vs the default path (the per-group hipBLASLt loop); geomean speedups, median of 50, every row checked against the default path's output and gradients (measured at 9b613f0; later commits only change tests and comments):

| arch | dtype | fwd vs merge base | bwd vs merge base | fwd vs default | bwd vs default |
|---|---|---|---|---|---|
| MI355X | bf16 | 1.21x | 1.39x | 1.06x | 0.98x |
| MI355X | fp16 | 1.18x | 1.34x | 1.07x | 0.99x |
| MI300X | bf16 | 1.30x | 1.02x | 1.12x | 0.85x |
| MI300X | fp16 | 1.27x | 1.02x | 1.10x | 0.93x |

No row is more than 4% slower than the merge base. On MI300X, backward is essentially unchanged and still trails the default path on most shapes.

Pull Request resolved: #200640
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
pytorchmergebot pushed a commit that referenced this pull request Nov 4, 2026
…p-Gemm Backend (#200640)

This PR adds config structs for each input and output type and platform combination. Each config struct stores kernel configs (things like M, N, K output tile size, the MFMA M, K, N sizes, etc...) for the CK-Tile group GEMM backend. This PR builds on top of #200307
- Only configs for bf16/fp16 on the mi300 and mi350 will be added in this PR. Support for fp32 on mi300 and mi350 will be added in subsequent PRs
- PR adds support for a load-cost heuristic that is used to select configs for CK-Tile
- Additionally performance work was done to bring CK-Tile group gemm performance back to where it was on ROCm 7.2.0.
  - For more details on the 7.2.0 regression see AIPYTORCH-1471 on amd jira.
  - To be clear the regression was only known to happen for bf16 on the mi350.

### Linked issue or supporting maintainer
Supported by @jeffdaily

Also tracked internally at AMD (AIPYTORCH-1471): CK-Tile grouped GEMM lost performance on MI350 (gfx950) going from ROCm 7.2.0 to ROCm 10.1.

### Performance
`F.grouped_mm` 2D x 3D over 396 MoE shapes, CK-Tile at this PR vs its merge base, and vs the default path (the per-group hipBLASLt loop); geomean speedups, median of 50, every row checked against the default path's output and gradients (measured at 9b613f0; later commits only change tests and comments):

| arch | dtype | fwd vs merge base | bwd vs merge base | fwd vs default | bwd vs default |
|---|---|---|---|---|---|
| MI355X | bf16 | 1.21x | 1.39x | 1.06x | 0.98x |
| MI355X | fp16 | 1.18x | 1.34x | 1.07x | 0.99x |
| MI300X | bf16 | 1.30x | 1.02x | 1.12x | 0.85x |
| MI300X | fp16 | 1.27x | 1.02x | 1.10x | 0.93x |

No row is more than 4% slower than the merge base. On MI300X, backward is essentially unchanged and still trails the default path on most shapes.

@diff-train-skip-merge

Pull Request resolved: #200640
Approved by: https://github.com/slayton58

Co-authored-by: Jeff Daily <[email protected]>
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…p-Gemm Backend (pytorch#200640)

This PR adds config structs for each input and output type and platform combination. Each config struct stores kernel configs (things like M, N, K output tile size, the MFMA M, K, N sizes, etc...) for the CK-Tile group GEMM backend. This PR builds on top of pytorch#200307
- Only configs for bf16/fp16 on the mi300 and mi350 will be added in this PR. Support for fp32 on mi300 and mi350 will be added in subsequent PRs
- PR adds support for a load-cost heuristic that is used to select configs for CK-Tile
- Additionally performance work was done to bring CK-Tile group gemm performance back to where it was on ROCm 7.2.0.
  - For more details on the 7.2.0 regression see AIPYTORCH-1471 on amd jira.
  - To be clear the regression was only known to happen for bf16 on the mi350.

### Linked issue or supporting maintainer
Supported by @jeffdaily

Also tracked internally at AMD (AIPYTORCH-1471): CK-Tile grouped GEMM lost performance on MI350 (gfx950) going from ROCm 7.2.0 to ROCm 10.1.

### Performance
`F.grouped_mm` 2D x 3D over 396 MoE shapes, CK-Tile at this PR vs its merge base, and vs the default path (the per-group hipBLASLt loop); geomean speedups, median of 50, every row checked against the default path's output and gradients (measured at 9b613f0; later commits only change tests and comments):

| arch | dtype | fwd vs merge base | bwd vs merge base | fwd vs default | bwd vs default |
|---|---|---|---|---|---|
| MI355X | bf16 | 1.21x | 1.39x | 1.06x | 0.98x |
| MI355X | fp16 | 1.18x | 1.34x | 1.07x | 0.99x |
| MI300X | bf16 | 1.30x | 1.02x | 1.12x | 0.85x |
| MI300X | fp16 | 1.27x | 1.02x | 1.10x | 0.93x |

No row is more than 4% slower than the merge base. On MI300X, backward is essentially unchanged and still trails the default path on most shapes.

Pull Request resolved: pytorch#200640
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…p-Gemm Backend (pytorch#200640)

This PR adds config structs for each input and output type and platform combination. Each config struct stores kernel configs (things like M, N, K output tile size, the MFMA M, K, N sizes, etc...) for the CK-Tile group GEMM backend. This PR builds on top of pytorch#200307
- Only configs for bf16/fp16 on the mi300 and mi350 will be added in this PR. Support for fp32 on mi300 and mi350 will be added in subsequent PRs
- PR adds support for a load-cost heuristic that is used to select configs for CK-Tile
- Additionally performance work was done to bring CK-Tile group gemm performance back to where it was on ROCm 7.2.0.
  - For more details on the 7.2.0 regression see AIPYTORCH-1471 on amd jira.
  - To be clear the regression was only known to happen for bf16 on the mi350.

### Linked issue or supporting maintainer
Supported by @jeffdaily

Also tracked internally at AMD (AIPYTORCH-1471): CK-Tile grouped GEMM lost performance on MI350 (gfx950) going from ROCm 7.2.0 to ROCm 10.1.

### Performance
`F.grouped_mm` 2D x 3D over 396 MoE shapes, CK-Tile at this PR vs its merge base, and vs the default path (the per-group hipBLASLt loop); geomean speedups, median of 50, every row checked against the default path's output and gradients (measured at 9b613f0; later commits only change tests and comments):

| arch | dtype | fwd vs merge base | bwd vs merge base | fwd vs default | bwd vs default |
|---|---|---|---|---|---|
| MI355X | bf16 | 1.21x | 1.39x | 1.06x | 0.98x |
| MI355X | fp16 | 1.18x | 1.34x | 1.07x | 0.99x |
| MI300X | bf16 | 1.30x | 1.02x | 1.12x | 0.85x |
| MI300X | fp16 | 1.27x | 1.02x | 1.10x | 0.93x |

No row is more than 4% slower than the merge base. On MI300X, backward is essentially unchanged and still trails the default path on most shapes.

@diff-train-skip-merge

Pull Request resolved: pytorch#200640
Approved by: https://github.com/slayton58

Co-authored-by: Jeff Daily <[email protected]>
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…p-Gemm Backend (pytorch#200640)

This PR adds config structs for each input and output type and platform combination. Each config struct stores kernel configs (things like M, N, K output tile size, the MFMA M, K, N sizes, etc...) for the CK-Tile group GEMM backend. This PR builds on top of pytorch#200307
- Only configs for bf16/fp16 on the mi300 and mi350 will be added in this PR. Support for fp32 on mi300 and mi350 will be added in subsequent PRs
- PR adds support for a load-cost heuristic that is used to select configs for CK-Tile
- Additionally performance work was done to bring CK-Tile group gemm performance back to where it was on ROCm 7.2.0.
  - For more details on the 7.2.0 regression see AIPYTORCH-1471 on amd jira.
  - To be clear the regression was only known to happen for bf16 on the mi350.

### Linked issue or supporting maintainer
Supported by @jeffdaily

Also tracked internally at AMD (AIPYTORCH-1471): CK-Tile grouped GEMM lost performance on MI350 (gfx950) going from ROCm 7.2.0 to ROCm 10.1.

### Performance
`F.grouped_mm` 2D x 3D over 396 MoE shapes, CK-Tile at this PR vs its merge base, and vs the default path (the per-group hipBLASLt loop); geomean speedups, median of 50, every row checked against the default path's output and gradients (measured at 9b613f0; later commits only change tests and comments):

| arch | dtype | fwd vs merge base | bwd vs merge base | fwd vs default | bwd vs default |
|---|---|---|---|---|---|
| MI355X | bf16 | 1.21x | 1.39x | 1.06x | 0.98x |
| MI355X | fp16 | 1.18x | 1.34x | 1.07x | 0.99x |
| MI300X | bf16 | 1.30x | 1.02x | 1.12x | 0.85x |
| MI300X | fp16 | 1.27x | 1.02x | 1.10x | 0.93x |

No row is more than 4% slower than the merge base. On MI300X, backward is essentially unchanged and still trails the default path on most shapes.

Pull Request resolved: pytorch#200640
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…p-Gemm Backend (pytorch#200640)

This PR adds config structs for each input and output type and platform combination. Each config struct stores kernel configs (things like M, N, K output tile size, the MFMA M, K, N sizes, etc...) for the CK-Tile group GEMM backend. This PR builds on top of pytorch#200307
- Only configs for bf16/fp16 on the mi300 and mi350 will be added in this PR. Support for fp32 on mi300 and mi350 will be added in subsequent PRs
- PR adds support for a load-cost heuristic that is used to select configs for CK-Tile
- Additionally performance work was done to bring CK-Tile group gemm performance back to where it was on ROCm 7.2.0.
  - For more details on the 7.2.0 regression see AIPYTORCH-1471 on amd jira.
  - To be clear the regression was only known to happen for bf16 on the mi350.

### Linked issue or supporting maintainer
Supported by @jeffdaily

Also tracked internally at AMD (AIPYTORCH-1471): CK-Tile grouped GEMM lost performance on MI350 (gfx950) going from ROCm 7.2.0 to ROCm 10.1.

### Performance
`F.grouped_mm` 2D x 3D over 396 MoE shapes, CK-Tile at this PR vs its merge base, and vs the default path (the per-group hipBLASLt loop); geomean speedups, median of 50, every row checked against the default path's output and gradients (measured at 9b613f0; later commits only change tests and comments):

| arch | dtype | fwd vs merge base | bwd vs merge base | fwd vs default | bwd vs default |
|---|---|---|---|---|---|
| MI355X | bf16 | 1.21x | 1.39x | 1.06x | 0.98x |
| MI355X | fp16 | 1.18x | 1.34x | 1.07x | 0.99x |
| MI300X | bf16 | 1.30x | 1.02x | 1.12x | 0.85x |
| MI300X | fp16 | 1.27x | 1.02x | 1.10x | 0.93x |

No row is more than 4% slower than the merge base. On MI300X, backward is essentially unchanged and still trails the default path on most shapes.

@diff-train-skip-merge

Pull Request resolved: pytorch#200640
Approved by: https://github.com/slayton58

Co-authored-by: Jeff Daily <[email protected]>
pragupta pushed a commit to ROCm/pytorch that referenced this pull request Nov 9, 2026
…llow-list (#3979)

Backport of the CK GEMM single-source allow-list to release/2.13.
Replaces the gfx1250 blacklist (list(REMOVE_ITEM ... gfx1250
gfx1250-strict)) with a single CMake cache variable
TORCH_CK_GEMM_ARCH_LIST (default gfx90a;gfx942;gfx950) that drives the
ck_gemm build arch filter (torch_filter_ck_gemm_arches) and is surfaced
to C++ via a generated ATen/ROCmCKGEMMConfig.h header.

release/2.13 predates the CK SDPA/GEMM gating split (upstream pytorch#187267)
and had no ckGemmSupported() -- only a combined ckSupported(). This adds
Context::ckGemmSupported() (parsing TORCH_CK_GEMM_ARCH_LIST via a shared
parseArchList helper) and routes the CK blas-backend gate through it,
leaving the CK SDPA / flash-attention gates on ckSupported(). The
ck_gemm_{half,bfloat16}.hip dispatch calls
at::globalContext().ckGemmSupported() instead of an isGPUArch({"gfx9"})
prefix check. TORCH_CK_GEMM_ARCH_LIST is forwarded from the environment
via cmake/EnvVarForwarding.cmake.

Squashed backport of upstream pytorch/pytorch pytorch#200307 (base allow-list)
and pytorch#201113 (TORCH_CK_GEMM_ARCH_LIST consolidation).

Once these are merged need to revert
ROCm/TheRock#9414

Co-authored-by: Claude Opus 4.8 <[email protected]>
pragupta pushed a commit to ROCm/pytorch that referenced this pull request Nov 9, 2026
…llow-list (#3980)

Backport of the CK GEMM single-source allow-list to release/2.14.
Replaces the gfx1250 blacklist (list(REMOVE_ITEM ... gfx1250
gfx1250-strict)) with a single CMake cache variable
TORCH_CK_GEMM_ARCH_LIST (default gfx90a;gfx942;gfx950) that drives the
ck_gemm build arch filter (torch_filter_ck_gemm_arches) and is surfaced
to C++ via a generated ATen/ROCmCKGEMMConfig.h header.
Context::ckGemmSupported() parses that list (shared parseArchList
helper) and the ck_gemm_{half,bfloat16}.hip dispatch calls
at::globalContext().ckGemmSupported() instead of an isGPUArch({"gfx9"})
prefix check. TORCH_CK_GEMM_ARCH_LIST is forwarded from the environment
via cmake/EnvVarForwarding.cmake.

Squashed backport of upstream pytorch/pytorch pytorch#200307 (base allow-list)
and pytorch#201113 (TORCH_CK_GEMM_ARCH_LIST consolidation).

Once these are merged need to revert
ROCm/TheRock#9414

Co-authored-by: Claude Opus 4.8 <[email protected]>
pytorchmergebot pushed a commit that referenced this pull request Nov 11, 2026
…03671)

## 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 #200307). The new CK defaults it to 1 (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.

Pull Request resolved: #203671
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
majing921201 pushed a commit to majing921201/pytorch that referenced this pull request Nov 16, 2026
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 ci-no-td Do not run TD on this PR ciflow/b200 ciflow/h100 ciflow/inductor-rocm-mi300 Trigger "inductor" config CI on ROCm MI300/MI325 ciflow/periodic-rocm-mi300 Trigger "distributed" config CI on ROCm MI300/MI325 ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request Merged missing actionable issue A PR without a linked actionable issue or maintainer sponsor module: rocm AMD GPU support for Pytorch open source Reverted 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.

7 participants