Repository navigation
gemm: run MXFP8 prompt sites W8A8 on activations prepared once - #769
Conversation
On GB10 an MXFP8 dense site's MMA tile decoded the weight's E4M3 values and rounded its F32 activation pieces to BF16 in every row block of the product, then ran BF16 MMA. The walk now writes an MXFP8 form of a model-width input once beside its q8 scratch (GemmAct32::with_form with MmaForm::Mxfp8, and mxfp8_cols: E4M3 values, one UE8M0 scale a block of 32 and a refusal word a column), and mxfp8_w8a8_gemm multiplies the stored weight against that form with the block-scaled m16n8k32 E4M3 MMA, copying both operands with cp.async as the BF16 form's tile does. A column holding a value the BF16 tile's rule refuses (mma_fits) and a weight row with a block scale byte outside 10..=165 replay on the exact owner from the f32 rows and the stored weight. The shared MMA tile takes block-scaled operands (MmaRows::SCALED, scale_word and mma, MmaCols::scale_word): K counts 16-bit units, E4M3 pairs stage like BF16 words, and each quad lane loads the scale words its MMA's thread-id selectors name. GemmAct32 holds both forms through MmaForm and ColsForm; a quantizer launch or a fill forgets both. site::resident_gemm takes the W8A8 entry for an E4M3 weight with MXFP8 scales when the rows hold the form, and the Qwen3.8 wide walk reserves the hidden, attention and FF inputs' forms (ACT_FORMS_TOKEN_BYTES). The MXFP8 device code lives in nvfp4mma.rs, built for sm_120a and sm_121a; other builds refuse the two entries by name. gate_gemm's mxfp8_w8a8 case checks the form against a host quantizer, the product against an f64 oracle at ragged shapes, the exact owner's columns and rows, and the stale and misplaced forms. Its graph check and dense_mma's BF16 form check replay over a form rewritten from zeros after the capture, so a graph without its form launch fails.
There was a problem hiding this comment.
Verdict: CLEAN: No demonstrated behavior defect or proven quality defect survived review.
Non-blocking
⚠ Attach the precision-change gate: crates/gpu/src/gemm/f32tile.rs:1557. Activations now round to E4M3 instead of BF16. The precision change class in AGENTS.md requires the gate-gpu-e2e count pin. Attach that recipe's output for the final head; the kernel oracles do not exercise model integration.
⚠ Complete the A/B reproduction evidence: crates/gpu/src/site.rs:1050. The timing section omits the measured branch SHA, exact model file and runnable request command with output. Supply both measured SHAs and the complete commands. The card and gate output alone do not satisfy the evidence list.
Optimization headroom
- G, Per-launch and per-sync fixed cost: crates/gpu/src/site.rs:1224. Write the form in its existing producer. For m columns of width K, this removes 1/m launches and 4K bytes of F32 reads per token [derived].
Checked
Duplicates: 60 added definition headers checked, including renamed items and trait implementations; no actionable duplicate. Dryer returned zero pairs in model; GPU and gate owners were Grepped manually.
Complexity: new mxfp8_w8a8_case (90) spans form/oracle, product/graph, replay and refusal stages, the natural split points. gemm 38→41 adds dispatch; dense_mma_case 108→110 adds graph preparation; run 19→20 adds one case.
Silent failure: six production sites followed. Optional reserve/form absence is valid; tail clamps feed only live output stores; refused non-finite columns replay exact NaNs and reach the existing fault checks.
Tests: dropping the form launch breaks graph equality; reversing scale bytes breaks the oracle; retaining a form after fill breaks refusal checks; changing reserve bytes breaks the placement assertion. These are assertion checks, not a local GPU run.
Gates: no tolerance moved; unsafe-count and replacement reserve-test pins carry dated reasons.
Adversarial checks: minimum K=128 supplies both initial stages; ragged tiles keep accesses inside live operands; stale pointers and excess columns fail the form guards.
Escape catalog: C1–C4 do not match this diff. No ledger lessons apply.
Notes
Static review only. GPU gates and PTX comparison were not rerun. GPU evidence is incomplete because the supplied run does not identify both tested commits.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_gemm.rs, crates/gpu/src/arch/qwen3moe/body38.rs, crates/gpu/src/arch/qwen3moe/plan38.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. |
|
Follow-up evidence for this PR, collected after the merge. Precision-change gate. The activations at the MXFP8 sites now round to E4M3, so this change is in the float precision class of AGENTS.md, whose runtime gate is the V2-Lite has no MXFP8 weights, so this run shows that the count pin did not move. The W8A8 path itself is checked by Reproducing the timing in the body.
NVFP4 checkpoint. The body left its prefill undecided. Its dense sites hold BF16 weights and do not take the new path, but they share the widened tile. I benchmarked the four shared entries ( Lint and spill. On the merged head, (AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.) |
GB10에서 MXFP8 dense 곱셈이 활성값을 한 번만 MXFP8로 양자화해 두고 FP8 텐서 코어(W8A8)로 계산하게 해서 prompt 처리 속도를 높이는 속도 PR입니다.
Part of #565.
What and why
On a GB10, the MMA tile of a dense MXFP8 site decoded the weight's E4M3 values and rounded its F32 activation pieces to BF16 in every row block of the product, then ran a BF16 MMA. The walk now writes an MXFP8 form of each model-width input once, beside its Q8 scratch: E4M3 values, one UE8M0 scale per block of 32 values and a refusal word per column.
mxfp8_w8a8_gemmmultiplies the stored weight by that form with the block-scaledm16n8k32E4M3 MMA, and the shared tile's cp.async pipeline, ldmatrix loads and exact replay serve both operand kinds.A column holding a value the BF16 tile's rule refuses (
mma_fits) and a weight row whose block scale byte lies outside 10..=165 replay on the exact owner from the F32 rows and the stored weight.crates/gpu/src/gemm/act32.rs:GemmAct32holds the BF16 form and the MXFP8 form (MmaForm,ColsForm,with_form).enqueue_mxfp8_colsfills the MXFP8 form. A quantizer launch or a fill forgets both forms, and a GEMM reads a form only when its rows, column count and kind match.crates/gpu/src/gemm/nvfp4mma.rs(built forsm_120aandsm_121a): the kernelsmxfp8_colsandmxfp8_w8a8_gemm, with host wrappersKernels::mxfp8_colsandKernels::mxfp8_w8a8. Other builds refuse both entries by name.crates/gpu/src/gemm/f32tile.rs:MmaRowsandMmaColsgain aSCALEDoperand kind withscale_wordandmma. A scaled operand counts K in 16-bit units, so a pair of E4M3 values stages like one BF16 word. Each quad lane loads the scale words its MMA's thread-id selectors name.crates/gpu/src/site.rsand the Qwen3.8 wide walk (wide38.rs,body38.rs,plan38.rs):resident_gemmtakes the W8A8 entry for an E4M3 weight with MXFP8 scales when the rows hold the form.write_formswrites only the forms a site reads and forgets the rest.crates/model/src/arch/qwen35moe/place.rs: on a unified card the named reserve for the forms is 14,772 B per position, the BF16 form's share and the MXFP8 form's share together. A discrete card reserves none.crates/gpu-gates/src/bin/gate_gemm.rs: the newmxfp8_w8a8case (details under Tests and FAIL-first), and the BF16 form's graph check indense_mmanow replays over a form rewritten from zeros after the capture, so a graph that lacks its form launch is caught.tools/unsafe-ratchet.txt(with aPINline),tools/ref/ptx-shapes/sm_121a-cc12.1.tsv(rows for the two new entries) and one sentence indocs/contrib/dgx-spark.md.Release notes: Changed: dense MXFP8 prompt products on GB10 run on FP8 tensor cores over activations quantized once per input.
Code shape
bf16_mma_bodywith block-scaled operands, so there is one tile, one exact replay and one tail rule. Column refusal reusesmma_fits,form_colandstore_refused, shared with the BF16 form.PlaceError::Bf16FormReservebecameActFormsReserve, and the removed refusals ofenqueue_bf16_colslive on inform_launchandheld_form.PINline. The placement test that checked the BF16 reserve is replaced bya_unified_stage_reserves_the_act_formswith aPINline.cargo fmtis clean.cargo clippywithCUDA_OXIDE_TARGET=sm_121awas not run, becausenvfp4mma.rsis built only forsm_120aandsm_121aand the default lint does not see it.Duplication found or removed (
path:line), or "none": none added.crates/gpu/src/gemm/nvfp4mma.rs:481(the E4M3m16n8k32MMA with thread-id selectors) andcrates/gpu/src/gemm/nvfp4mma.rs:305(the FP4 routed MMA) use different instructions and operand shapes.mxfp8_colsandbf16_colsare separate kernel entries over different planes, and both callform_col,mma_fitsandstore_refused.What I ran
Hardware and builds
The timed run and the gates ran on one DGX Spark (GB10) at the default
sm_121atarget. The card asnvidia-smireports it on the gate run:The same card on the timed run:
Speed
Upstream main
608c0909a8a4deeea2dcd3f33eef6a1ecd36e024and the branch were built on the same machine atsm_121awithcargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features glm5next,clef,mimo2,solar2,minimaxm3,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve. Each checkpoint was served withbloomery-serve -m <model> --host 127.0.0.1 --port <p> --parallel 4 --ctx-size 16896andBLOOMERY_DRAFT=off. The models are the FP4-Local and NVFP4 Qwen3.8-Flash-Next checkpoints. The request is a 4,096-token code prompt on/completionat concurrency 1, temperature 0 and 128 output tokens. Main and head alternated in one sitting after a discarded warm load, and the GPU clock cap was lifted only while an arm's requests ran. A cell is the median of the arm's requests.FP4-Local: prefill +12.7 % and +12.9 %, TTFT -11.2 % and -11.4 %, decode -0.36 % and +0.27 %
The two pairs agree within 1 % of each other, and decode does not move. This is one sitting with two pairs, not a significance test.
The kernel times of one profiled FP4-Local 4,096-token prompt show where the time went:
mxfp8_mma_gemmtook 624.4 ms over 396 launches. On the head,mxfp8_w8a8_gemmtakes 247.6 ms over 396 launches andmxfp8_colstakes 53.2 ms over 192, which is 300.8 ms together. Summed kernel time falls from 2,678.8 ms to 2,355.1 ms.Output parity
Greedy 128-token outputs on FP4-Local match main for two of three prompts. The third diverges at character 313 (main continues "# handle the individual names", the head "# handle the internal names"), and both continuations are valid code. The divergence sits at the same place in both repeats. The NVFP4 checkpoint's greedy output equals main's. KL was not measured.
Tests and FAIL-first
Each gate case ran with
bash tools/gpu-gate.sh gate_gemm --case <case>, the gate step of thejust gate-gpu-gemmrecipe, on the card above:The
dense_mmarun includes the 32 newmxfp8_w8a8rows.cargo test --release -p bloomery-model --lib -- qwen35moe::placegavetest result: ok. 31 passed; 0 failed, includinga_unified_stage_reserves_the_act_forms.The new
mxfp8_w8a8case holds:mxfp8_w8a8_form: the written form equals a host quantizer (mxfp8_reference, an independent implementation of the same rule) cell for cell.mxfp8_w8a8: shapes (129,128,127), (129,128,128), (129,256,129), (257,128,257), (128,640,129) and (17,640,3) equal an f64 oracle bit for bit on exactly representable inputs, with eager equal to graph and the guard words after the output intact.mxfp8_w8a8_neighbours: a column carrying 0x00000200 (subnormal), 0x57800000 or NaN takes the exact owner's bits, and every other cell keeps its W8A8 bits.mxfp8_w8a8_scale_edges: weight rows with scale byte 9 or 166 go to the exact owner, rows with 10 or 165 stay on the MMA.mxfp8_w8a8_refused: other rows, more columns, a BF16-only form, a stale read, a read after a quantize, an unaligned weight and K not a multiple of 128 are each refused by name.FAIL-first, each mutant built and run against
mxfp8_w8a8, both red with rc 1:fillkeeping the MXFP8 form:FAIL_FIRST M1 rc=1 pass=24 fail=8, withcells_off_reference=1592in the form row, all sixmxfp8_w8a8_scale_edgesrowsbytes_9_166_exact=falseandafter_quantize=falsein the refusal row.FAIL_FIRST M2 rc=1 pass=19 fail=13, withcells_off_reference=14786in the form row.Device code on
sm_121a: the PTX spill pin check over the dense MMA entries and the form kernels gaveentries=17 pinned=17withviolations=0. The newmxfp8_colsandmxfp8_w8a8_gemmhave spill 0 and local 0, with 28 and 128 registers.Static checks:
./tools/mac-check.sh checkwith and withoutCUDA_OXIDE_TARGET=sm_121aexit 0 with no warnings,./tools/mac-check.sh fmtis clean, andtools/check-unsafe.shandtools/check-ptx-names.pypass.Heads
The speed A/B ran on the branch before it was rebased onto current main and before the two graph checks in
gate_gemm.rschanged. The device and host code of this PR and its build path are the same as the measured tree's, and range-diff over the rebase shows only changed context in the gate case list, one import line and the unsafe ratchet count. The speed deltas are each tree against its own base and are not a fresh measurement on current main.After the rebase the gate cases ran again, on the DGX Spark at
sm_121aand on an RTX 5090 atsm_120a, with the same result on both cards. The only later change boxes the twoRouteXvariants and turns twochunks_exactcalls in the gate's reference intoas_chunks, for clippy; it moves no device code.The two graph checks now count the form launch inside the capture. With the capture leaving the form launch out, both cases turn red on the RTX 5090:
Reproduction
just gate-gpu-gemm --case dense_mma just gate-gpu-gemm --case nvfp4_native just gate-gpu-gemm --case nvfp4_swiglu cargo test --release -p bloomery-model --lib -- qwen35moe::placeFor the timing, build upstream main and the head at
sm_121a, serve the FP4-Local checkpoint with the draft off, and send greedy requests of a 4,096-token prompt and 128 output tokens, alternating the arms.What I ran into
This does not block the PR.
sm_121andsm_86,ptx-compare, andcargo clippyforsm_121a.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.