Repository navigation
Conversation
…s too (#138) #138 asks which of TMA feed cadence, MMA issue cadence or epilogue overlap the remaining gap is, with no profiler to ask. This decomposes it two ways that do not depend on one — arithmetic, then ablation — and they agree. `bench sol` leads with the term that needs no measurement. Both shared plans admit one CTA per SM, a cluster is two CTAs, so a wave is 74 clusters and the launch is one cluster per output tile: 4096^3 is 256 clusters over four waves, a 0.865 ceiling before any cadence is measured, and 8192^3 is 0.988. The sawtooth table proves that is the whole shape dependence rather than asserting it — `N` in tile steps, and the quantization-corrected rate is flat to 0.6% at M512 across five shapes whose predicted ceiling spans 0.865 to 1.000. The three suspects are the same device body at three values of a new `ABLATE` const, so no arm can drift from the kernel it decomposes and the shipped kernels are that body at `WHOLE`. Every barrier survives every arm; only a phase leaves. `regcount`'s census is the proof and reads exactly that way, and the two shipped kernels stay opcode-identical between the crates. The depth ladder is a straight line in `K` — 0.5% over an eightfold range at M512 — so the launch is a per-tile constant plus a per-K-block rate, and both fall out. The M512 K loop runs at **99.4% of tensor-core peak**; its entire deficit is 12.7 us per tile, of which the drain is 9.99. M256's K loop runs at 75.8%, which is a cadence and not a constant. Subtracting the arms gives an additive budget that reproduces both launches: | term | 4096^3 M256 | 8192^3 M512 | | --- | ---: | ---: | | arithmetic at peak | 58.1% | 83.4% | | wave quantization | 9.1% | 1.0% | | epilogue | 19.7% | 11.9% | | TMA feed in situ | 5.3% | 1.4% | | MMA issue cadence | 7.9% | 2.2% | The epilogue is the largest single loss at both shapes and is 11.9 of the 13.2 points between 8192^3 and peak. It costs the same per byte of `C` in both variants — 25.3 and 26.2 GB/s per cluster — so it is the LDTM/stmatrix/store chain running at a fixed rate, not a bandwidth and not a variant. The feed is not the problem anywhere: it moves the whole launch's operands in half the launch, at 18-22 TB/s. Also: #138's profiler finding re-derived and its two escapes closed. `NVIDIA_DRIVER_CAPABILITIES=all` is already in the container and is not the lever, `ncu` fails identically on a four-line nvcc kernel, and NVIDIA's own 580 component list has no performance-counter library to withhold. `scripts/fmt` also picked up three pre-existing hunks in `src/shared.rs`.
… and the rule that picks them `gemm_sol`'s 0.795 at 4096³ reads like tile quantization. It is not, and the tables say so before they say anything else. Residency is one CTA an SM — both shared plans exceed half of the 233472 B an SM divides — so a `cta_group::2` pair is 74 clusters on 148 SMs. At 4096³ the `[256, 256]` tile is 256 clusters over 4 waves and 13.5% of the grid idles; `[512, 256]` is 128 over 2 and idles the same 13.5%, which is what makes that pair a controlled comparison of everything except quantization. At 8192³ both are 0.988 and quantization predicts nothing about that shape's gap at all. The model is measured, not assumed: sweeping `m` in tile steps at `n = k = 4096` swings throughput 8.7% and the same numbers divided by the predicted wave efficiency are flat to ±2%. CLC work stealing runs throughout, which settles what it is worth — it removes the static share of the tail and cannot remove the integral one. And it buys nothing against the baseline, because cuBLASLt pays the identical sawtooth: its heuristic prints 3.46 / 3.89 / 4.32 / 4.76 waves at those four shapes, which is our own tile count over 74 to three digits, on the same `tile=23` from 2048³ up. Quantization divides out of the ratio exactly, so 4096³'s deficit is a rate deficit and belongs to #144's per-tile constant and K-loop cadence. Every lever that buys the quantization back loses, and all of them are kept: - `[256, 128]`, which reaches 0.988 at 4096³, is 0.80 there and 0.63 at 8192³. The two shapes where efficiency does not move price the tile alone: 1.5× the operand traffic per flop and twice the per-tile constants, worth −7% at 2048³ and −37% at 8192³. - `[512, 256]` at 4096³ is a dead heat at 0.985, inside a 4% spread. #138's crossover at 8192 is right and now has a reason. - Split-K doubles the epilogue, which #144 prices at 19.7% of the 4096³ launch, to recover 8%. Stream-K pays 5.7% for the same 8%. cuBLASLt reports `splitk=1 reduction=0 workspace=0 B` at every shape here. - The N band is flat to 0.2% over `{1,2,4,8,16}` at 8192³ and inside its rows' own spread at 4096³, so `group` becomes a launch parameter and its default does not move. What did move is below 2048: halving `N` doubles the wave efficiency only while both tile counts fit one wave count, and there the narrow tile is 1.27–1.29×. `select_variant` is that sentence, taken twice round-robin because a 1024³ launch is 17 µs. 1024³ goes 0.567 → 0.731 of cuBLASLt and 1536³ 0.597 → 0.760, with every shape at and above 2048³ left on the entry it already had. `Small` is one width-generic entry rather than two, `Common` gives up the B ring to the entry that sizes it, and all three entries are exact over every BF16 output at 1024x1024x512.
… the two arms it was missing
…g ladder, and one wait a band where there were two The epilogue is the largest single term in `gemm_sol` at both shapes with a gap. #144 measured it at 19.7% and 11.9% of the launch and left two things fused: the drain's own cost and its failure to overlap. This separates them, prices the chain a third at a time, and ships the one lever the split says is worth anything. Three new `ABLATE` arms make a doubling ladder, each repeating one more pass of the drain per band with the extra global stores aimed at the cluster's own first output tile so they stay in L2. An extra pass has nothing left to hide behind, so it is paid serially by construction: `twice all - whole` is the drain's own occupancy cost D, and `whole - no drain` is what the launch pays. E > D at both shapes. None of the drain is hidden, and at M256 -- where the accumulator IS double-buffered across tiles -- E is 191% of D, so the drain also slows the phase it runs beside. The LDTM half is free: doubling `tcgen05.ld` and its waits costs zero. What is left is the register->shared half, at 60-70% of D. Two drains built on that. `paired` puts a band's two LDTM issues in flight before one wait and ships (+0.9% at 8192^3, nothing at 4096^3, two round-robin passes each, every census column but the wait identical). `wide` puts four behind one wait and loses. New: `TmemTile::tile_x8_batched`, an `ldtm.wait` census column, a `ldtm x8 batched map` device case, six ablation arms, two tables, and a correctness gate for the arms that compute a right C.
…r on the drain that ships
…rithmetic on global_k
…claims the measurements killed
…m, and the PTX says so
…and re-open the barrier-address lever
…rain dial are two axes
…olded, and the fold's win is where #148 said
feitreim
marked this pull request as ready for review
July 30, 2026 01:10
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.
Status
This is a WIP port of NVLabs
gemm_sol_finalimplemented through ferro-kittens library primitives rather than copied low-level CUDA device code.Correctness and integration are working. Performance is close to cuBLASLt at 16K, but the requested dead-even target is not met yet at 4K/8K.
Implemented
ClcQueue/ClcCursorcta_group::2MMApipeline::groupedpipeline::Jobitem boundariesexamples/src/gemm_sol.rsThe B200 measurements select M256 at 4K and M512 at 8K/16K. Upstream selects M512 only at 16K; the earlier crossover is retained here because it materially improves 8K on this B200.
Validation run
cargo test: 96 unit tests passed, 1 integration test passedmodal run modal_app.py::build: passed, includingsm_100acodegen and the cuBLAS feature buildmodal run modal_app.py::examples: passedCurrent B200 performance
Live comparison against cuBLASLt 13.0 FP16 input / FP32 compute / FP16 output, same process, stream, event clock, 5 warmups, minimum of 30 launches:
Measured tuning so far:
G=4versus upstreamG=8at 8K is neutral.Remaining work
Notes
The benchmark baseline is the closest cuBLASLt combination supported by this stack: FP16 inputs, FP32 compute, FP16 output. The kittens kernel writes BF16, so final conversion differs while input compute precision and output width match.