Repository navigation
Every step GEMM gets a cuBLASLt denominator at its exact shape and mode, and the fold, not the walk, is what lags - #79
Merged
Merged
Conversation
…oduct The square bench prices one mode pairing; the training step runs fourteen rectangles across three modes. cublaslt::Baseline learns the kernel's other form (dW += At*B over native [K, MN] panels, beta = 1) and the fp32 output element, and bin/model_shapes.rs reports every step GEMM at its exact shape and mode against that matched denominator, same buffers, same clock.
f32_store_transposed fills the mode grid's hole (mode 2, MN-major) and the bench times store / store-T / acc-T at each dW shape, one variable apart each, after checking store-T agrees bitwise with a from-zero acc-T.
This was referenced Aug 4, 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.
What
The square bench prices the tcgen05 GEMM at one mode pairing per element; the training step runs fourteen rectangles across three modes, and the step profile's per-row rates spread 0.82–1.55 PF/s with nothing to divide them by. This PR gives every step GEMM its own denominator at its exact shape and mode:
cublaslt::Baselinelearns the kernel's other form (Form::AccumulateTransposed:dW += Aᵀ·Bover the native[K, MN]panels,β = 1) and the fp32 output element, so the weight-gradient rows divide by the matched cuBLASLt product rather than by a store they are not.bin/model_shapes.rsreports ours vs cuBLASLt at all fourteen shapes — same buffers, same stream, same clock, each cuBLASLt configuration checked against the kernel's output at a rectangle before its time is believed.Tcgen05Gemm::f32_store_transposedfills the mode grid's hole (mode 2, MN-major — the kernel always tookmodeandtransposedindependently; no adapter said so), and the bench uses it to price the MN-major walk and the fold's read ofCapart at each dW shape, after checking store-T agrees bitwise with a from-zero acc-T.FEATURES=cublas ./run.sh gemm model_shapesto run. No kernel changes; ptxas budgets unmoved.Results (B200, cuBLASLt 13.0, main @ cebec1c + this bench)
(rates in TFLOP/s; bold = below 0.90; run1 reproduced every row within ~2%)
Walk and fold priced apart at the dW shapes (ours only):
Reading
The ratio is a function of K depth and drain kind, not of shape family or the transposed walk. Every mode converges to ~0.92–0.94 of cuBLASLt at K ≥ 8–9k and decays as K shrinks: 0.72–0.78 at K = 3–4k for f32 store, 0.81 for bf16 store, 0.59–0.67 for the fold at K = 6k. The fixed per-item epilogue — which
pipeline::runserializes against the next item's TMA/MMA — works out to ~6–7 µs (bf16 staged drain), ~10–13 µs (f32 scattered drain), ~30 µs (f32 fold) per[256,256]tile, and the MMA that has to amortize it is ~26 µs per 3072 of K. ferro-kittens #114 measured the drain exposed at square shapes; these rows put a per-shape price on it at the model's K depths.The two profile suspicions resolve as follows.
ld.global.v4in front of the scattered fp32 drain): +6% at K = 24576, +26–29% at K = 6144. The profile's 0.91–1.06 PF/s weight rows are the per-expert K = 6144 folds, reproduced here at 964–1162 TFLOP/s.No cheap config-level fix exists, which is why this PR ships the measurement and nothing else:
BLOCK_N = 128breaksHALF_N == BLOCK_M(one stage type serves both operands), the hardcodedMmaShape::M256_N256, theSHARED_BYTES/MAX_CLUSTERSasserts, and the 2-CTA/SM residency the TMEM term pins; ferro-kittens GEMM parity residuals: lm_head fwd at ~0.895, FEED bandwidth term (low priority) #87 measured those rungs losing at depth and The batch the B200 holds is 21, and the one worth taking is 16 #105 already tracks "nothing picks between the two tiles".GROUP: a feed/L2 knob, and the walk decomposition shows the feed is not where the money is.The real remedies live in ferro-kittens, and are known there: hiding the drain behind the next item's MMA needs a second TMEM slot that
BLOCK_N = 256at 2 CTAs/SM cannot allocate (512 columns is the whole budget); the fold's round trip would be deleted outright by reduction TMA stores (cp.reduce.async.bulk.tensor, ferro-kittens #42); the scattered fp32 drain is GAPS.md §2.6 / #174. What this bench adds to those threads is the price at the training step's shapes: ~4.3 ms/step of recoverable time against cuBLASLt parity, most of it in the shallow-K forward stores and the per-expert folds.