Skip to content

[ROCm] Add support for fp32 configs for CK-Tile Group GEMM backend - #202073

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

TheRealMichaelWang wants to merge 9 commits into
pytorch:mainfrom
ROCm:mwang105-add-cktile-groupgemm-fp32-support

Conversation

@TheRealMichaelWang

@TheRealMichaelWang TheRealMichaelWang commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Add tuned configs for fp32 on gfx950 and gfx942 for the group gemm CK-tile backend. This PR does not add support for mixed input types for ck-tile group GEMM, and will be added later in another PR.

Supported by @jeffdaily

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 release notes: linalg_frontend release notes category labels Oct 26, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 26, 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:

The PR adds fp32 CK-tile grouped GEMM tile configs for gfx950 and gfx942, sends
kFloat through ck_tile_group_gemm_supported and with_ck_type, and extends the
ROCm grouped_mm correctness and config-coverage tests to fp32. Recommendation:
Approve. Nothing blocks: jeffdaily's requested test fixes are in, he agreed to
defer the earlier blocking point, and the remaining points are all non-blocking
clean-ups.

Findings (4):

[minor] aten/src/ATen/native/cuda/GroupedBlas.cpp:741
Non-blocking: fp32 ignores the TF32 / `fp32_precision` setting. Nothing under
`aten/src/ATen/native/hip/` reads it. Before this PR, fp32 grouped_mm always
took `_grouped_mm_fallback`, which goes through `at::mm_out`/`bmm_out` to
hipBLASLt. That path sets `CUBLAS_COMPUTE_32F_FAST_TF32` when precision is TF32
(`CublasLtUtils.h:328-332`, no `USE_ROCM` guard). So a user who sets
`ROCM_ALLOW_GROUP_GEMM_CK_TILE=1` and opts into TF32 now gets IEEE fp32 on
aligned shapes. This is confirmed for gfx942 (see the XF32 handling in
`Blas.cpp:121-134`). On gfx950 it depends on hipBLASLt's xf32 support. The tests
force `allow_tf32 = False`, so they cannot catch it. Fix: return false from
`ck_tile_group_gemm_supported` for `kFloat` when TF32 is requested, or document
the difference.

[minor] aten/src/ATen/native/hip/ck_tile_group_gemm.hip:200
Non-blocking: the gfx950 fp32 rationale contradicts the gfx942 configs. The
comment says "four-wave tiles with 256 rows or columns spill at K_Tile 32", and
the reason it gives doesn't depend on the arch (fp32 fragments take twice the
registers). Yet gfx942 fp32 Forward ships exactly that shape:
`CkTileGroupGemmConfig<256, 128, 32, 16, 16, 16, 2, 2, ...>` (:299), and both
arches have the same register budget. Either say this was measured on gfx950
only, or reconcile the two. Whether either tile actually spills can't be checked
without a build.

[minor] test/test_linalg.py:12462
Non-blocking: the fp32 tolerance comment overstates how tight it is (repeated at
:12491). `tol(atol=1e-4, rtol=1e-5)` is about 10x the default fp32 atol and
about 7.7x the default rtol, not "up to 2x the rounding error". The "on long K"
reason conflicts with "Contractions stay small" (:12305); the longest
contraction that reaches ck_tile is 224. The override also covers fp32 cases
that go to hipBLASLt. Fix the comment, or apply the tolerance per case as
`2d_3d_sparse_decode` does (:12294).

[minor] test/test_linalg.py:12318
Non-blocking: the tail-path comment no longer holds for fp32
(test/test_linalg.py:12303-12307). It says "eight-wave configs see 1 to 7 K
tiles", which covers the one-tile Odd tail of `FourWaveTailCompV3`. The new
K_Tile-16 eight-wave forward/dX configs only ever see 2 to 8 K tiles, so that
path never runs for them. These are gfx950 RC 256x256x16, RR 256x128x16 and RR
128x128x16, and gfx942 RR 128x128x16 and RR 256x128x16. The gfx942 `CR
128x128x16 8w --K` dW config also sees 2 to 14 tiles, never 1. Fix: add a case
with a contraction of 16, or narrow the comment to the K_Tile-32 configs.

Reviewed commit: 6ba0475

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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

❌ 2 Cancelled Jobs, 2 Unrelated Failures, 1 Unclassified Failure

