Skip to content

feat(hipblaslt): fp32 GridBased logic + Equality retune for gfx1200/g… - #12116

Merged
stsokolo merged 1 commit into
developfrom
users/stsokolo/rocm-28540-gfx120x-fp32-gridbased
Oct 8, 2026
Merged

stsokolo merged 1 commit into
developfrom
users/stsokolo/rocm-28540-gfx120x-fp32-gridbased

Conversation

@stsokolo

Copy link
Copy Markdown
Contributor

Motivation

Neither gfx1200 nor gfx1201 ships any fp32 GridBased logic (0 of 108 files on gfx1201, 0 of 112 on gfx1200), so Equality is the only matching row for fp32. An Equality miss is a hard miss, so any fp32 shape not in those exact tables gets no solution at all. HIPBLAS_COMPUTE_32F_FAST_TF32 hits the same wall, since it falls back to fp32 and misses again.

Reported from PyTorch as:

bgemm_internal_cublaslt error: HIPBLAS_STATUS_NOT_SUPPORTED when calling hipblasLtMatmul
  with transpose_mat1 t transpose_mat2 n m 128 n 128 k 64 lda 64 ldb 64 ldc 128
  abType 0 cType 0 computeType 6 scaleType 0.
  Will attempt to recover by calling cublas instead.

JIRA ID : ROCM-28540

Technical Details

Adds fp32 GridBased logic for both archs and retunes the fp32 Equality tables. 16 files, fp32 (_S_B_Bias_HA_S_SAV_UserArgs) only, no other datatype touched.

arch dir files solutions exact entries
gfx1200 GridBased/ 4 285 864 new (was 0)
gfx1200 Equality/ 4 17 24 retuned
gfx1201 GridBased/ 4 281 864 new (was 0)
gfx1201 Equality/ 4 42 58 retuned

GridBased cannot miss, so adding the row removes the no-solution failure. Grid is a 6-point grid, 216 points per transpose:

M ∈ {1, 64, 256, 768, 3072, 12288}
N ∈ {1, 64, 256, 1024, 4096, 8192}
K ∈ {1, 64, 256, 1024, 4096, 8192}

Equality is row 0, so it is consulted before GridBased on every shape it covers. Those tables are retuned here so the exact-match path benefits from the same solution pool. Shape sets are unchanged, verified per file; only the selected kernel changes.

Test Plan

Host with both cards (gfx1200 + gfx1201), ROCm nightly. Per CONTRIBUTING.md, tested against an existing ROCm install via HIPBLASLT_TENSILE_LIBPATH, run once per arch.

  1. Correctness. hipblaslt-test, fp32 filter, against both the stock and the new library:
    hipblaslt-test --gtest_filter='*f32_rf32_rf32_rf32_rf32_r*'
  2. Reported failure. The PyTorch test that surfaced the bug, before and after:
    python -m pytest inductor/test_flex_attention.py \
      -k "test_debug_flag_disables_internal_compilation_cuda" -v
  3. Performance. hipblaslt-bench, 22 shapes per arch, stock vs new. Both arms get a discarded warmup then best-of-3.
  4. Build gates. TensileLogic --check-all and TensileCreateLibrary.
  5. Per-file validation. LibraryType, arch/device names, entry counts, contiguous SolutionIndex, all ExactLogic references in range, 100% UseDualFMAC, and the non-MI fp32 constraints (PrefetchLocalRead <= 1, ScheduleIterAlg == 1, no UseE).

Test Result

Correctness: 3862 fp32 tests per arch, 0 failures. Same pass count as stock, so no coverage was lost.

suite gfx1201 gfx1200
quick fp32 (2108 tests) 2108 passed 2108 passed
pre_checkin fp32 (1754 tests) 1754 passed 1754 passed

Reported failure: fixed on both archs.

arch stock with this change
gfx1200 FAILED passed
gfx1201 FAILED passed

Performance: no regressions, slowest shape on either arch is ~+40%.

gfx1201 gfx1200
on-table shapes (Equality) +79.1% +68.4%
off-table shapes (GridBased) +92.7% +86.8%
overall geomean +90.8% +84.2%
median speedup 1.63x 1.72x
worst individual shape +39.4% +45.1%

Representative shapes (gfx1201, TN unless noted):

shape stock new
128x128x8192 637 5207 +718%
256x256x32768 2288 16328 +614%
512x512x16384 (NT) 9512 22113 +133%
2048x2048x2048 (Equality) 11150 24080 +116%
4096x4096x4096 (Equality) 14994 27153 +81%

