Skip to content

[ROCm] Guard CK grouped GEMM kernels on unsupported GPU targets (#203715) - #203715

Closed
geng-meta wants to merge 1 commit into
pytorch:mainfrom
geng-meta:export-D130060358
Closed

geng-meta wants to merge 1 commit into
pytorch:mainfrom
geng-meta:export-D130060358

Conversation

@geng-meta

@geng-meta geng-meta commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Fix HIP compilation of ck_tile_group_gemm.hip in builds that compile this
source for unsupported targets such as gfx1250, instead of filtering CK
GEMM architectures. Runtime checks cannot prevent CDNA-only assembly from
being instantiated during compilation.

Keep the original GroupedGemmKernel type for host compilation and supported
gfx942, gfx950, and gfx9-4-generic device targets. Use a trap stub only
for unsupported device targets. This preserves supported-target code generation
and the kernel names used by profiler-based ROCm tests.

Test Plan:

  • Full HIP translation unit compiled successfully for gfx1250.
  • gfx942/gfx950: all 62 BF16/FP16 configuration/layout cases produced assembly identical to the baseline, excluding source identifiers; symbol probes retained the exact baseline CK kernel names.
  • On-device MI300/MI350 tests have not been run.

Reviewed By: RandySheriff

Differential Revision: D130060358

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

@pytorch-bot

pytorch-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

This appears to be a diff that was exported from phabricator, but the PR author does not have sufficient permissions to run CI. @geng-meta, please do step 2 of internal wiki to get write access so you do not need to get CI approvals in the future. If you think this is a mistake, please contact the Pytorch Dev Infra team.

@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Nov 6, 2026
@pytorch-bot

pytorch-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

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

✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:

This re-review finds that ck_tile::GroupedGemmKernel is again the Kernel type
for host compilation and for gfx942/gfx950/gfx9-4-generic device compilation,
with a trap stub for other device targets, and that the earlier blocking
kernel-rename finding is fixed. Recommendation: Approve. The remaining points
are all labeled non-blocking.

Findings (3):

[minor] aten/src/ATen/native/hip/ck_tile_group_gemm.hip:123
Non-blocking: the trap stub can never run, and nothing says so. On device
targets outside the #if, CkTileGroupGemm<...>::Kernel is a different type in the
device pass (nested struct) than in the host pass (GroupedGemmKernel<...>).
make_kernel<1>(Kernel{}, ...) puts Kernel in the mangled name, so the
host-registered name does not exist in those code objects (incl. gfx90a in the
default TORCH_CK_GEMM_ARCH_LIST, and gfx1250). A launch there would fail as a
host-side launch error (likely invalid device function), not a device trap. No
impact today since host dispatch only selects gfx950/gfx942, but the
description's "trap stub for unsupported targets" is wrong. Fix: add a comment
here explaining why the guard exists (CDNA-only asm fails elsewhere), that host
dispatch makes the stub unreachable and host/device intentionally see different
types, and which lists it must stay in sync with (host dispatch :677-683,
CkTileGroupGemmConfigs specializations :163-262, GroupedBlas.cpp:805). Optional:
for a real device trap, keep one type and put the #if inside the body
(AsyncMM.hip:72-86, flash_attn/ck/launch_kernel_pt.hpp:17-36 with
CUDA_KERNEL_ASSERT).

[minor] aten/src/ATen/native/hip/ck_tile_group_gemm.hip:123
Non-blocking: the PR description still doesn't say which build fails, or that
gfx90a changes. In OSS, native/hip/ck*.hip builds into ck_gemm filtered to
TORCH_CK_GEMM_ARCH_LIST (aten/src/ATen/CMakeLists.txt:676-695,
cmake/public/utils.cmake:305-316); with the default list gfx1250 and
gfx9-4-generic never compile this file, so the failing build is presumably
internal or uses an overridden list. The default-list OSS gfx90a code object now
gets the stub instead of the full kernel  harmless, but worth one line in the
description.

[minor] aten/src/ATen/native/hip/ck_tile_group_gemm.hip:124
Non-blocking: the profiler-name tests behind the earlier blocking finding have
still not run on hardware. The description says MI300/MI350 tests haven't run,
the PR has no ciflow label, and pull.yml's ROCm job only builds. Before landing,
add ciflow/rocm-mi300 (gfx942) and ciflow/trunk (MI350/gfx950 job in
trunk.yml:383-427) so test_grouped_gemm_ck_tile_config_coverage
(test/test_linalg.py) and test_grouped_gemm_rocm_ck_flag[ck_tile]
(test/test_matmul_cuda.py) run on both.

Reviewed commit: 52e757c (NOT the current head 14241fa)

Review run

🐛 Report a bad review

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203715

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

✅ No Failures

As of commit 14241fa with merge base 3796b39 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@meta-codesync

meta-codesync Bot commented Nov 6, 2026

Copy link
Copy Markdown

@geng-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D130060358.

@geng-meta

Copy link
Copy Markdown
Contributor Author

@jeffdaily : would you please help as I saw you review the same file changes recently. Thanks!

@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 6, 2026
github-actions[bot]

This comment was marked as outdated.

@meta-codesync meta-codesync Bot changed the title [ROCm] Guard CK grouped GEMM kernels on unsupported GPU targets [ROCm] Guard CK grouped GEMM kernels on unsupported GPU targets (#203715) Nov 6, 2026
geng-meta added a commit to geng-meta/pytorch that referenced this pull request Nov 6, 2026
…rch#203715)

Summary:

Fix HIP compilation of `ck_tile_group_gemm.hip` in builds that compile this
source for unsupported targets such as `gfx1250`, instead of filtering CK
GEMM architectures. Runtime checks cannot prevent CDNA-only assembly from
being instantiated during compilation.

Keep the original `GroupedGemmKernel` type for host compilation and supported
`gfx942`, `gfx950`, and `gfx9-4-generic` device targets. Use a trap stub only
for unsupported device targets. This preserves supported-target code generation
and the kernel names used by profiler-based ROCm tests.

Test Plan:
- Full HIP translation unit compiled successfully for `gfx1250`.
- `gfx942`/`gfx950`: all 62 BF16/FP16 configuration/layout cases produced assembly identical to the baseline, excluding source identifiers; symbol probes retained the exact baseline CK kernel names.
- On-device MI300/MI350 tests have not been run.

Differential Revision: D130060358

@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 52e757c: nothing blocking; ready for human review.

This re-review finds that ck_tile::GroupedGemmKernel is again the Kernel type for host compilation and for gfx942/gfx950/gfx9-4-generic device compilation, with a trap stub for other device targets, and that the earlier blocking kernel-rename finding is fixed. Recommendation: Approve. The remaining points are all labeled non-blocking.

⚪ 3 non-blocking findings

#if !defined(__HIP_DEVICE_COMPILE__) || defined(__gfx942__) || defined(__gfx950__) || defined(__gfx9_4_generic__)

Non-blocking: the trap stub can never run, and nothing says so. On device targets outside the #if, CkTileGroupGemm<...>::Kernel is a different type in the device pass (nested struct) than in the host pass (GroupedGemmKernel<...>). make_kernel<1>(Kernel{}, ...) puts Kernel in the mangled name, so the host-registered name does not exist in those code objects (incl. gfx90a in the default TORCH_CK_GEMM_ARCH_LIST, and gfx1250). A launch there would fail as a host-side launch error (likely invalid device function), not a device trap. No impact today since host dispatch only selects gfx950/gfx942, but the description's "trap stub for unsupported targets" is wrong. Fix: add a comment here explaining why the guard exists (CDNA-only asm fails elsewhere), that host dispatch makes the stub unreachable and host/device intentionally see different types, and which lists it must stay in sync with (host dispatch :677-683, CkTileGroupGemmConfigs specializations :163-262, GroupedBlas.cpp:805). Optional: for a real device trap, keep one type and put the #if inside the body (AsyncMM.hip:72-86, flash_attn/ck/launch_kernel_pt.hpp:17-36 with CUDA_KERNEL_ASSERT).


#if !defined(__HIP_DEVICE_COMPILE__) || defined(__gfx942__) || defined(__gfx950__) || defined(__gfx9_4_generic__)

Non-blocking: the PR description still doesn't say which build fails, or that gfx90a changes. In OSS, native/hip/ck*.hip builds into ck_gemm filtered to TORCH_CK_GEMM_ARCH_LIST (aten/src/ATen/CMakeLists.txt:676-695, cmake/public/utils.cmake:305-316); with the default list gfx1250 and gfx9-4-generic never compile this file, so the failing build is presumably internal or uses an overridden list. The default-list OSS gfx90a code object now gets the stub instead of the full kernel harmless, but worth one line in the description.


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

Non-blocking: the profiler-name tests behind the earlier blocking finding have still not run on hardware. The description says MI300/MI350 tests haven't run, the PR has no ciflow label, and pull.yml's ROCm job only builds. Before landing, add ciflow/rocm-mi300 (gfx942) and ciflow/trunk (MI350/gfx950 job in trunk.yml:383-427) so test_grouped_gemm_ck_tile_config_coverage (test/test_linalg.py) and test_grouped_gemm_rocm_ck_flag[ck_tile] (test/test_matmul_cuda.py) run on both.

This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

@github-actions
github-actions Bot dismissed their stale review November 6, 2026 03:14

Withdrawn: the automated review of 52e757c found nothing blocking.

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 6, 2026
@jeffdaily jeffdaily added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 9, 2026
…rch#203715)

Summary:

Fix HIP compilation of `ck_tile_group_gemm.hip` in builds that compile this
source for unsupported targets such as `gfx1250`, instead of filtering CK
GEMM architectures. Runtime checks cannot prevent CDNA-only assembly from
being instantiated during compilation.

Keep the original `GroupedGemmKernel` type for host compilation and supported
`gfx942`, `gfx950`, and `gfx9-4-generic` device targets. Use a trap stub only
for unsupported device targets. This preserves supported-target code generation
and the kernel names used by profiler-based ROCm tests.

Test Plan:
- Full HIP translation unit compiled successfully for `gfx1250`.
- `gfx942`/`gfx950`: all 62 BF16/FP16 configuration/layout cases produced assembly identical to the baseline, excluding source identifiers; symbol probes retained the exact baseline CK kernel names.
- On-device MI300/MI350 tests have not been run.

Reviewed By: RandySheriff

Differential Revision: D130060358
@pytorch-bot

pytorch-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

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

@meta-codesync

meta-codesync Bot commented Nov 10, 2026

Copy link
Copy Markdown

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Adding the topic: not user facing label automatically: this co-dev PR is being merged after its internal diff landed, without a release-notes label. If this change is user facing, please replace the label with the appropriate release notes: ... one.

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged meta-exported module: rocm AMD GPU support for Pytorch ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants