Repository navigation
gpu: normalize independent BF16 output heads to MXFP8 - #665
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect was found in the changed paths.
Non-blocking
⚠ Complete the precision-change evidence: crates/gpu/src/q8f32.rs:3505.
The encoder rounds BF16 head weights to MXFP8. The base contract's precision-change class requires the just gate-gpu-e2e count-pin result.
Attach that output and the exact timing commands with output for 3e03d745c versus 4e5082d58. The PR body supplies family-gate output and timing tables, but omits these records. The review rules classify missing measurement evidence as non-blocking.
Checked
Duplicates: 14 new or relocated definitions checked; no duplicate requiring fewer elements after extraction. Dryer reported zero pairs; GPU and gate code were searched manually.
Complexity: new head_rows_case (23) covers layout, replay and fault stages. walk (85→91), enqueue_mix (28→31), enqueue_over (18→20), enqueue_e4m3_gemv (19→21) and upload_rows (52→53) grow by format dispatch. e4m3_case (18→22) adds gate dispatch; cases (38→39) adds one clause. No complexity finding.
Silent failure: six sites followed. Missing dimensions and size-conversion failures become named errors. Host column checks block the kernel fallback arms. Encoder clamps follow finite-input validation and implement representable quantization.
Tests: mutation analysis covers bypassing file_card_format (placement.rs:516), restoring old plane sizing (card.rs:606), transposing output (q8f32.rs:2799), dropping the ID fault (q8f32.rs:1365), and removing finite/range refusals (q8f32.rs:3526,3548); their format, byte, layout, fault and refusal assertions fail. The BF16 gate retains its raw-format coverage explicitly.
Numeric check: an independent arithmetic check of 32,640 positive finite BF16 values found no nearest-even mismatch against the E4M3 value table. Rounded overflow reaches the encoder's named range error.
Adversarial paths: malformed shapes, NaN/infinity, extreme finite weights, repeated and out-of-range IDs, invalid column counts, tied embeddings and K=320 fallback were traced to guards or defined behavior.
Gates: changed format/byte pins and the unsafe ratchet carry dated reasons; no numeric tolerance was relaxed.
Escape catalog: C1–C4 do not match the changed code.
Notes
Rust and GPU gates were not executed locally. Hardware evidence was assessed from the PR body.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_bf16.rs, crates/gpu-gates/src/bin/gate_mxfp8.rs, crates/gpu-glm5next/src/tp/source.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. |
Qwen3.8 서버가 독립 BF16 출력 head를 load할 때 MXFP8로 바꿔 읽고, BF16 HC up의 m=1 전용 kernel을 더해 GB10의 C@1 decode를 빠르게 합니다.
Part of #565.
What and why
Single-request decode (C@1) on a GB10 reads the whole output projection (the LM head) from memory for every new token. A BF16 head stores 2 bytes per value. This PR changes two things on that path.
output.weightloads as MXFP8. Each value becomes one byte, with one scale byte for every 32 values, so the resident head takes about 1.03 bytes per value instead of the 2 in the file. The encoder rounds to nearest even and picks a power-of-two scale per 32 values. It applies when K is a multiple of 128; a head with another K stays BF16. Tied embeddings and the hyper-connection (HC) head-stage matrices keep their formats.head_card_formatincrates/placement/src/placement.rsis the one owner of this choice, and both the placement and the upload read it, so their resident byte counts agree. The normal head and the MTP draft heads borrow the same resident planes, and the selected-row kernel (blocks_gemv_idsincrates/gpu/src/q8f32.rs) serves Q8_0 and MXFP8 rows alike, so no draft copy of the weight is added. The encoder refuses non-finite values and any value whose rounded MXFP8 form would leave f32 range, each with a named load error.m = 1it keeps only the 320 bottleneck values in shared memory, where the general entry reserves 8 columns of 320. Them > 1path is unchanged.The MXFP8 head rounds the weights, so its logits differ slightly from the BF16 head. The default path is the faster one; greedy agreement and KL are reported below as diagnostics.
Release notes: Changed: an independent BF16 output head loads as MXFP8 on the card, which speeds up single-request decode on GB10.
Code shape
file_card_format), called by placement, by the upload and by the GLM checkpoint folder's tensor-parallel plan. The selected-row kernel is shared by Q8_0 and MXFP8 rows.cargo fmtandcargo clippyare clean on what I touched.Duplication found or removed (
path:line), or "none": none. The new selected-row kernel and the HC entry reuse the existing lane-partial arithmetic incrates/gpu/src/q8f32.rsandcrates/gpu/src/hc_gated.rs.What I ran
Head
417bcdc86, base main2a2d2d2fa. The GPU gates below ran ona38851339. The head changes only host code after it: the GLM checkpoint folder's tensor-parallel plan counts a BF16 head at its MXFP8 size (16,896 bytes for 64 rows of 256, where it counted 65,536), and two tests expect the MXFP8 head. The decode timing ran on4e5082d58against3e03d745c, the same device code for the output head; later commits add a finite-range refusal in the host encoder and the pins that follow the head's new format.GPU Evidence
On an NVIDIA GB10:
The MXFP8 gate covers the head encoding, the row layout, selected ids, the invalid-id fault and the eager and replay bits:
The BF16 gate covers the raw BF16 words, and the HC gate covers a BF16 hyper-connection site:
The tensor-parallel checkpoint gate, whose expected head bytes now follow the head's MXFP8 format:
With the head conversion bypassed in both callers, the head output transposed and non-finite BF16 accepted, the placement test and the MXFP8 gate fail. With the source restored they pass:
On
a076b6e58, an RTX 5090 machine ran the encoder test for the f32-range refusal. It fails when the new bound is removed and passes with it restored:Decode and prefill
One server load per arm, base then head, two requests per load. Each request has a different 4096-token code window and generates 128 tokens, at temperature 0 with top-k 1, no prompt cache and no draft, with
--parallel 1 --ctx-size 4224. Modelnvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6887e18c089fdea8509a33e63429a3300, loaded from its checkpoint folder, on one GB10 with driver 595.84, CUDA 13.3 and release binaries.Decode speed rose by 7.07%, and prefill did not change.
Each arm is one load with two requests. The base requests decoded at 27.670 and 27.519 tok/s, and the head requests at 29.589 and 29.505 tok/s.
Quality diagnostics over 64 greedy steps: the greedy token ids matched on 64 of 64. The KL is computed over the shared top 100 token ids plus one bucket for the rest, so it is a lower bound on the full-vocabulary KL. Its mean is 1.393e-5 and its maximum is 3.833e-4.
What I ran into
This does not block the PR. The m=1 HC kernel is in both timed arms, and its own effect was too small to separate from run-to-run variation, so I claim no speed gain for it. MTP draft throughput with the shared head planes was not measured.
Hardware
One NVIDIA DGX Spark (GB10), driver 595.84, CUDA 13.3. The encoder test ran on an RTX 5090 machine.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.