Largest gains are fat-K / small-MN shapes, where GlobalSplitU was previously unavailable.

Notes

There is also a bug in the xf32 to fp32 fallback path in tensile_host.cpp. It is not included here and all results above were measured without it. This PR fixes the underlying cause, but the two are independent and the fallback fix should follow in its own PR.

@therock-pr-bot

therock-pr-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass PR does not contain code files — Unit Test auto-passed
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@stsokolo
stsokolo force-pushed the users/stsokolo/rocm-28540-gfx120x-fp32-gridbased branch from 42dc2f5 to 1c34df4 Compare September 16, 2026 09:57
@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12116      +/-   ##
===========================================
- Coverage    71.93%   71.93%   -0.01%     
===========================================
  Files         2861     2863       +2     
  Lines       472441   472670     +229     
  Branches     69773    69824      +51     
===========================================
+ Hits        339832   339969     +137     
- Misses      109043   109118      +75     
- Partials     23566    23583      +17     
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 49.33% <ø> (+0.29%) ⬆️
TensileLite-Unit 83.28% <ø> (+<0.01%) ⬆️
hipBLAS 90.62% <ø> (ø) Carriedforward from e344fdc
hipBLASLt 38.92% <ø> (-0.12%) ⬇️
hipCUB 82.68% <ø> (ø) Carriedforward from e344fdc
hipDNN 86.64% <ø> (ø) Carriedforward from e344fdc
hipFFT 43.43% <ø> (ø) Carriedforward from e344fdc
hipRAND 76.12% <ø> (ø) Carriedforward from e344fdc
hipSOLVER 68.96% <ø> (ø) Carriedforward from e344fdc
hipSPARSE 86.99% <ø> (ø) Carriedforward from e344fdc
rocBLAS 48.25% <ø> (ø) Carriedforward from e344fdc
rocFFT 47.62% <ø> (ø) Carriedforward from e344fdc
rocRAND 57.45% <ø> (ø) Carriedforward from e344fdc
rocSOLVER 76.83% <ø> (ø) Carriedforward from e344fdc
rocSPARSE 74.64% <ø> (ø) Carriedforward from e344fdc
rocThrust 93.15% <ø> (ø) Carriedforward from e344fdc

*This pull request uses carry forward flags. Click here to find out more.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stsokolo
stsokolo force-pushed the users/stsokolo/rocm-28540-gfx120x-fp32-gridbased branch 2 times, most recently from 1f6f78d to cf287d1 Compare September 16, 2026 12:56
@stsokolo
stsokolo marked this pull request as ready for review September 17, 2026 09:03
@stsokolo
stsokolo requested a review from a team as a code owner September 17, 2026 09:03
@talumbau

Copy link
Copy Markdown
Collaborator
There is also a bug in the xf32 to fp32 fallback path in tensile_host.cpp. It is not included here and all results above were measured without it. This PR fixes the underlying cause, but the two are independent and the fallback fix should follow in its own PR.

This sounds bad! Can you file a Github issue/ Jira ticket with some more details - thanks!

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

Thanks for fixing the "gaps" here! hipBLASLt kernel library on gfx120x is already by far our largest in RDNA, so we should quantify what we are doing to library size with this change. It's likely that we need it regardless, but the data should be captured for future efforts in library size reduction. Can you please add before/after sizes on kernel library with this PR? thank you!

@stsokolo
stsokolo force-pushed the users/stsokolo/rocm-28540-gfx120x-fp32-gridbased branch from bea8f00 to a77652e Compare September 22, 2026 11:59
@stsokolo

stsokolo commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for fixing the "gaps" here! hipBLASLt kernel library on gfx120x is already by far our largest in RDNA, so we should quantify what we are doing to library size with this change. It's likely that we need it regardless, but the data should be captured for future efforts in library size reduction. Can you please add before/after sizes on kernel library with this PR? thank you!

@talumbau I built the libraries locally and measured this:

Same develop commit and identical CMake config for both builds (GPU_TARGETS=gfx1201;gfx1200, compression on), so the only difference is this PR's logic files.

arch before after delta %
gfx1200 234,001.5 KB 234,431.6 KB +425.3 KB +0.182%
gfx1201 169,518.7 KB 169,840.9 KB +322.3 KB +0.190%
total 403,516.2 KB 404,271.6 KB +747.5 KB +0.185%

So +747.5 KB total, under 0.2% — roughly 93% code objects, 7% .dat metadata.

