Skip to content

fix(hipblaslt): clamp workspace limits above 4 GiB instead of rejecting - #13410

Merged
tony-davis merged 1 commit into
developfrom
users/tony-davis/ROCM-32535-clamp-workspace-limit
Oct 10, 2026
Merged

tony-davis merged 1 commit into
developfrom
users/tony-davis/ROCM-32535-clamp-workspace-limit

Conversation

@tony-davis

@tony-davis tony-davis commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

JIRA ID : ROCM-32535

Motivation

#12856 fixed a real bug where the C++ heuristic truncated the workspace limit to int. It also made any workspace limit or size above UINT32_MAX return HIPBLAS_STATUS_INVALID_VALUE. The thing is, callers commonly pass SIZE_MAX to mean "no limit." driftcheck 1.0.6 does exactly that, so it now fails at hipblasLtMatmulPreferenceSetAttribute before any GEMM runs.

A limit is a ceiling, so I think a value above what the kernels can address should be clamped, not rejected.

Technical Details

  • validateWorkspaceSize() becomes clampWorkspaceSize() in rocblaslt_mat_utils.hpp. It returns min(value, UINT32_MAX) and logs at the hints level when it clamps (the rocblaslt logger has no warning level).
  • It applies at the same four entry points as fix(hipblaslt): check workspace limits and name complex types #12856: the HIPBLASLT_MATMUL_PREF_MAX_WORKSPACE_BYTES preference, hipblasLtMatmul, and the extension API's algoGetHeuristic and initialize. Kernels still never see more than a 32-bit range.
  • The preference stores the clamped value, so every later reader sees at most UINT32_MAX. Reading it back after setting SIZE_MAX gives UINT32_MAX.
  • The int to size_t fix in getBestSolutions from fix(hipblaslt): check workspace limits and name complex types #12856 stays.
  • The header docs and CHANGELOG now say these values are clamped.
  • The minimum-workspace check from fix(hipblaslt): reject undersized workspace in the ext API #13184 (ROCM-32226) is on the same path and still works, since a clamped limit is still compared against what the solution needs.

Test Plan

smoke_RejectsWorkspaceAboveUint32Max locked in the behavior this PR fixes, so two tests in heuristic_workspace_gtest.cpp replace it:

  • smoke_PreferenceClampsLimitAboveUint32Max: at 4 GiB and UINT64_MAX, setting the preference succeeds and reads back UINT32_MAX. It needs no solution library, so it can't skip.
  • smoke_ClampsWorkspaceAboveUint32Max: at 4 GiB and UINT64_MAX, the C and C++ heuristics return the same results as at UINT32_MAX. hipblasLtMatmul succeeds with an oversized workspace size (the driftcheck pattern), and extension initialize succeeds with an oversized setMaxWorkspaceBytes.

Restoring the reject, or dropping the clamp at any one entry point, fails a specific assertion. smoke_CppQueryKeepsLimitsFrom2GiBToUint32Max is unchanged and still guards the int fix. Both new tests use the smoke_ prefix, so they run in the existing CI smoke lane.

Adjacent tests: AlgoWorkspace.* (the #13184 undersized-workspace test on the same path) and the full *smoke*:*aux_test* set.

  • hipblaslt-test --gtest_filter='HeuristicWorkspaceLimit.*:DataTypeNames.*:AlgoWorkspace.*', with this PR's library and again with a develop library
  • hipblaslt-test --gtest_filter='*smoke*:*aux_test*' on this PR and on develop

Test Result

All runs on one MI300X (gfx942), ROCm 10.2.0a20260928, Release build for gfx942, develop at e56d6561886.

  • Targeted filter: 5/5 pass with this PR. The same test binary against the develop library fails both new tests; the setter returns 3 (INVALID_VALUE) at 4 GiB and SIZE_MAX.
  • *smoke*:*aux_test*: 3236/3236 pass with this PR, 3235/3235 on develop. The only difference in the passing lists is the reject test swapped for the two clamp tests.
  • I didn't run driftcheck itself against this build.

Device coverage: host-only, with no change to kernels, kernel selection, or defaults for limits at or below UINT32_MAX. So I think standard PR CI on any gfx lane is enough, and no multi-arch sweep is needed.

Submission Checklist

Risk level

Low (2/5). It's host-only and narrow. It turns an error back into the ceiling behavior callers expect, and kernels still see at most 32 bits. One visible difference from before #12856: reading back the preference after setting a huge value returns UINT32_MAX instead of the value set.

Related: #12856 (AIHPBLAS-4984), the regression source. #13184 (ROCM-32226) touches the same path.

#12856 made any workspace limit or size above UINT32_MAX return
HIPBLAS_STATUS_INVALID_VALUE. Callers pass SIZE_MAX to mean "no limit",
so driftcheck now fails at hipblasLtMatmulPreferenceSetAttribute before
any GEMM runs.

A limit is a ceiling, so clamp it to UINT32_MAX at the same four entry
points: the MAX_WORKSPACE_BYTES preference, hipblasLtMatmul, and the
extension API's algoGetHeuristic and initialize. Kernels still never see
more than a 32-bit range, and the int truncation fix from #12856 stays.
The clamp is logged at the hints level.

The reject test becomes two clamp tests. One checks the preference and
needs no solution library. The other compares heuristic results at 4 GiB
and SIZE_MAX against UINT32_MAX, and runs hipblasLtMatmul and extension
initialize with an oversized workspace size.

JIRA ID : ROCM-32535

Co-authored-by: Cursor <cursoragent@cursor.com>
@tony-davis tony-davis changed the title fix(hipblaslt): clamp workspace limits above 4 GiB instead of rejecting (ROCM-32535) fix(hipblaslt): clamp workspace limits above 4 GiB instead of rejecting Oct 9, 2026
@tony-davis
tony-davis marked this pull request as ready for review October 9, 2026 19:21
@tony-davis
tony-davis requested review from a team as code owners October 9, 2026 19:21
@therock-pr-bot

therock-pr-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 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

therock-pr-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

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

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

LGTM. Clamping makes sense.

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

Sounds reasonable. Code looks good.

@tony-davis
tony-davis enabled auto-merge (squash) October 9, 2026 21:54
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

❌ Your project status has failed because the head coverage (42.73%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #13410   +/-   ##
========================================
  Coverage    71.86%   71.86%           
========================================
  Files         2877     2877           
  Lines       475878   475860   -18     
  Branches     70414    70410    -4     
========================================
- Hits        341980   341973    -7     
+ Misses      110042   110035    -7     
+ Partials     23856    23852    -4     
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 49.67% <ø> (ø) Carriedforward from c1b2c94
TensileLite-Unit 83.44% <ø> (ø) Carriedforward from c1b2c94
hipBLAS 90.62% <ø> (ø) Carriedforward from c1b2c94
hipBLASLt 42.73% <100.00%> (+0.02%) ⬆️
hipCUB 82.68% <ø> (ø) Carriedforward from c1b2c94
hipDNN 86.66% <ø> (-<0.01%) ⬇️ Carriedforward from c1b2c94
hipFFT 42.58% <ø> (ø) Carriedforward from c1b2c94
hipRAND 76.12% <ø> (ø) Carriedforward from c1b2c94
hipSOLVER 68.96% <ø> (ø) Carriedforward from c1b2c94
hipSPARSE 86.99% <ø> (ø) Carriedforward from c1b2c94
rocBLAS 48.23% <ø> (ø) Carriedforward from c1b2c94
rocFFT 46.85% <ø> (ø) Carriedforward from c1b2c94
rocRAND 57.45% <ø> (ø) Carriedforward from c1b2c94
rocSOLVER 76.83% <ø> (ø) Carriedforward from c1b2c94
rocSPARSE 74.07% <ø> (ø) Carriedforward from c1b2c94
rocThrust 93.15% <ø> (ø) Carriedforward from c1b2c94

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...blaslt/library/include/hipblaslt/hipblaslt-ext.hpp 0.00% <ø> (ø)
...ts/hipblaslt/library/include/hipblaslt/hipblaslt.h 50.00% <ø> (ø)
...tail/rocblaslt/src/include/rocblaslt_mat_utils.hpp 6.55% <100.00%> (ø)
...c/amd_detail/rocblaslt/src/rocblaslt_auxiliary.cpp 76.71% <100.00%> (+0.28%) ⬆️
...ary/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp 83.85% <100.00%> (-0.07%) ⬇️

... and 1 file 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.

@tony-davis
tony-davis merged commit fbbc964 into develop Oct 10, 2026
257 of 273 checks passed
@tony-davis
tony-davis deleted the users/tony-davis/ROCM-32535-clamp-workspace-limit branch October 10, 2026 01:58
@assistant-librarian

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

pghysels added a commit that referenced this pull request Oct 13, 2026
tony-davis added a commit that referenced this pull request Oct 14, 2026
… 26.13 pin)

Refreshes projects/hipblaslt, shared/stinkytofu, shared/origami, shared/mxdatagenerator and projects/hipsparselt to their contents at develop 01f6f9c, the rocm-libraries commit that TheRock's 26.13 BKC branch (release/bkc/therock-10.2-20261013) pins. Everything else stays at release/bkc/therock-10.2-20260922 (201f54b), the rocm-libraries in BKC 26.12.

Adds #13410 (ROCM-32535, workspace clamp) on top of the previous patch commit (#12170, #13011, #13274). hipBLASLt in this build is now identical to BKC 26.13's.

Co-authored-by: Cursor <cursoragent@cursor.com>
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