Repository navigation
Description
gemm_cg2 accumulates in fp32 tensor memory and writes fp32 C. The
accumulator is right and should not change. The output should be bf16.
bf16 in, fp32 accumulate, bf16 out is the ordinary training-GEMM signature,
and examples/src/cublaslt.rs's own module doc says as much about the baseline:
Upstream's C file uses a 2-byte output and is not [comparable]
So the baseline was bent to match us, and it is our fp32 output that is the
unusual choice.
The baseline must move in the same PR
cublaslt.rs:442 is layout(&mut session.d, CUDA_R_32F, n, m, n)?. It becomes
CUDA_R_16BF. CUBLAS_COMPUTE_32F and the CUDA_R_16BF operands stay.
This is not optional and it is not a detail. At 8192³ an fp32 C is 268 MB
and a bf16 C is 134 MB. Changing ours without changing theirs would compare a
kernel writing half as much against one writing twice as much and report the
difference as a win. Every ratio in examples/README.md §7 is against the fp32
baseline, so the PR has to re-measure the pair, not patch one column.
State clearly which rows are comparable across the change and which are not.
Why this might be worth more than the bytes, and why it might be worth less
Less, on the obvious argument. #107's HotStore probe deleted a gigabyte of
streaming writes and gained 0-1.2% — the epilogue is issue-bound, not
bandwidth-bound. Halving the bytes buys at most that.
And it may not reduce the instruction count at all. Under BaseLdtm the
contiguous run is 2 (#94's CONTIGUOUS_VALUES; the columns are {0,1} then
{8,9}, eight apart), so a bf16 pair is a 4-byte store where an fp32 pair was
8 — the same number of stores, half as wide — plus cvt instructions that
were not there before. On issue-bound reasoning alone this predicts neutral to
slightly negative, and the ratio could move against us since cuBLASLt gets the
cheaper output too.
More, on an argument nothing has tested. stmatrix is b16. It has been
unusable in this epilogue for exactly one reason: C is fp32. #94 §6 and #107
both partly rejected the shared-staging route on that — "getting fp32 registers
into a swizzled shared tile is plain indexed stores plus a
fence.proxy.async.shared::cta", and there is no fp32 SharedTile swizzle
because the atom arithmetic is written around 2-byte elements.
A bf16 output removes that constraint. stmatrix moves a whole tile per
issue, which is the right shape of lever for a bound that is instruction issue.
So #107's rejection of the staging route was conditional on a constraint this
issue removes, and it should be re-opened here rather than treated as settled.
Scope
- bf16
Cfrom an unchanged fp32 accumulator, with thecvtin the drain. cublaslt.rs:442toCUDA_R_16BF, both columns re-measured together.- The exactness check's tolerance will move — the output rounds where it did
not. Say what the new worst relative error is and against what tolerance,
and do not widen the tolerance silently; softmax is now the slow kernel by 5.8x, and its CHUNK rung is only a quarter of it #76's section is the precedent for
how to report an accuracy change that is real and acceptable. - Then ask whether
stmatrixis now reachable. That is the part with real
upside and it is a second measurement, not an assumption — price it before
building it, the way The store stage cost a reordering to try, and it hides nothing (#15) #107 priced its own route withHotStore.
Acceptance
Both columns re-measured in one session, exact at every size before timing, the
accuracy change stated, and a direct answer on whether stmatrix is reachable
and what it would be worth. A finding that bf16 C costs throughput and is
still the right output format is an acceptable result — say so plainly rather
than hunting for a number that makes it look like a win.
Related: #107 (issue-bound epilogue, and the staging rejection this may reopen),
#94 (CONTIGUOUS_VALUES and the fp32 swizzle gap), #9 (the TMA store surface),
#96 (the baseline), #16 (fp8 — a different axis, not this one).
Activity
C is bf16, the accumulator is not, and the baseline moved with it (#108…
A second GEMM, warp-specialized at one CTA per SM — and the second CT…
The item boundary was the epilogue, and BLOCK_K was already right (#114)
Audit the library whole: three doc claims were wrong, and the surface…