No build artifacts are added or removed (282 / 292 files before and after). The 8 new GridBased YAMLs don't create new outputs, since those fp32 problem types already existed from the Equality files — the new logic just folds into the same per-problem-type .co/.dat, 4 of each per arch. Everything outside fp32 is unchanged apart from a few hundred bytes of build nondeterminism.

Kernel count is the bigger relative jump: 16 → 302 on gfx1200 and 50 → 323 on gfx1201. They're non-MI ThreadTile MAC kernels though, so ~1.5 KB each.

If size becomes a concern the easiest lever is grid density — 216 points (6×6×6) is already a subsample, and 5×5×5 would roughly halve the GridBased pool at some cost to interpolation quality on off-grid shapes. Happy to do that if you'd prefer.

@talumbau

talumbau commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the numbers @stsokolo! I didn't realize that the fp32 coverage was so small. Although it absolute terms the number of kernels goes up a lot, this is obviously not a significant bump in size. Thanks for confirming! LGTM

@JeniferC99

Copy link
Copy Markdown
Contributor

Cancelling the remaining gfx950 jobs on this run so the TheRock submodule bump PRs can be prioritized on the gfx950 queue.

This change does not target gfx950, and gfx950 was the only work still outstanding. Jobs that already finished are unchanged. Re-run failed jobs if you need gfx950 results before merge.

@stsokolo
stsokolo force-pushed the users/stsokolo/rocm-28540-gfx120x-fp32-gridbased branch from d5a2e12 to 893c1e7 Compare October 7, 2026 07:56
jinchen62 added a commit that referenced this pull request Oct 7, 2026
…12866)

JIRA ID : ROCM-29721

## Motivation

`getAllSolutions()` used to return solutions in heap-address order. For
problem sizes missing from the tuned tables,
`hipblasLtMatmulAlgoGetHeuristic` returns the first supported entry of
that list, so identical processes could run different kernels for the
same GEMM. On gfx1201 this made the ranks of a PyTorch FSDP job compute
different gradients, so `TestStateDict.test_fsdp` failed intermittently
(ROCM-29721), and it caused a random 2x slowdown reported in #12126.
#11340 fixed the order by sorting on solution index but added no test,
so nothing stops the order from regressing.

## Technical Details

- New test `AlgoOrder_pre_checkin.GetAllAlgosIsSortedBySolutionIndex`
checks that `hipblaslt_ext::getAllAlgos()`, which returns the same list
the heuristic fallback reads, gives strictly increasing solution indices
for all four transpose combinations in FP32, FP16 and BF16.
- Because the list is sorted, the duplicate check in `getAllSolutions()`
compares each solution with the last kept result instead of scanning
every kept result. The returned list is unchanged.
- `row_uniformity_gtest.cpp` no longer sorts `getAllAlgos()` results
itself; its comment now states that it relies on the index order the new
test checks.
- Production kernel selection does not change, so there is no flag.

Related: #11340 (the ordering fix this test locks), #11090 and #12126
(issues it fixed), #12116 (FP32 size-grid tables for gfx120x, which
reduce how often gfx12 FP32 GEMMs reach the fallback).

## Test Plan

On gfx1201 (RX 9070 XT), with hipBLASLt host libraries built from the
10.1.0a20260814 nightly source without the sort, from that source with
the sort, and from this branch merged with develop:
- the new gtest;
- a dump of every `getAllAlgos()` index for the 12 transpose and type
combinations, compared across builds.

## Test Result

- The new gtest fails on all 5 runs against the build without the sort
(10 to 12 of the 12 combinations out of order) and passes on all 5 runs
with it. Against this branch merged with develop it passes 2/2.
- `getAllAlgos()` returns the same 4,435 algorithms in the same order
with the quadratic and the linear duplicate check, and in this branch
merged with develop.
- Automated checks are pending: TheRock CI (Linux gfx94X and gfx950,
Windows gfx110X) and Math CI pre-checkin, whose gfx12 stage runs the
`*_pre_checkin` gtest suites, including the new test.

## Risk level

Low (2/5): a host-only change to the duplicate check that returns
identical results, plus test changes. Production kernel selection is
unchanged.

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@stsokolo
stsokolo merged commit 234d9b9 into develop Oct 8, 2026
120 of 124 checks passed
@stsokolo
stsokolo deleted the users/stsokolo/rocm-28540-gfx120x-fp32-gridbased branch October 8, 2026 08:26
@assistant-librarian

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants