Repository navigation
gemm: replay only the dense MMA cells of an exceptional row or column - #711
Conversation
…rows and columns hold
The dense prompt MMA (bf16_mma_gemm, mxfp8_mma_gemm, fp8_b128_mma_gemm) replayed a whole 128 by 128 tile on the exact F32 owner when one operand of the tile left the tensor cores' range, so every other cell of the tile took the F32-activation value instead of its MMA value: a token's outputs changed with what its neighbours in the ubatch held. Every dense MMA product now marks the cells whose row or column staged such an operand, replays those alone and keeps every other cell's MMA bits, as the HC prompt products already did; bf16_mma_gemm_columns and the const parameters that picked a mode go. The marks are made only when the block's vote finds an exceptional operand, so a tile without one runs as before. The PTX pins follow the GB10 scans: bf16_mma_gemm_columns leaves the tables, the three dense entries stay at 0/0 on sm_86, sm_121 and sm_121a, and hc_gated_up_mma_mix_4 reads 0 sm_86 spill bytes (was 920) with its sm_121 260/96 and sm_86 JIT 96 unchanged.
There was a problem hiding this comment.
Verdict: CLEAN: The replay mask preserves cells outside exceptional rows and columns.
Non-blocking
⚠ Complete the numeric evidence: crates/gpu/src/gemm/f32tile.rs:1015 changes healthy cells beside exceptional operands from F32 replay to MMA precision. The float precision class requires the gate-gpu-e2e count pin and timed A/B; the supplied timing covers ordinary inputs. Add the end-to-end result and an exceptional-input A/B with both tested commit hashes.
⚠ Report the first failed cell: crates/gpu-gates/src/bin/gate_gemm.rs:7015 prints only aggregate booleans. A failed mask requires another probe to locate the error. Include the first failing row, column and MMA/exact bits in this existing report to supply the fix's debuggability layer.
Optimization headroom
- E, Less work: crates/gpu/src/gemm/f32tile.rs:769 still recomputes unmarked subtiles. Skip those subtiles: one refused column in a full 128×128 tile leaves 24 of 32 exact passes unnecessary, including 24×(K/64+1) block barriers [derived].
Checked
Duplicates: 1 new function checked, no duplicate owner. The dryer pair is two format-specific kernel entries calling the same core.
Complexity: dense_mma_case 48→76 adds fixture construction, execution and assertions to an existing function; site_case 40→41 and e4m3_case 28→29 extend existing clauses.
Silent failure: 1 marker path followed: NaN store → barrier → exact replay before consumption; launch/readback errors propagate.
Tests, static mutation: f32tile.rs:718 changing || to && fails exceptional-line assertions; :779 changing marked replay to whole-tile writes fails kept and mma.neighbours; shifting coordinates at :639 fails layout bounds.
Gates: dated PINs explain the narrowed exact assertion, kernel-name replacement and tighter spill pin; no tolerance moved.
Escape catalog: no pattern matched.
Notes
The supplied gate logs omit the tested commit hashes, so GPU evidence is incomplete. Validation here was static; GPU gates were not run.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_bf16.rs, crates/gpu-gates/src/bin/gate_gemm.rs, crates/gpu-gates/src/bin/gate_hc_gated.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Filed outside this PR: #712
85611ac to
18ec450
Compare
There was a problem hiding this comment.
Since the last review, the kernel patch is unchanged. The interdiff replaces the old unsafe-pin edit with a count for the rebased tree.
Verdict: CLEAN: The rebased unsafe pin matches the source count and has a dated reason.
Non-blocking
⚠ Complete the numeric evidence — still open: crates/gpu/src/gemm/f32tile.rs:1015 changes healthy cells beside exceptional operands from F32 replay to MMA precision. The supplied timing covers ordinary inputs. Add the float-precision class's gate-gpu-e2e count-pin result and an exceptional-input timed A/B, with both tested commit hashes, to verify the engine-level effect.
⚠ Report the first failed cell — still open: crates/gpu-gates/src/bin/gate_gemm.rs:7015 still reports aggregate booleans. Each mask failure requires another probe to locate the error. Include the first failing row, column and MMA/exact bits in this existing report.
Checked
Duplicates: 0 new Rust items in the interdiff. Dryer pair read: the two format-specific kernel entries delegate to the same core; no duplicate computation.
Complexity: dense_mma_case 48→76 adds fixture/execution/assertion work; site_case 40→41 and e4m3_case 28→29 extend clauses. All are unchanged since the previous review.
Silent failure: 0 new sites. The replay marker path still has a barrier before exact replay.
Tests: no new or changed tests in the interdiff; prior mutation checks remain applicable. No GPU gates run here.
Gates: gpu blocks tighten 2268→2266 with PIN(2026-10-23) and the kernel-removal reason. Independent recounts match both trees, including unchanged 278 functions and 10 impls; the removed kernel contains exactly two blocks.
Escape catalog: no pattern matched.
Notes
GPU evidence remains incomplete because the supplied runs omit their tested commit hashes. Dryer did not search gpu-gates; the interdiff adds no Rust code there.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_bf16.rs, crates/gpu-gates/src/bin/gate_gemm.rs, crates/gpu-gates/src/bin/gate_hc_gated.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
GB10의 BF16, MXFP8, FP8_B128 prompt 행렬곱에서 값 하나가 텐서코어 범위를 벗어나면 같은 타일의 다른 칸까지 F32 값으로 바뀌던 결함을 고쳐서, 각 칸이 자기 행과 열의 값에만 따르게 하는 수정입니다.
Part of #565. Tracked in #699.
What and why
On GB10 the dense prompt products for BF16, MXFP8 and FP8_B128 weights run on tensor cores (
bf16_mma_gemm,mxfp8_mma_gemm,fp8_b128_mma_gemm). When one staged operand is outside the range the tensor cores take (mma_fits), the tile is recomputed on the exact F32 path. Before this change the recompute replaced every cell of the 128 by 128 tile, so a single subnormal activation changed the output bits of the other tokens in that tile. A normal token's bits therefore depended on which other tokens shared its ubatch, which breaks the per-token bit contract in thewide38.rsmodule doc.The cause is in
bf16_mma_body. WithISOLATE=false, the block vote inMmaTile::needs_replayranreplay::<_, false>, which rewrote the whole tile throughf32_tile_at::<_, _, false>. Onlybf16_mma_gemm_columns(HC down) and the fused HC up mix marked cells per row and column. The defect came in with c7f7f41 (BF16 tensor cores for GB10 dense prompt products) and a0baef9 (replay of exceptional dense MMA tiles), both merged in #668.crates/gpu/src/gemm/f32tile.rsis now the one owner and theISOLATEparameter is gone.MmaTilekeeps each thread's refused staged lines (lines: u32, one bit per weight and activation line) instead of oneretryflag.MmaTile::needs_replaytakes the block vote as before. Only when some warp voted does it write the line flags to the unused stage and mark the cells whose row or column is flagged. A tile with no refused operand pays one vote and writes no flags.bf16_mma_bodystores after the vote. With no replay it stores plainly. With a replay it stores the marked cells as NaN, takes a barrier, andreplayrecomputes only those cells on the F32 path.bf16_mma_gemm_columnsis removed, because it is now the same kernel asbf16_mma_gemm.enqueue_bf16_promptandenqueue_bf16_mmalose their const parameter, and their callers insite.rs,hc_gated.rs,kernels32.rsand the gates follow.bf16_mma_gemm_columnsrows, and the sm_86 spill pin ofhc_gated_up_mma_mix_4moves from 920 to 0 with aPIN(2026-10-23)line. The unsafe ratchet forgpumoves from 2256 to 2254.Inputs with no refused operand keep their bits. Cells next to an exceptional row or column change from the F32 value to the MMA value, which is the rule the HC paths already used.
Release notes: Fixed: on GB10, a dense BF16, MXFP8 or FP8_B128 prompt product recomputes only the cells of an out-of-range row or column in F32, so a token's output no longer depends on the other tokens in its tile.
Code shape
MmaTile::needs_replay, shared by the dense formats and the HC up mix. The duplicate kernelbf16_mma_gemm_columnsis removed.ISOLATEconst parameter, theMARKEDparameter ofreplay,bf16_mma_gemm_columnsand its pin rows are removed.hc_gated_up_mma_mix_4is lowered to the value the scan reads, with aPIN(2026-10-23)line.cargo fmt --all -- --checkis clean. I did not runcargo clippy.Duplication found or removed (
path:line):bf16_mma_gemm_columnsincrates/gpu/src/q8f32.rs:1861duplicatedbf16_mma_gemmonce the marking moved into the shared tile; it is removed.What I ran
The new gate clauses were added first, on the old API, and run against main with only those clauses. Then the same gates ran on the fix.
gate_gemm --case dense_mma: a 130 by 130 output at K = 128 per format (bf16, mxfp8, fp8_b128), unit weights, activations1 + 2^-10(BF16 rounds them to 1, F32 keeps them). Column 129 can hold one subnormal activation and row 64 one weight of 2^60. Three clauses: no odd line, a column, a column and a row. Every other cell must equal K exactly, and the odd lines must equal the exact tile.mma.neighboursingate_bf16andgate_mxfp8(throughsite::gemm, compute capability 12.1): a subnormal first value in column 1 must leave every other column's output bits equal to the run without it.Each
just gate-gpu-*line below names the recipe whose last step I ran,bash tools/gpu-gate.sh <binary>, on binaries built from the fix and, for the FAIL-first, from main plus the new clauses.FAIL-first, on main plus the new clauses:
On main the log marks six
cellsrows FAIL (each format, with an odd column) and leaves the three rows with no odd line without a FAIL. All four BF16mma.neighboursrows and six of the twelve MXFP8 and FP8_B128 rows are marked FAIL. The six scale-edge shapes ofgate_mxfp8leave the odd column's own row exceptional, so main already replays every column there and they do not distinguish the two behaviours.On the fix, GB10 card and gates:
Totals over the full head logs:
gate_gemm70 PASS, 0 FAIL;gate_hc_gated125 PASS, 0 FAIL;gate_bf16309 PASS, 0 FAIL;gate_mxfp8342 PASS, 1 FAIL (see below). Everydense_mma ... eager_graph_bitsrow on the fix readstrue.Normal inputs keep their bits. A kernel micro run on this GB10 (M = 4096 columns, three warmups, ten timed calls, main and head alternated) gives equal output digests on all eight in-range shapes. The largest shape:
I ran
cargo fmt --all -- --checkandtools/check-unsafe.sh, and the workspacecargo check --workspace --all-targetscompiled every crate without a warning. I did not runcargo clippy, the othertools/check-*.shscripts ortools/ptx-compare.sh; those are the maintainers' checks. The gates were run on the commits before the final rebase onto current main. The rebase left everycrates/line of this change as it was and changed only table hunks around the removed rows.Hardware
One DGX Spark (
NVIDIA GB10, driver 595.84, CUDA 13.3), the gate and micro runs above. No other GPU was used. The sm_86 spill pin was read from a build for that architecture, run through the driver JIT on the GB10; no sm_86 card was used, so thejit_localvalue of the cc 8.6 row keeps its existing pin.What I ran into
These do not block this PR.
gate_mxfp8still reportssel.refusalas FAIL. The gate expects "a q8_0 or fp8_b128 stack" whilesite::resident_sel_f32now says "a q8_0, fp8_b128 or nvfp4 stack" after qwen38: load the checkpoint folder MTP draft in its stored formats #682. This change does not touch either side, so I left the gate as it is.replaystill recomputes the full tile on the F32 path and stores only the marked cells, so a tile with one odd column costs several times a normal tile. That only matters for inputs with subnormal or very large values, and it is the same cost as before.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.