As of commit 6ba0475 with merge base aa6d3e9 (image):

NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following jobs failed, but the AI CI Advisor judged the failures not to be evidence against this change:

  • Lint / Test collect_env (older_python_version, linux.24_04.4x) (gh)
    ##[error]The version '3.8' with architecture 'x64' was not found for Ubuntu 26.04.

    AI verdict: AI verdict: infra issue

    The suspect commit only changes test/test_linalg.py. The job failed in actions/setup-python because Python 3.8 isn't available on the linux.24_04.4x runner, which now runs an Ubuntu 26.04 image. Trunk fixed this separately by moving the job to ubuntu-24.04 ([CI] Run Lint's collect_env jobs on ubuntu-24.04 #203982), but the PR's older merge base still uses the old runner.

    Full reasoning on HUD →

  • pull / linux-jammy-py3.11-gcc11 / build (gh) (this job did not run on the merge base, so DrCI cannot tell whether the failure is pre-existing)
    Could not load credentials from any providers

    AI verdict: AI verdict: infra issue

    The build job failed at the aws-actions/configure-aws-credentials step before any build happened, with "Could not load credentials from any providers". The suspect commit only edits one test in test/test_linalg.py, so it can't affect fetching AWS credentials. The same error also shows up on trunk commit 50ed686.

    Full reasoning on HUD →

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

  • trunk / win-vs2022-cpu-py3 / test (default, 11, 12, windows.4xlarge.nonephemeral) (gh) (this job did not run on the merge base, so DrCI cannot tell whether the failure is pre-existing)
    AssertionError: Torch not compiled with CUDA enabled

    AI verdict: AI verdict: probably not related

    The suspect commit only edits a ROCm-only grouped-mm test in test/test_linalg.py, and that file never ran in this Windows CPU shard. The job went red because test_nestedtensor finished with every test passing and then its process exited abnormally ("Unsupported signal: 2"). The "Torch not compiled with CUDA enabled" line is stderr from a subprocess inside a test that passed. It is not the failure.

    Full reasoning on HUD →

CANCELLED JOBS - The following jobs were cancelled. Please retry:

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

@pytorch-bot

pytorch-bot Bot commented Oct 26, 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 26, 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.

@jithunnair-amd jithunnair-amd added ciflow/trunk Trigger trunk jobs on your pull request ciflow/periodic-rocm-mi300 Trigger "distributed" config CI on ROCm MI300/MI325 ciflow/inductor-rocm-mi300 Trigger "inductor" config CI on ROCm MI300/MI325 labels Oct 30, 2026
@TheRealMichaelWang
TheRealMichaelWang force-pushed the mwang105-add-cktile-groupgemm-fp32-support branch from e2665c9 to ab084bc Compare November 3, 2026 18:26
Adds a CkTileGroupGemmConfigs<GFX950, ck_tile::fp32_t> specialization and lets
ck_tile_group_gemm_supported accept fp32 inputs on gfx950 (gfx942 has no fp32
configs, so fp32 there keeps falling back to hipBLASLt).

fp32 fragments take twice the registers of bf16, so four-wave tiles with 256
rows or columns spill at K_Tile 32, and the backward layouts read transposed
operands from LDS with narrow loads. Eight-wave tiles cut both costs: dX/dW
went from ~73-136 to ~97-148 TFLOPS in the standalone harness. The candidate
lists came from a sweep of ~220 configs (tile shape, wave count, fp32 MFMA warp
tile, K_Tile, CK pipeline and scheduler), with load_cost selection simulated
over every candidate subset; the chosen lists are within ~2% of a per-shape
best pick, and adding the 30 best other configs improves the best by <=1%.

fp32 ck_tile is only faster than hipBLASLt on small experts (mostly M=512):
forward on 64/396 Primus MoE shapes (up to 1.41x), dX and dW on ~10 each (up
to 1.17x); elsewhere it is 0.81-0.98x. rocprofv3 shows the same MFMA work on
both backends; the gap is LDS: dX hits bank conflicts on ~31% of LDS-active
cycles, and dW uses a 128x128 tile (hipBLASLt: 224x256) with narrow transposed
reads, 3.5x the LDS instructions. Neither is reachable through configs, so a
dispatcher should route fp32 to ck_tile only for small per-expert sizes.

