Repository navigation
gpu: finish the MXFP8 gate projection and its output form in one epilogue - #819
Conversation
The Qwen3.8 delta layer's gated norm output feeds the MXFP8 output projection, which needs its MXFP8 form. A separate mxfp8_cols launch read the 4096 x 4096 f32 rows back to write it. The MXFP8 norm-gate epilogue now writes the form from the values it holds, bit for bit mxfp8_cols's, and ORs each column's refusal across its heads. The site takes this path only when that form is all the readers take from the scratch, and quantizes for them itself otherwise.
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix finding remains; the GPU evidence request is non-blocking.
Non-blocking
⚠ Complete the GPU evidence: crates/gpu/src/gemm/f32tile.rs:2043.
This folds launches into the projection epilogue: three graph nodes become two per MXFP8 projection. The PR body supplies gate summaries and A/B medians, but omits both measured commit hashes, actual model filenames, and the gate command with its output.
Attach the owning gate command and output, measured hashes, model filenames, and reproducible A/B commands and output to complete CONTRIBUTING.md's evidence list.
Checked
Duplicates: diagnostics report zero qualifying dryer pairs in crates/gpu; gpu-gates was outside the scan.
Complexity: diagnostics report norm_gate_case 88 → 190 and resident_gemm_norm_gate 6 → 21. Complexity alone produced no finding.
Dispatch: incompatible output readers retain the split path and resident_quantize. The fused launcher clears output refusal words before its kernel.
Tests: norm_gate_case checks split_bits, out_form_bits, graph parity, and scratch reuse. Removing the refusal memset at crates/gpu/src/gemm/nvfp4mma.rs:1786 fails scratch_reuse according to the author's mutant report. GPU gates and the mutant were not run here.
Gates: new unsafe and PTX resource allowances carry dated PIN reasons.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_gemm.rs, crates/gpu/src/arch/qwen3moe/wide38.rs, crates/gpu/src/gemm/act32.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. |
Qwen3.8 FP4-Local의 선형 어텐션 층에서 gate projection이 공용 norm과 다음 층이 읽는 출력 양자화를 자기 store 단계에서 한 번에 끝내도록 합니다.
What and why
In a Qwen3.8 FP4-Local checkpoint, the z gate projection of each Gated DeltaNet layer is an MXFP8 W8A8 product. After it, two more launches ran: the shared sigmoid head norm (
gdn_norm_gate_sigmoid) andmxfp8_cols, which quantizes the norm output into the MXFP8 form thatssm_outreads. A request ran each of them 36 times.This PR lets the product's store epilogue do both.
bf16_mma_norm_gate_bodyis now generic over the MMA operand views, so the block-scaled E4M3 tile (MXFP8) shares it with the BF16 tile. A new kernelmxfp8_w8a8_norm_gateand host entryenqueue_mxfp8_w8a8_norm_gateuse it. TheNormFormtrait names what the epilogue writes beside the f32 values: nothing for the BF16 entry, and for the MXFP8 entryMxfp8Out, which writes the E4M3 words, the UE8M0 scale words and the column refusal word (OR-ed across heads, zeroed by a memset before the launch).site::resident_gemm_norm_gatetakes the output's readers and its scratch, reads the MXFP8 weight planes through the existingWeights::e4m3owner, and uses the MXFP8 epilogue only when the readers take just the MXFP8 form from that scratch. In every other case it runs the split product, norm andresident_quantize. The wide Qwen3.8gdnno longer callsquantize_forafter the norm.NVFP4 does not change. Its z projection is BF16, so it takes the BF16 arm, and the
resident_quantizeafter it issues the same launches as before. The gate shows that the fused result is bit for bit the split result (split_bits) and that the output form matchesenqueue_mxfp8_cols(out_form_bits).Release notes: Changed: Qwen3.8 FP4-Local prompt prefill finishes the linear-attention output gate and its MXFP8 output form in the gate projection's store epilogue.
Code shape
The review reads these first. A box left unticked needs one line of why.
ue8m0_blockis now the one owner of the UE8M0 scale rule (mxfp8_cols_bodyuses it),GemmAct32::roomthe one owner of the form room check (form_launchuses it),mxfp8_mma_launchthe one owner of the MXFP8 launch check (enqueue_mxfp8_w8a8uses it), andreads_q32the one owner of the question whether a site reads q8 blocks of 32 values, lifted out ofresident_quantize.quantize_forcall after the norm and the closure inresident_quantizeare removed.cols_refused,mxfp8_refused).PIN(2026-10-25):line and its reason.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": the duplicate scan reports three candidates.crates/gpu/src/gemm/nvfp4mma.rs:1403andcrates/gpu/src/gemm/nvfp4mma.rs:1346are two kernel entries over the shared tile body with the flat arguments a kernel ABI needs.crates/gpu/src/gemm/nvfp4mma.rs:1403andcrates/gpu/src/gemm/kernels32.rs:1164differ in tile, format and epilogue.crates/gpu-gates/src/bin/gate_gemm.rs:7615andcrates/gpu-gates/src/bin/gate_dspark_graph.rs:1176are an arm-name match and an argmax comparison.What I ran
Format and lint, on this head:
cargo fmt --all -- --checkwas clean.just lintwith the sm_121a target on a DGX Spark ended with rc 0 and 3 warnings, the same count as main.GPU Evidence
Card conditions of the timed runs and of the gate, from
nvidia-smi:The gated-projection cases (
zgate) ofgate_gemmran on this head on a DGX Spark, both for the BF16 and for the MXFP8 form, on the normal edge at five shapes (the largest 6144 rows, K 2560 and 4095 columns) and on the NaN, out of range, overflow and gain edges. The output summary:All 28
zgaterows passed, none failed. The rows checksplit_bits,out_form_bits,eager_graph, the scratch contract,scratch_reuseand the fault sites.scratch_reuseruns one launch whose output columns are all refused and then a normal launch into the same output scratch, once eagerly and once as a graph replay, and compares the next product bit for bit with the split path. The refusal cases for the column and room checks are in the same run.just gate-gpu-gemmnot run as the full recipe: thezgaterows above ran from the samegate_gemmbinary, and a maintainer runs the recipe on the workstation.A mutant that drops the refusal OR from the epilogue fails
out_form_bitson the MXFP8 normal and gain edge rows and on no BF16 row. A mutant that passes the replay length in value units failssplit_bitson the MXFP8 NaN, range and overflow edge rows. A mutant that drops the column check fromGemmAct32::roomfails thecols_refusedrows andout_past_cols. A mutant that removes the refusal word's memset before the launch fails only the MXFP8scratch_reuserow (scratch_reuse=false); the other 27 rows pass.Micro benchmark
On a DGX Spark, the 6144 x 2560 projection at 4095 columns (graph mean) takes 3234.90 us as separate product, norm and
mxfp8_colslaunches and 1990.55 us as one fused launch. The BF16 projection goes from 3179.15 us to 2499.66 us. The fused MXFP8 launch saves 1244 us, about 44.8 ms over the 36 launches of a request.The new kernel has 364 bytes of spill and 64 bytes of JIT local, both in the epilogue and not in the MMA main loop; both are pinned in
tools/ref/ptx-shapes/sm_121a-cc12.1.tsv.Timed A/B
The timed A/B ran on a DGX Spark with main and with this change, three rounds per side in alternating order after a discarded lead-in round, medians below. Each request is a 4096-token prompt with 128 greedy tokens. The FP4-Local rows use the FP4-Local checkpoint without a draft and with the MTP draft (code and prose windows); the NVFP4 rows use the NVFP4 checkpoint without a draft.
Greedy output was identical on main and on head in every part.
On FP4-Local the prefill and TTFT ranges of the two sides are separate. Decode on FP4-Local is inside the run-to-run noise: its ranges overlap. With the MTP draft the prefill and TTFT ranges are separate in both windows, and decode ranges overlap. NVFP4 is inside the noise in all three metrics: every range overlaps.
The timed runs were built before the launcher arguments moved into the two argument structs (
Mxfp8NormGateArgs,NativeNormGateArgs) and before oneis_multiple_ofedit of a lane test inMxfp8Out::store. The structs change no check, launch or order. The edit changes three PTX lines ofmxfp8_w8a8_norm_gate, with the same register count, spill and shared memory (128 registers, 364 bytes of spill, 49152 bytes of shared memory). The gate rows above ran on this head. Theptx-scanMD5 block ofgate_gemmbuilt from it is identical across 377 entries to the one from the head that carries theis_multiple_ofedit.Reproduce one FP4-Local round (the NVFP4 round uses the NVFP4 checkpoint; the MTP rounds add
BLOOMERY_DRAFT=mtp BLOOMERY_MTP_DRAFT="<mtp-folder>" BLOOMERY_MTP_WIDTH=cost), withbaseon main andheadon this branch:Hardware
DGX Spark (GB10), driver 595.84, CUDA 13.3, for the gate, the lint, the micro benchmark and the timed A/B.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.