Skip to content

feat(hipblaslt): run JIT GEMM solutions through the normal launch path - #13131

Closed
jaopaulolc wants to merge 5 commits into
users/jolabega/jit-upstream-01-jit-interfacesfrom
users/jolabega/jit-upstream-01b-jit-gemm-run
Closed

jaopaulolc wants to merge 5 commits into
users/jolabega/jit-upstream-01-jit-interfacesfrom
users/jolabega/jit-upstream-01b-jit-gemm-run

Conversation

@jaopaulolc

@jaopaulolc jaopaulolc commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

JIRA ID : AIHPBLAS-4801

Motivation

hipBLASLt runs each matrix multiplication (GEMM) with a kernel from a library that is generated and tuned at build time, so a problem the library serves poorly has no better kernel at run time. Just-in-time (JIT) generation produces a kernel for a problem when it is needed. The previous PR builds generated kernel sources with comgr and loads the code object into a TensileLite library of one or more solutions. This PR runs those solutions through hipblasLtMatmul and hipblaslt_ext::Gemm like a prebuilt one, and it proves the path end to end on a GPU with the committed kernel.

Technical Details

The feature is behind HIPBLASLT_ENABLE_JIT, which is off by default. The commits each build on their own:

  • Pipeline. Jit runs one request for one device through four stages, each an interface: Generate (a backend returns library entries and their kernel sources), Build, Support (each solution's predicates and workspace) and Load. It returns up to the requested count of supported solutions, best first. A failure in one entry skips it and records its stage.
  • In-process GEMM. The internal entry points makeGemmRequest, getJitAlgo and getGemmAlgo return a hipblasLtMatmulAlgo_t that carries a process-local token and the solution's local index. The TensileLite loader in tensile_host.cpp loads an entry once and wraps each supported solution, with the shared library and adapter, in a TensileGemmBundle. get_library_and_adapter resolves the token, and the solution then runs through the normal launch path, including Stream-K's per-stream synchronization. A token from another process or device is rejected before any work is submitted. No installed header declares these entry points.
  • Replay backend. Every JIT build compiles it. It implements Backend and returns pre-generated source bundles instead of running a generator, and Jit builds and loads those entries with the same builder and loader as any other backend.
  • Docs in JIT.md and the JIT test guide. The workflow watches the GEMM host files.

With JIT off, the shared host code still changes in small ways. The GEMM data keeps the selected algorithm and the scale layouts. makeArgument stores its kernels only after they are ready, and it restores the handle's synchronizer on reinitialization. run before initialize returns NOT_INITIALIZED. Kernel-name lookups for an unknown index return an empty name. heuristicResult_copy copies the whole algorithm. Two internal status codes are added.

Not in this PR: a generator backend and a solution store. Later PRs add them.

Test Plan

Host-only builds with GPU_TARGETS=gfx950: JIT on with JIT testing, and JIT off. A third host build uses GPU_TARGETS=gfx942 with JIT on. In each build, CTest runs the JIT tests in clients/tests/jit. The previous PR adds jit-bundles, jit-source-bundle, jit-builder and jit-loader. This PR adds:

  • jit-end-to-end replays the two-solution plain-pair bundle that jit-bundles writes from the committed kernel assembly, builds and loads it, and runs M=256, N=128 through hipblasLtMatmul and hipblaslt_ext::Gemm twice, checking D against a host reference: K=512 runs the first solution and K=256 the second. It also checks that a transposed-A problem is not supported. It replays the bundle of device 0's architecture, so the gfx90a, gfx942 and gfx950 lanes each run their own kernel. CMake registers it in builds with JIT testing when GPU_TARGETS include an architecture with committed bundles.
  • jit-disabled, in the JIT-off build, checks that the JIT headers are not in the public include tree.

A device-library build for gfx950, restricted to one FP16 logic file, ran the JIT tests and the hipblaslt-test quick suite. The suite was compared with the same build of develop. actionlint checked the workflow.

Test Result

Build Tests Result
gfx950, JIT on, on one gfx950 GPU jit-bundles, jit-source-bundle, jit-builder, jit-loader, jit-end-to-end 5 of 5 passed
gfx950, JIT on, every GPU hidden jit-bundles, jit-source-bundle, jit-builder 3 of 3 passed
gfx950, JIT off, every GPU hidden jit-source-bundle, jit-disabled 2 of 2 passed
gfx942, JIT on, every GPU hidden jit-bundles, jit-source-bundle, jit-builder (-L jit-cpu; the build also registers jit-loader and jit-end-to-end) 3 of 3 passed
gfx950 device library, JIT on JIT tests 5 of 5 passed
gfx950 device library hipblaslt-test quick suite 139 passed, 785 failed on both develop and this branch, with identical test names

The 785 failures report "NO solution found", because the build keeps one logic file. Each commit built with JIT on and passed the JIT tests it registers; the last commit also built with JIT off. There is no gfx90a or gfx942 GPU on the test host, so the workflow's lanes are the first native runs of jit-loader and jit-end-to-end on those architectures. actionlint 1.7.12 reported no errors. The workflow's three lanes and the other automated GitHub checks are pending.

Submission Checklist

Risk level

Low (2/5): the JIT sources build only with HIPBLASLT_ENABLE_JIT=ON, which is off by default. With JIT off, the changes are the small shared host-code edits listed in Technical Details, and the quick suite matched develop.

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.55056% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...rary/src/amd_detail/rocblaslt/src/tensile_host.cpp 64.47% 16 Missing and 11 partials ⚠️
...cts/hipblaslt/library/src/amd_detail/hipblaslt.cpp 0.00% 4 Missing and 4 partials ⚠️
...ary/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp 75.00% 0 Missing and 1 partial ⚠️

❌ Your project check has failed because the head coverage (49.03%) 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                                @@
##           users/jolabega/jit-upstream-01-jit-interfaces   #13131      +/-   ##
=================================================================================
- Coverage                                          72.13%   72.13%   -0.00%     
=================================================================================
  Files                                               2861     2861              
  Lines                                             472127   472165      +38     
  Branches                                           69811    69823      +12     
=================================================================================
+ Hits                                              340551   340570      +19     
- Misses                                            107831   107839       +8     
- Partials                                           23745    23756      +11     
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 49.03% <ø> (ø)
TensileLite-Unit 83.28% <ø> (ø)
hipBLAS 90.62% <ø> (ø) Carriedforward from a6c8eb0
hipBLASLt 39.06% <59.55%> (+0.02%) ⬆️
hipCUB 82.68% <ø> (ø) Carriedforward from a6c8eb0
hipDNN 86.64% <ø> (ø) Carriedforward from a6c8eb0
hipFFT 54.32% <ø> (ø) Carriedforward from a6c8eb0
hipRAND 76.12% <ø> (ø) Carriedforward from a6c8eb0
hipSOLVER 68.96% <ø> (ø) Carriedforward from a6c8eb0
hipSPARSE 86.99% <ø> (ø) Carriedforward from a6c8eb0
rocBLAS 48.25% <ø> (ø) Carriedforward from a6c8eb0
rocFFT 48.78% <ø> (ø) Carriedforward from a6c8eb0
rocRAND 57.45% <ø> (ø) Carriedforward from a6c8eb0
rocSOLVER 76.83% <ø> (ø) Carriedforward from a6c8eb0
rocSPARSE 74.75% <ø> (ø) Carriedforward from a6c8eb0
rocThrust 93.15% <ø> (ø) Carriedforward from a6c8eb0

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

Files with missing lines Coverage Δ
...hipblaslt/library/src/amd_detail/hipblaslt-ext.cpp 60.10% <ø> (ø)
...c/amd_detail/rocblaslt/src/rocblaslt_auxiliary.cpp 74.56% <100.00%> (-0.02%) ⬇️
...ary/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp 83.82% <75.00%> (-0.08%) ⬇️
...cts/hipblaslt/library/src/amd_detail/hipblaslt.cpp 66.96% <0.00%> (-0.94%) ⬇️
...rary/src/amd_detail/rocblaslt/src/tensile_host.cpp 43.67% <64.47%> (+0.19%) ⬆️
🚀 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.

@jaopaulolc
jaopaulolc added this pull request to stack #13164 October 6, 2026 15:00
@jaopaulolc
jaopaulolc removed this pull request from stack #13164 October 6, 2026 17:24
@jaopaulolc
jaopaulolc added this pull request to stack #13185 October 6, 2026 17:24
@jaopaulolc
jaopaulolc force-pushed the users/jolabega/jit-upstream-01b-jit-gemm-run branch from 8d1d41f to 6c4132a Compare October 6, 2026 18:52
@jaopaulolc
jaopaulolc force-pushed the users/jolabega/jit-upstream-01-jit-interfaces branch from 3db7dd0 to 73e8602 Compare October 6, 2026 18:52
@therock-pr-bot

therock-pr-bot Bot commented Oct 6, 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?

@jaopaulolc
jaopaulolc marked this pull request as ready for review October 6, 2026 18:59
@jaopaulolc
jaopaulolc requested review from a team as code owners October 6, 2026 18:59
@therock-pr-bot

therock-pr-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

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

@jaopaulolc jaopaulolc added the rocm:gemm algos Label to identify PRs of the GEMM Algorithms team. label Oct 6, 2026
Jit runs one operation request for one device target through four stages: a
backend generates library entries, the builder builds them, and a loader
checks which of their solutions support the request and loads those, one
bundle per solution. The requested count counts solutions, not entries. Each
stage is an interface, a failure in one entry skips that entry and is recorded
with its stage, and the scratch directory is kept after a failure. The opaque
Backend, Request and Solution handles in hipblaslt-jit.hpp carry a Jit, an
operation request and a compiled solution.
makeGemmRequest captures a GEMM from the existing descriptors, getJitAlgo
generates, builds and loads a solution for it through a backend's Jit, and
getGemmAlgo returns a hipblasLtMatmul algorithm that carries the solution's
local index and a process-local token for it. get_library_and_adapter resolves
the token to the bundle's library and adapter, so the algorithm runs through
the same argument and launch path as a prebuilt one, including its
synchronization storage.

The TensileLite loader returns a TensileGemmBundle for each supported solution of
a loaded entry, sharing its library and adapter. Its support check reuses
ConstructTensileProblem and the solution's predicates and workspace. With
HIPBLASLT_ENABLE_JIT off, the GEMM data keeps the selected algorithm and scale
layouts, kernels are stored only once they are ready, a reinitialized handle
keeps its synchronizer, running before initialization returns
HIPBLAS_STATUS_NOT_INITIALIZED, and kernel-name lookups for unknown indices
return an empty name.
HIPBLASLT_JIT_TESTING, off by default, compiles a replay backend into the
library. It returns pre-generated source bundles with a solution whose
predicates accept the device and the problem instead of running a generator,
and the comgr builder still builds them.

jit-end-to-end replays the two-solution bundle that jit-bundles writes for
device 0's architecture.
getJitAlgo builds and loads it and returns its first solution for K=512 and
its second for K=256. Each runs an FP16 GEMM through hipblasLtMatmul and
hipblaslt_ext::Gemm, and D is checked against a host reference. It also checks
that a problem neither solution solves is not supported.
jit-disabled checks that a build with JIT off installs no JIT header. The
workflow turns on HIPBLASLT_JIT_TESTING and runs for the host files the GEMM
path changes.
JIT.md describes the internal entry points, the Jit stages, how they count
solutions and their failures, the TensileLite GEMM loader, HIPBLASLT_JIT_TESTING
and the replay backend, and the lifetime of a JIT algorithm. The JIT test
guide adds jit-end-to-end and jit-disabled.
The replay backend is the simplest Backend, and the shared build and load path is what every other backend uses. HIPBLASLT_JIT_TESTING no longer gates it.
@jaopaulolc
jaopaulolc removed this pull request from stack #13185 October 6, 2026 23:16
@jaopaulolc
jaopaulolc added this pull request to stack #13210 October 6, 2026 23:16
@jaopaulolc
jaopaulolc force-pushed the users/jolabega/jit-upstream-01-jit-interfaces branch from 73e8602 to b37eeb1 Compare October 6, 2026 23:16
@jaopaulolc
jaopaulolc force-pushed the users/jolabega/jit-upstream-01b-jit-gemm-run branch from 030745a to b35a2e1 Compare October 6, 2026 23:17
@jaopaulolc

Copy link
Copy Markdown
Contributor Author

Closing this as a review checkpoint. The branch stays, because #13202 is based on it.

Solutions run only as JIT library indices. A query looks up the library first and publishes on a miss. The process-local in-memory algorithm path is not the intended way to run a JIT solution and will be removed on #13202. The pipeline and the replay backend in this branch remain, because a miss still has to build a code object before it can publish.

@jaopaulolc jaopaulolc closed this Oct 7, 2026
@jaopaulolc
jaopaulolc removed this pull request from stack #13210 October 7, 2026 14:50
@jaopaulolc
jaopaulolc deleted the users/jolabega/jit-upstream-01b-jit-gemm-run branch October 29, 2026 21:56
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.

1 participant