test_grouped_gemm_rocm_backend now also runs fp32 with atol=1e-4, rtol=1e-5.
ck_tile accumulates each output over K in one fp32 accumulator; against a
float64 reference its error matches an emulated sequential fp32 sum, while
hipBLASLt kernels that split K have up to 2x lower RMS error on long K, which
pushed a few elements per tensor just past the default atol=1e-5.

Test Plan:

    python3 test/test_linalg.py -k TestGroupedMM -v
    python3 test/test_matmul_cuda.py -k grouped -v

On MI355X (gfx950): 1048 passed, 0 failed, 835 skipped (CPU/MPS variants and
the existing unaligned-case skips) for TestGroupedMM, including 192 fp32
test_grouped_gemm_rocm_backend cases; 1 passed for test_matmul_cuda. These ran
on a build with `float` in place of the identical `ck_tile::fp32_t` alias.

Performance and accuracy (agent_space scripts, not part of this change):

    python3 agent_space/eval/fp32_bench.py fp32_hipblaslt.csv
    ROCM_ALLOW_GROUP_GEMM_CK_TILE=1 python3 agent_space/eval/fp32_bench.py fp32_cktile.csv --check

All ck_tile fp32 outputs over the 396 shapes matched hipBLASLt to 8.5e-6
relative.

This change was authored with the help of an AI assistant (Claude Code).
@TheRealMichaelWang
TheRealMichaelWang force-pushed the mwang105-add-cktile-groupgemm-fp32-support branch from ab084bc to faead33 Compare November 3, 2026 18:35
@TheRealMichaelWang

TheRealMichaelWang commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

These are the performance results for the CK-tile group gemm backend and the default hipBLASlt based backend, for fp32. Note G=2^30. Note the speedup shows the speedup of the CK-tile backend over the default backend.

gfx950 on MI355X perf

MNK per expert shapes fwd speedup bwd speedup ck_tile fwd (ms) ck_tile bwd (ms) default fwd (ms) default bwd (ms) ck_tile fwd (TFLOPS) ck_tile bwd (TFLOPS) default fwd (TFLOPS) default bwd (TFLOPS)
1-2G 3 1.43x 1.04x 0.093 0.321 0.133 0.332 127 74 89 71
2-4G 15 1.05x 0.97x 0.404 0.674 0.422 0.656 75 90 72 93
4-8G 33 1.05x 0.89x 1.074 1.932 1.131 1.728 89 99 85 111
8-16G 51 1.10x 0.87x 2.175 4.455 2.397 3.892 109 106 99 122
16-32G 61 1.04x 0.86x 3.804 8.090 3.959 6.926 119 112 115 131
32-64G 63 1.08x 0.84x 6.527 14.500 7.072 12.249 130 117 120 139
64-128G 62 1.04x 0.84x 12.066 27.361 12.565 22.911 136 120 131 143
128-256G 51 0.99x 0.84x 24.573 56.854 24.317 47.586 142 122 143 146
256-512G 33 0.96x 0.84x 42.239 97.969 40.721 81.840 144 124 149 149
512-1024G 15 0.96x 0.84x 40.064 93.490 38.520 78.571 146 125 152 149
1024-2048G 5 0.95x 0.84x 19.858 45.894 18.889 38.324 146 126 153 151
2048-4096G 3 0.94x 0.83x 34.738 79.563 32.810 66.170 145 127 153 152
4096-8192G 1 0.93x 0.83x 61.574 138.319 57.337 114.895 143 127 153 153

gfx942 on MI300X perf

MNK per expert shapes fwd speedup bwd speedup ck_tile fwd (ms) ck_tile bwd (ms) default fwd (ms) default bwd (ms) ck_tile fwd (TFLOPS) ck_tile bwd (TFLOPS) default fwd (TFLOPS) default bwd (TFLOPS)
1-2G 3 1.30x 1.13x 0.130 0.356 0.170 0.402 91 66 70 59
2-4G 15 1.03x 1.04x 0.347 0.764 0.358 0.791 88 80 85 77
4-8G 33 0.98x 0.99x 1.005 2.168 0.983 2.154 95 88 97 89
8-16G 51 0.98x 0.99x 2.369 4.906 2.329 4.857 100 96 102 97
16-32G 61 0.96x 0.94x 4.404 8.834 4.244 8.343 103 103 107 109
32-64G 63 0.96x 0.94x 8.018 15.633 7.733 14.716 106 109 110 116
64-128G 62 0.97x 0.91x 15.197 29.340 14.681 26.790 108 112 112 122
128-256G 51 0.96x 0.89x 31.859 61.932 30.625 55.305 109 112 114 126
256-512G 33 0.96x 0.89x 55.524 104.216 53.111 93.164 109 117 114 131
512-1024G 15 0.94x 0.89x 54.118 101.633 50.623 90.297 108 115 116 130
1024-2048G 5 0.94x 0.88x 26.507 49.471 24.926 43.360 109 117 116 133
2048-4096G 3 0.96x 0.87x 45.518 84.099 43.629 73.437 111 120 115 137
4096-8192G 1 0.95x 0.86x 79.110 147.233 75.209 126.491 111 119 117 139

@TheRealMichaelWang TheRealMichaelWang changed the title Add support for fp32 configs for CK-Tile [ROCm] Add support for fp32 configs for CK-Tile Group GEMM backend Nov 3, 2026
@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Nov 3, 2026
@TheRealMichaelWang
TheRealMichaelWang marked this pull request as ready for review November 3, 2026 22:36
@github-actions
github-actions Bot requested a review from jeffdaily November 3, 2026 22:39
@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 3, 2026

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

Three things need to change before this can go in; details below.

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

  1. test_grouped_gemm_ck_tile_config_coverage (test/test_linalg.py) only runs bf16, and _GROUPED_MM_CK_TILE_CONFIGS only lists bf16 configs. The 20 new fp32 configs use different tile shapes, so nothing shows that test_grouped_gemm_rocm_backend ever launches them (for example the gfx950 256x256x16 eight-wave forward or the gfx942 128x64x64). Please parametrize the coverage test over dtype and add the fp32 expected config sets for each (arch, CUs).
  2. GroupedBlas.cpp: the new isGPUArch({"gfx942", "gfx950"}) in ck_tile_group_gemm_supported duplicates the check its only caller makes just before calling it, and costs a second device-property lookup on every grouped_mm call. Please drop it. Also, the comment at ck_tile_group_gemm.hip:62 ("Only a 16-bit C vector width of 1 needs NoSplitKEpilogue") is now wrong: the fp32 AnyShape takes that path too.
  3. In your fp32 table, ck_tile backward is 0.83-0.89x of hipBLASLt for every bucket above 4G, and forward drops below 1x above 128G. Which arch is the table from? Please add gfx942 numbers and split backward into dX and dW. ROCM_ALLOW_GROUP_GEMM_CK_TILE covers all dtypes, so anyone who enables it for bf16 also gets these fp32 kernels. Either show where fp32 wins, or leave out the layouts that lose. Please also use the current PR template, with a summary and a test plan.

@drisspg drisspg 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.

@TheRealMichaelWang

Copy link
Copy Markdown
Contributor Author

@pytorchbot review

@pytorch-bot pytorch-bot Bot added in progress PR is being worked on by the author, until the automated review accepts it and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 6, 2026
github-actions[bot]

This comment was marked as outdated.

@TheRealMichaelWang

Copy link
Copy Markdown
Contributor Author

Automated review of 59be65c: changes requested before human review.

The PR adds fp32 CK-tile grouped GEMM tile configs for gfx950 and gfx942, routes kFloat through ck_tile_group_gemm_supported and with_ck_type, and extends the ROCm grouped_mm and config-coverage tests to fp32. Recommendation: Request Changes. The one blocker is jeffdaily's point 3: fp32 kernels that lose to hipBLASLt on most measured sizes ship behind the shared all-dtype opt-in, and no dX/dW breakdown has been posted. Every other point is non-blocking.

