Repository navigation
bench has a denominator: cuBLASLt in-process beside the GEMM, and we are at 0.69 of it (#92) - #96
Merged
Merged
Conversation
…s stable, and cuBLASLt prices the target (#92)
feitreim
force-pushed
the
cublaslt-denominator
branch
from
July 28, 2026 20:36
8ed7c06 to
6284824
Compare
This was referenced Jul 28, 2026
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.
Closes #92.
The answer, in one line
At the two largest sizes this kernel runs at 0.69 of cuBLASLt, reproducing
to about 1%. Below 4096³ the comparison is not stable enough to quote — for a
reason that turned out to be the more interesting finding.
The table
Two complete sweeps of this branch, separate sessions, one B200, driver
580.95.05, cuBLASLt 130000.
benchprints the heuristic's pick per row: algorithmid=66at every size inboth sessions, no split-K, and no workspace used at all despite the 32 MiB
offered. Our own figures reproduce #94 (1217.4 / 1236.0 against its 1223.4).
1. A ratio is less reproducible than either number in it
This is counterintuitive and it should not be a footnote. The instinct — and my
stated reason for sweeping twice — is that run-to-run drift moves both sides
together and cancels. It does not, because the variance here is almost
entirely on the baseline side, so the ratio inherits all of it and adds ours
on top. The split is sharp, and it is by size:
Only the bottom three rows carry a quotable ratio. The top four are
dominated by cuBLASLt's own variance — its 256x128x256 figure nearly doubles
between sessions — so
0.751in the table above is noise, not this kernel'sbest row. Two digits is all any ratio here supports, and below 4096³ none is.
That is now written into the README beside the table so the next reader is
stopped before they quote three digits.
2. cuBLASLt at 79–84% of dense peak is the calibration this project lacked — and it prices the target
The library measures 1767.8–1892.4 TFLOP/s, i.e. 1.77–1.89 PFLOP/s. That
independently confirms #90's derived 1550–1800 band for this tile "boundary
overlapped and walk L2-aware" from the outside, and shows it was conservative
rather than optimistic — the honest complaint about that derivation was that it
stacked two assumptions and nothing had ever run there. Something has now.
On the target, one correction worth making explicitly. You framed this as
"the stated goal is 2–2.2 PFLOP/s and the vendor library does not reach it".
The only target written down in this repo is #86's: 1.7–1.9 PFLOP/s at bf16
before precision changes — and cuBLASLt's 1.77–1.89 lands inside that band.
So the written goal is not "most of the way to the library", it is level with
the library: reaching it means matching a vendor GEMM, not approaching one.
That is materially harder than "48% of peak → 80%" sounds. And a target of 2.0+
is above everything cuBLASLt achieved here, so it would require beating the
vendor on its own part, with nothing measured so far suggesting where that comes
from. Both readings are stated in the README; I did not want to transcribe the
2–2.2 figure without noting the repo says something different.
3. The layout caveat in #92 does not apply
#92 asserts
gemm.rsusesencode_bf16_panels. It does not — it builds a TMAmap over a plain packed bf16
[m, k]/[n, k], K contiguous, so both sidesread byte-identical operands and there is no rearrangement on either side to
discount. The descriptor is built once, outside the clock, exactly as cuBLASLt's
layouts and heuristic are.
The real asymmetry is generality: ours computes one form — both operands
K-major,
α = 1,β = 0, no epilogue,m % 256 == n % 128 == k % 64 == 0—while cuBLASLt takes any of it and picks per shape. So 0.69 is an upper bound
on how well this kernel would stand in for one. cuBLASLt also gets a 32 MiB
workspace it does not spend. All of this prints under the table from
benchitself, not only here, because the output gets pasted into issues.
What it says about the levers — nothing that reorders them
The ratio improves with size in both runs (0.573 → 0.689 → 0.694, reproduced as
0.574 / 0.686 / 0.685). Ragged waves go 76.9% → 92.3% → 99.7% and the per-tile
boundary falls by 4× across those rows; cuBLASLt pays neither. The deficit is
largest where the two known fixed costs are largest — #86's finding from
outside.
It does not follow that #15 and #89 close it: at 8192³ they would have to be
worth the whole 1217 → 1768, and #90's steady state for this tile at this shape
was 1500–1670, under what the library achieves. So there is plausibly a residue
that is the tile (#87). No kernel constant moved in this PR.
Two things to file rather than act on, as agreed: the tile question above,
and whether cuBLASLt also loses 23% to aspect ratio. The latter is deliberately
not measured here — the baseline is on
gemmonly, sincegemm-footprintandgemm-depthexist to compare the kernel against itself and each extra rowre-stages operands on the host, the long pole at these sizes. It is a one-word
change,
baseline: CUBLASLTon that case, noted in both the code and theREADME so whoever picks it up knows.
Linking worked — recorded either way, as #92 asked
cargo oxideshells out to plaincargoand only injects a codegen backend viaRUSTFLAGS, so an ordinarybuild.rsemittingcargo:rustc-link-lib=dylib=cublasLtis honoured with nothing special — thesame mechanism
cuda-bindingsuses upstream for the driver. No fallback to aseparate binary was needed, so the baseline goes through the same
bench::time, stream, warm-up and min-of-30, and what differs between the twofigures is the code between the two CUDA events.
The check is the load-bearing part
cuBLASLt is column-major and ours is row-major, so what must be asked for is
Ĉ = Cᵀ = B·Aᵀ = (B̂)ᵀ · — cuBLASLt's first operand is ourbunderCUBLAS_OP_T, its second ouraunderCUBLAS_OP_N. The operands are swappedrelative to the obvious spelling, and the obvious spelling is not slower and does
not fail: it computes a different matrix at full speed. So
gemm::run'sreference comparison was extracted to
gemm::check_cand the baseline is checkedby the same function, not a copy — the one edit to
gemm.rs, pluspub(crate)on the two generators andstage.The comparison stays
==rather than a tolerance: operands are small integers,partial sums stay under 983,040 against fp32's exact 2²⁴, and integer addition in
fp32 below that bound is exact in any order — so whichever tiling or split-K
cuBLASLt picks, the answer is the same integer ours is.
Scope
examples/src/cublaslt.rs— new; the FFI, the layout derivation, the fairnessargument.
examples/build.rs,examples/cublaslt_abi.c— new; the link step, and thehand-transcribed enum values and struct offsets asserted against the real
headers under
gcc -fsyntax-only, so a wrong constant fails the CPU gaterather than a B200 one. It caught nothing, which is the outcome I wanted.
examples/src/bench.rs—BaselineonCase, the comparison table, rule 4 inthe module header. Two type aliases also clear a pre-existing clippy warning.
examples/Cargo.toml—cublasfeature, off by default.modal_app.py— mounts the two new non-src/files, runs the ABI check plus afeature-on clippy and device build in the CPU gate, and passes
--features cublastobench.examples/README.md§7 — the section above, after Two fp32 a store where the layout pairs them, and the boundary intercept says so (#91) #94's.Verification
modal run modal_app.py::build— exit 0 on the rebased tree. Confirms thecrate still builds with the feature off, and additionally builds and lints
it with the feature on, linking real
libcublasLt.modal run modal_app.py::examples—pass gemm,pass softmax,pass layernorm; thecheck_cextraction changed no result.modal run modal_app.py::bench— two full sweeps after the rebase, bothexit 0, no row failing its check. Every figure above is measured.
cargo fmt --checkboth crates, rootcargo clippy --all-targets -- -D warningsclean,cargo test76 + 1.Every timed figure went through the checked path, cuBLASLt included — there is
still no route in
benchthat prints a throughput for a launch it did notverify.