Repository navigation
HIP: rocBLAS BF16 projections with FP32 sums - #1930
Merged
Merged
Conversation
14 of 26 tasks
This was referenced Nov 2, 2026
Merged
OCR families on HIP need dense BF16 projections that accumulate in FP32 and round to BF16 only once. A new hip.blas module loads rocBLAS as an optional runtime library, binds a handle to the caller's stream, and offers project and projectAdd; projectAdd adds the existing output, such as a bias row, before that single rounding. Both refuse impossible geometry and aliased outputs before any library call. The build adds test-hip-blas-host for those refusals and build-hip-blas-test for device checks against exact integer dots, and RUNTIME.md lists the new optional rocBLAS dependency.
ashhart
force-pushed
the
pr-ocr-hip-blas
branch
from
November 2, 2026 15:51
51c6891 to
6e811dc
Compare
Owner
|
Thank you @laudney. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
Owner
|
Thanks @laudney! This is in TensorFold 1.2.2, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1927.
The OCR checkpoints in #1927 ship BF16 weights, and their image towers and decoders need many dense BF16 projections. The HF references compute these with FP32 accumulation and one BF16 rounding of each output, and some add a bias inside that one rounding. This PR adds that one operation on HIP through rocBLAS, as an optional runtime library like the existing ones, so later family PRs share one tested path. They do not each bring their own GEMM.
hip.Blas.project(rocBLAS)hip.Blas.projectAddpackaging/RUNTIME.mdChanges
zig/src/hip/blas.zig:Blas.open(stream)loads rocBLAS, resolves its symbols and binds a handle to the caller's device context and nonblocking stream.projectcomputes BF16x[M,K]times BF16w[N,K]transposed into BF16out[M,N], with an FP32 scalar and accumulator.projectAddadds the existing BF16outto the FP32 dot before its one BF16 rounding. A bias row uses this epilogue.Shape.ofrefuses zero sizes and sizes past rocBLAS'sintarguments, and byte extents are checked for overflow, before any call.platform/optional_libraries.zig: arocblasentry (librocblas.so.5, thenlibrocblas.so, then/opt/rocm/lib/librocblas.so) with its ownRocblasUnavailablefailure and install hint.packaging/RUNTIME.mdlists it.test-hip-blas-host(shape and admission checks, no device) andbuild-hip-blas-test(device checks,zig/tests/hip/blas_test.zig). The device checks need exactly one visible device.Gates
zig build test-hip-blas-host -Dhip=true: 2/2.tf-hip-blas-teston a Radeon AI PRO R9700 (gfx1201), 3/3:zig build test -Dhip=truewith this PR and the prompt-cache PR: 492/492 steps, 6,187/6,234 tests (47 skipped).