if (mat_b.scalar_type() != dtype || (dtype != at::kBFloat16 && dtype != at::kHalf && dtype != at::kFloat)) {

🔴 Blocking (continuing): jeffdaily's point 3 is still not done. He asked to split backward into dX and dW and to "either show where fp32 wins, or leave out the layouts that lose". Neither has happened: both arches still ship every fp32 Forward/GradInput/GradWeight candidate set (ck_tile_group_gemm.hip:203-236, :290-325), and no dX/dW breakdown has been posted. The author's own tables show ck_tile fp32 is slower than hipBLASLt in most size ranges (gfx950 bwd 0.830.89x above 4G, fwd 0.930.99x from 128G; gfx942 fwd 0.940.98x, bwd 0.860.99x above 4G). rocmAllowGroupGemmCkTile() is one switch for every dtype, so anyone who turned it on for bf16 now silently gets slower fp32 kernels with no fp32-only opt-out. With ROCM_ALLOW_GROUP_GEMM_CK=1 also set, aligned fp32 used to run on group_gemm_ck (which supports F32) and now runs on ck_tile, with different numerics and speed. Deferring the heuristic to another PR is a fair scoping argument, but it doesn't cover the dX/dW split, and jeffdaily's review is still CHANGES_REQUESTED. To resolve: get jeffdaily to confirm in the PR that deferring is fine, or leave out the fp32 layouts that lose (at least GradInput/GradWeight) so they fall back to hipBLASLt, or put fp32 behind its own opt-in.

An earlier comment near this line has replies: #202073 (comment)

⚪ 7 non-blocking findings

self.fail(f"no expected ck_tile configs for (arch, CUs, dtype) {key}; add them to _GROUPED_MM_CK_TILE_CONFIGS")

Non-blocking: the new hard failure breaks the test on unlisted hardware. self.fail now runs for any gfx942/gfx950 device whose (arch, CUs, dtype) key isn't in the table, which has only (gfx950,128), (gfx950,256) and (gfx942,304). MI300A (228 CUs), MI308X (80) and partition modes such as CPX now fail for both bf16 and fp32, where bf16 used to skip. PyTorch's own MI300/MI355 runners are in the table, so CI isn't affected. A narrower check would serve better: fail only when the (arch, CUs) pair is listed for another dtype but not this one, and skip when the CU count itself is unknown. That still catches a forgotten dtype entry.

continue # the unaligned 16-bit cases _check_grouped_gemm skips

Non-blocking (raised before, no reply): the comment is wrong. It says "the unaligned 16-bit cases _check_grouped_gemm skips", but _check_grouped_gemm only skips when not torch.version.hip (:12445), and this test only runs on ROCm. It also doesn't say why fp32 keeps the unaligned cases.

@toleranceOverride({torch.float32: tol(atol=1e-4, rtol=1e-5)})

Non-blocking (raised before): the tolerance is looser than its comment says (also :12491). The comment says "up to 2x the rounding error", but tol(atol=1e-4, rtol=1e-5) is about 10x the default fp32 atol and about 7.7x the default rtol. It applies to every fp32 case, including those routed to hipBLASLt. Either scale it with the contraction length, or apply it per case the way 2d_3d_sparse_decode does (:12294).

subtest(((256, 64), (2, 20, 64), [128, 256], True), name="ck_tile_2d_3d_n20"),

Non-blocking (raised before): the tail-path comment at test_linalg.py:12303-12307 no longer holds for fp32. It says the eight-wave configs see 1 to 7 K tiles, but for the fp32 K_Tile-16 eight-wave forward and dX configs, the aligned contraction lengths (forward K of 32 to 128, dX N 32) never give a single K tile, so the 1-tile Odd-tail path of FourWaveTailCompV3 isn't exercised. Affected: gfx950 RC 256x256x16, RR 256x128x16, RR 128x128x16; gfx942 RR 128x128x16, RR 256x128x16. Fix: add a case with contraction length 16, or narrow the comment.

case at::kFloat: return f(ck_tile::fp32_t{});

Non-blocking (raised before): ck_tile fp32 ignores the TF32 setting. Nothing under native/hip reads fp32_precision or allow_tf32, while the hipBLASLt fallback does (CublasLtUtils.h:327-332). A user who opts in with TF32 enabled silently gets IEEE fp32: more accurate but probably slower. The tests force allow_tf32=False (test_linalg.py:12388), so they never see this. Fall back to hipBLASLt when TF32 is requested, or document the difference. The PR should also say which precision mode the "default" benchmark columns used.

static constexpr bool UseNoSplitKEpilogue = FixedVectorSizeC && VectorSizeC == 1;

Non-blocking: the epilogue comment was deleted, not corrected, so UseNoSplitKEpilogue has no explanation left. The only remaining rationale, in ck_tile_group_gemm/no_split_k_epilogue.h:10, is "16-bit atomics reject a C vector width of 1". The fp32 AnyShape configs also take this path, and the coverage test relies on that by finding the C1 configs by epilogue name. A one-line note that fp32 C1 configs use it too (harmless since k_batch is always 1) would stop someone narrowing it to 16-bit later.

const bool supported_ck_tile_arch = at::detail::getCUDAHooks().isGPUArch({"gfx942", "gfx950"});

Non-blocking: supported_ck_tile_arch is a misleading name. It also gates the non-tile CK path (:814); a name like is_gfx942_or_gfx950 would fit both uses. It is now evaluated before the env-flag checks rather than after them, but the cost is negligible since isGPUArch reads cached device properties.

Please address the findings and push; a new commit normally gets a fresh automated review.

Disagree with a finding? Reply with your reasoning, then comment @pytorchbot review to request a re-review. This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

I reject the changes you request. You are relitigating an non-issue I have already marked resolved. The heuristics for backend selection will be added in an independent PR. This is an internal AMD project, and the plan has already been established.

My agent has responded and I've reviewed the changes

  • Opt-in only. ck_tile grouped mm, including fp32, only runs when ROCM_ALLOW_GROUP_GEMM_CK_TILE=1 is set. > That flag is off by default, so nothing changes for anyone who hasn't opted in.
  • Precedence with ROCM_ALLOW_GROUP_GEMM_CK=1. _grouped_mm_cuda already preferred ck_tile over CK > when both flags were set, for bf16/fp16. fp32 now follows the same rule rather than adding a dtype-specific exception.
  • Correctness. fp32 matches the per-group matmul reference within rtol=1e-4 / atol=2e-2 for forward, dX and dW on all op-benchmark shapes on MI300X. test_grouped_gemm_ck_tile_config_coverage now has gfx942 and gfx950 fp32 entries, and a supported arch with no entry fails the test instead of skipping it.
  • Performance. The fp32 tables are posted above. A dX/dW split and a per-layout selection heuristic (falling back to hipBLASLt where ck_tile loses) are out of scope for this PR; I'll handle them in a follow-up so this one stays focused on adding fp32 support behind the existing opt-in.

@TheRealMichaelWang

Copy link
Copy Markdown
Contributor Author

@pytorchbot review

@pytorch-bot pytorch-bot Bot added in progress PR is being worked on by the author, until the automated review accepts it and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 6, 2026
github-actions[bot]

This comment was marked as outdated.

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

Fine to defer the fp32 selection heuristic and the dX/dW split to the follow-up, since everything here stays behind ROCM_ALLOW_GROUP_GEMM_CK_TILE. Please link the follow-up here when it exists. Approving; two small test fixes to make before merging:

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

  1. test/test_linalg.py:12500: the new self.fail runs for any gfx942/gfx950 device whose (arch, CUs, dtype) key is not in the table, so the test now fails on MI300A (228 CUs), MI308X (80 CUs) and CPX partitions, where it used to skip. Please fail only when the (arch, CUs) pair is listed for another dtype but not this one, and skip when the CU count itself is unlisted. That still catches a missing dtype entry.
  2. test/test_linalg.py:12506: the comment "the unaligned 16-bit cases _check_grouped_gemm skips" is wrong here; _check_grouped_gemm only skips them when not torch.version.hip, and this test only runs on ROCm.

@TheRealMichaelWang

Copy link
Copy Markdown
Contributor Author

Fine to defer the fp32 selection heuristic and the dX/dW split to the follow-up, since everything here stays behind ROCM_ALLOW_GROUP_GEMM_CK_TILE. Please link the follow-up here when it exists. Approving; two small test fixes to make before merging:

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

  1. test/test_linalg.py:12500: the new self.fail runs for any gfx942/gfx950 device whose (arch, CUs, dtype) key is not in the table, so the test now fails on MI300A (228 CUs), MI308X (80 CUs) and CPX partitions, where it used to skip. Please fail only when the (arch, CUs) pair is listed for another dtype but not this one, and skip when the CU count itself is unlisted. That still catches a missing dtype entry.
  2. test/test_linalg.py:12506: the comment "the unaligned 16-bit cases _check_grouped_gemm skips" is wrong here; _check_grouped_gemm only skips them when not torch.version.hip, and this test only runs on ROCm.

Both of the requested changes to the tests have been added in 6ba0475.

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

The PR adds fp32 CK-tile grouped GEMM tile configs for gfx950 and gfx942, sends kFloat through ck_tile_group_gemm_supported and with_ck_type, and extends the ROCm grouped_mm correctness and config-coverage tests to fp32. Recommendation: Approve. Nothing blocks: jeffdaily's requested test fixes are in, he agreed to defer the earlier blocking point, and the remaining points are all non-blocking clean-ups.

⚪ 4 non-blocking findings

if (mat_b.scalar_type() != dtype || (dtype != at::kBFloat16 && dtype != at::kHalf && dtype != at::kFloat)) {

Non-blocking: fp32 ignores the TF32 / fp32_precision setting. Nothing under aten/src/ATen/native/hip/ reads it. Before this PR, fp32 grouped_mm always took _grouped_mm_fallback, which goes through at::mm_out/bmm_out to hipBLASLt. That path sets CUBLAS_COMPUTE_32F_FAST_TF32 when precision is TF32 (CublasLtUtils.h:328-332, no USE_ROCM guard). So a user who sets ROCM_ALLOW_GROUP_GEMM_CK_TILE=1 and opts into TF32 now gets IEEE fp32 on aligned shapes. This is confirmed for gfx942 (see the XF32 handling in Blas.cpp:121-134). On gfx950 it depends on hipBLASLt's xf32 support. The tests force allow_tf32 = False, so they cannot catch it. Fix: return false from ck_tile_group_gemm_supported for kFloat when TF32 is requested, or document the difference.

An earlier comment near this line has replies: #202073 (comment)


// configs for fp32 inputs on gfx950. fp32 fragments take twice the registers of bf16, so four-wave tiles with

Non-blocking: the gfx950 fp32 rationale contradicts the gfx942 configs. The comment says "four-wave tiles with 256 rows or columns spill at K_Tile 32", and the reason it gives doesn't depend on the arch (fp32 fragments take twice the registers). Yet gfx942 fp32 Forward ships exactly that shape: CkTileGroupGemmConfig&lt;256, 128, 32, 16, 16, 16, 2, 2, ...&gt; (:299), and both arches have the same register budget. Either say this was measured on gfx950 only, or reconcile the two. Whether either tile actually spills can't be checked without a build.


@toleranceOverride({torch.float32: tol(atol=1e-4, rtol=1e-5)})

Non-blocking: the fp32 tolerance comment overstates how tight it is (repeated at :12491). tol(atol=1e-4, rtol=1e-5) is about 10x the default fp32 atol and about 7.7x the default rtol, not "up to 2x the rounding error". The "on long K" reason conflicts with "Contractions stay small" (:12305); the longest contraction that reaches ck_tile is 224. The override also covers fp32 cases that go to hipBLASLt. Fix the comment, or apply the tolerance per case as 2d_3d_sparse_decode does (:12294).


subtest(((2048, 128), (2, 8192, 128), [1024, 2048], False), name="ck_tile_2d_3d_k128"),

Non-blocking: the tail-path comment no longer holds for fp32 (test/test_linalg.py:12303-12307). It says "eight-wave configs see 1 to 7 K tiles", which covers the one-tile Odd tail of FourWaveTailCompV3. The new K_Tile-16 eight-wave forward/dX configs only ever see 2 to 8 K tiles, so that path never runs for them. These are gfx950 RC 256x256x16, RR 256x128x16 and RR 128x128x16, and gfx942 RR 128x128x16 and RR 256x128x16. The gfx942 CR 128x128x16 8w --K dW config also sees 2 to 14 tiles, never 1. Fix: add a case with a contraction of 16, or narrow the comment to the K_Tile-32 configs.

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 stale reviews from themself November 9, 2026 17:33

Withdrawn: the automated review of 6ba0475 found nothing blocking.

@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 5 checks: pull / linux-jammy-py3.11-gcc11 / build, Lint / Test collect_env (without_torch, linux.24_04.4x), Lint / Test collect_env (with_torch, linux.24_04.4x), Lint / Test collect_env (older_python_version, linux.24_04.4x), trunk / win-vs2022-cpu-py3 / test (default, 11, 12, windows.4xlarge.nonephemeral)

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

bot-triaged This is a label only to be used by the auto triage bot 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 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 release notes: linalg_frontend release notes 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.

6 participants