Repository navigation
gemm: BF16 tensor cores for GB10 dense prompt products - #668
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No proven behavior or quality defect remains after tracing the changed paths.
Non-blocking
⚠ Whole-model numeric gate: crates/gpu/src/gemm/f32tile.rs:528 changes operand precision and reduction order. The change-class table in AGENTS.md requires gate-gpu-e2e count-pin evidence. Attach its command and output on GB10 for the reviewed head; kernel KL checks do not establish that pin.
⚠ Reproducible timing evidence: docs/cards/dense-bf16-prompt.card:5 defines the experiment, but the PR's timing table identifies builds as main plus unnamed loading branches and checkpoints by quantization label. Add the exact model files, both build hashes for each comparison, and the timing commands with output required by CONTRIBUTING.md.
Checked
Duplicates: 20 new named functions, types and constants checked. The dryer pair at kernels32.rs:1201/1243 contains typed entries calling the same owner; no duplicate implementation. Existing vision GEMM has a different storage and output contract.
Complexity: dense_mma_case is new at 44, spanning fixture preparation, eager validation and graph replay; those are its natural stage boundaries. bf16_mma_body is new at 30, a kernel body reviewed for correctness. site_case and e4m3_case each grew by 6 for MMA validation; site::gemm grew by 5 for device dispatch. gate::run and g32::run grew by 3 and 1 for case routing.
Silent failure: 8 candidate sites followed. Padding clamps reach guarded stores; raster rejection cannot discard a valid launched tile. Q8 diagnostic substitutes and statistic clamps do not bypass the output band or finite-KL check.
Tests: mutation analysis only. Dropping f32tile.rs:569 replay fails dense_mma range/exact checks; zeroing :550 stores fails the oracle band; dropping replay stores fails sentinel equality. Accepting K=96 or malformed E4M3 planes fails the extended refusal checks. Dropping rounding.rs:149 KL finiteness makes the new unit assertion fail. CUDA gates were not rerun locally.
Gates: GB10 site bit checks become band/KL checks with dated PIN reasons; exact entries retain their bit checks. The unsafe ratchet increase has a dated PIN. No other existing threshold moved.
Safety: independent index enumeration covers 4,096 distinct shared slots and 4,096 distinct output slots. Ragged stores, pipeline reuse, block voting and exact replay barriers checked.
Escape catalog: C1–C4 do not match this diff.
Card check: gpu-evidence. 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_mxfp8.rs … and carries a gate run on the author's card, which counts as verified.
🔨 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 E4M3, FP8_B128 가중치의 prompt 곱을 BF16 tensor core를 쓰는 본체 하나로 계산해 4K prefill을 높입니다.
What and why
On GB10, dense prompt products for BF16, MXFP8 E4M3 and FP8_B128 weights ran on exact F32 FMA tiles. This PR sends those three formats through one BF16 tensor-core body with F32 accumulation, using 64 by 64 output tiles and a permutation of the shared-memory rows that spreads fragment loads across banks. Stored weights are not rewritten, and other devices keep their current dispatch. A block-wide vote finds every tile that saw a non-finite or out-of-range operand (a magnitude above 2^47, or a subnormal) or a partial sum outside the F32 range. Only those tiles are replayed with the existing exact F32 tile reduction, so their output is the same as on the exact path. A product still takes one launch and no new global scratch buffer. I also tried keeping the partial sums in F64 instead of replaying; it needed 154, 148 and 148 registers and one block per SM, and it still failed the case where the exact path's lane-ordered F32 sum overflows to NaN, so it is not used.
On one GB10, a 4096-token prompt prefilled 98.2% faster on the NVFP4 checkpoint and 54.0% faster on the FP4-Local checkpoint (table below).
Part of #565.
Release notes: Changed: on GB10, prompts on BF16, MXFP8 E4M3 and FP8_B128 weights prefill on tensor cores, which roughly doubles 4K prefill speed on the NVFP4 checkpoint measured here.
Code shape
bf16_mma_body. The duplication scan below found only typed ABI wrappers and launchers.gate_bf16::k96_casechecks the K=96 refusal.crates/gpu-gates/src/rounding.rsis diagnostic only.cargo fmtandcargo clippyare clean on what I touched.Duplication found or removed (
path:line), or "none": none duplicated. The scan hits arecrates/gpu/src/gemm/kernels32.rs:1201,crates/gpu/src/gemm/kernels32.rs:1243andcrates/gpu/src/q8f32.rs:1724, which are typed wrappers that callbf16_mma_body, andcrates/gpu/src/gemm/f32tile.rs:673, wheremma_launchreusestile_launch(f32tile.rs:643) and checks the same spans before it adjusts the grid.kernels32.rs:1155andkernels32.rs:1106are the exact F32 entries that other devices need.What I ran
Head
d9f46a5dc, base main2a2d2d2fa. The gates below ran on39ccccb24; the head only regroups a private helper's arguments and the gate fixture's constant packing, with no arithmetic change. The 4K prefill table ran the first two commits on top of each checkpoint's baseline build; a short A/B of the exact replay follows it.GPU Evidence
On an NVIDIA GB10, with
BLOOMERY_BOX_LOCAL=1:The new tensor-core entries against their oracle band and the Q8_0 representation, with eager and graph replay compared bit for bit. The boundary cases cover a cancelling pair inside a fragment, across fragments, across stages, across a reused pipeline slot, at the last lane of a warp, at the first output of the next tile, and a pair whose lane-ordered F32 sum overflows to NaN on the exact path. Each runs for all three formats and is compared with the exact F32 tile output:
The BF16 site gate, which also runs the stored model shapes through the tensor-core entry:
The MXFP8 and FP8_B128 gate:
4K prefill timing
Each checkpoint ran as a pair on the same GB10: the baseline build first, then the candidate, each loaded once and sent one 4096-id code-fn request that generated two tokens. Concurrency was 1, drafting was off, the window was [0, 4096], and both arms used identical stored weights. Prefill tok/s is
4096 / TTFT. The NVFP4 baseline is main plus the unmerged branches that checkpoint needs to load. The FP4-Local baseline is main plus #649 and the unmerged checkpoint-folder commits its per-layer embedding reader needs. Each checkpoint compares only with its own baseline.Prefill rose from 393.3 to 779.7 tok/s on NVFP4 (+98.2%) and from 496.4 to 764.5 tok/s on FP4-Local (+54.0%) [derived]. TTFT fell 49.6% and 35.1% [derived]. Each arm is one request after one server load, so these are single observations with no spread and no significance claim.
To check that the exact replay costs nothing on the normal path, I compared the revision before it with this one on NVFP4 (one load and two 4096-token requests each, same GB10). On the second request the earlier revision prefilled at 755.94 tok/s and this one at 774.78 tok/s, so there is no regression. The first request of the earlier revision was slower than its second, and I do not count that as a gain.
Correctness
eager_graph_bits=false FAILand exits 1. On the previous revision, the cancelling-pair cases (between fragments, between stages, across a reused pipeline slot, warp corner, tile corner) and the NaN case readrange=falsefor all three formats and the gate exits 1 (gate_gemm ran 11 s (exit 1)). With the replay every one of them readsrange=true past_end_untouched=true eager_graph_bits=trueand matches the exact tile bits.site::gated, but itsGemmFrontsupplies only quantized inputs, so the new path would not serve it until that frontend passes the common F32 form.What I ran into
This does not block the PR. The full
just gate-gpu-gemmwithout--casestops before its first case on this machine because it reads model-derived inputs this machine does not have:gate_gemm: io error: No such file or directory. The cases this PR adds are thedense_mmaones in GPU Evidence.Hardware
One NVIDIA DGX Spark (GB10, compute capability 12.1, unified memory), driver 595.84, CUDA 13.3. Builds use
BLOOMERY_ARCH=sm_121.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.