Repository navigation
gpu: HC prompt projections use the shared BF16 tensor-core dispatch - #693
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix finding remains.
Non-blocking
⚠ Complete precision-change evidence: crates/gpu/src/hc_gated.rs:2192 routes HC activations through BF16 rounding on GB10. The change-class table asks for the gate-gpu-e2e count-pin result. Attach that output, both tested commit hashes, and the exact A/B commands with output so the evidence is reproducible.
⚠ Identify replay diagnostics: crates/gpu/src/hc_gated.rs:1777 has a shared replay owner and recurrence checks, but the PR identifies no retained tools/ probe or stats()/record exposing replay decisions. Name the existing diagnostic, or explain how the gate output supplies the fix's debuggability layer. This preserves a way to diagnose another numeric failure.
Checked
Duplicates: both dryer pairs are thin entries using shared computation, with distinct format or replay semantics.
Complexity: the reported growth covers shared MMA/isolation logic, numerical fixtures, graph comparison and fused dispatch.
Silent failure: non-finite mixed outputs raise HcMix; Head::tokens returns a fault error.
Tests: the HC gate checks exceptional-column independence, per-cell replay arithmetic, and eager/graph equality. The PR reports FAIL-first and GPU mutation results.
Gates: no existing band or tolerance moved; new spill and unsafe-count pins carry dated reasons.
Escape catalog: C1–C4 do not match the diff.
Notes
GPU gates and timing were not rerun during validation.
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. |
Qwen3.8의 HC 프롬프트 투영을 BF16 텐서 코어로 돌려, DGX Spark에서 4K 프롬프트 prefill이 752.753 tok/s에서 888.469 tok/s로 빨라집니다.
Part of #565.
What and why
Qwen3.8's hyper-connection (HC) layers run two BF16 projections on every prompt token: a down projection from 10,240 values (four streams of 2,560) to a 320-wide rank and an up projection back to 10,240. A 4,096-token prompt makes 97 calls of each, with shapes (M, N, K) = (4096, 320, 10240) and (4096, 10240, 320). Both called the exact BF16 tile launcher directly, so they never reached the hardware dispatch that the other BF16 prompt sites use. On a GB10 that dispatch picks the tensor-core MMA.
This PR has three commits.
gpu: HC prompt projections use the shared BF16 tensor-core dispatch.Q8F32Kernelsincrates/gpu/src/q8f32.rsowns the BF16 prompt choice and the GB10 capability test, and bothsite.rsand the HC code ask it. HC no longer launches the tile kernel itself. Ordinary BF16, MXFP8 and FP8_B128 sites keep the exact-tile replay they had.gemm: keep exceptional MMA cells independent of neighboring columns. This is a correctness fix that the first commit needs. When one operand row or column held a NaN or a value outside the range the MMA handles exactly, the whole-tile exact replay recomputed every column of the tile, so a bad column changed the arithmetic of clean neighbors. HC now takes a second instantiation of the same MMA body and exact owner that marks the bad rows and columns and replays only the marked cells. The HC gate caught the defect: with the dispatch change alone it printedthe other columns clean=false FAILand exited 1. With this commit, the same check and the newwide[subnormal_columns]check both pass (the run is in the GPU evidence below).gpu: fuse HC prompt up projection and gated mixing. On GB10 with more than 8 columns, the up projection hands its MMA fragments straight to the sigmoid gate and the ordered four-stream mix, so the gatedgplane of 10,240 values per column is no longer written and read back. Rows are permuted so the four streams of one column sit in the same warp group. Tiles with an exceptional cell fall back to the existinggallocation and the checked exact replay. The gate and the FMA order are shared with the narrow decode path, and the decode geometry for 2 to 4 columns does not change. On the normal 4K path this removes 335,544,320 bytes of logical traffic per site, 32,547,799,040 over the 97 sites [derived from the source, not a DRAM counter]. The allocation stays because exceptional tiles and the other formats still use it.The activation rounding to BF16 is the default for these sites, with no new option or runtime lever.
Release notes: Changed: HC prompt projections on Qwen3.8 run on the BF16 tensor cores with the up projection fused into the gated mix, which speeds up 4K prefill on a DGX Spark.
Code shape
bf16_mma_body, specialized at compile time for independent cells or full-tile replay.gallocation stays because exceptional tiles and other formats read it.PIN(2026-10-23):lines record the unsafe counts and the PTX shapes of the two new entries.cargo fmtis clean on what I touched.Duplication found or removed (
path:line): none. The overlaps the scan reported are two entry points that call the same tile body (crates/gpu/src/q8f32.rs:1823and:1793) and the shared launch geometry (:2705,:2735).What I ran
Speed A/B
The model is
nvidia/Qwen3.8-Flash-Next-NVFP4at revisionfc694b54fb0174e0913e6adf86691ef85a4ead47. Both servers run with one slot, draft off, a 4,224-token context and no cache RAM. Each arm loads once and sends two 4,096-token prompts from a code corpus, one client at a time, greedy, generating 2 tokens. Main and head ran back to back on one idle GB10, and every request evaluated 4,096 tokens with 0 cached tokens. The A/B ran on this code before the PTX and unsafe pin files were updated and the branch was rebased onto the current main. The rebase left the implementation diff unchanged.Delta (head minus main): prefill +18.03% (752.753 to 888.469 tok/s), TTFT -15.28% (5441.530 to 4610.243 ms).
Prefill tok/s is the 4,096 prompt tokens divided by the request's wall time. The server-side figures move the same way, 753.605 on main and 889.653 on head. Load takes 202.6 s on main and 202.2 s on head and is outside these numbers. A separate 32-token greedy continuation of the same prompt matched on all 32 tokens.
This is one main/head pair with two requests per arm. I make no significance claim from it.
GPU evidence
Card and driver, from
nvidia-smi:Card state when the timed sitting started, with the clock cap lifted, and after it, with the cap restored (
nvidia-smi --query-gpulines):The gates that cover the changed kernels:
They check eager and graph equality, untouched output tails, the named refusals, columns with NaN or subnormal operands, and the exact power-of-two range cases. The HC oracle KL is 1.591600e-5 for the down projection, below the Q8_0 reference's 4.643809e-4 on the same shape.
FAIL-first for the column fix. The first HC gate run, with the dispatch change alone, failed on the neighbor-column check. With the fix, the same line and the new subnormal-column check pass:
Four more mutations each fail a numerical check and the restored source passes: removing the HC down call, removing the fused up and mix, removing the BF16 site call, and widening the operand range check.
CPU geometry and FMA-order tests for the HC layout:
cargo oxide test --arch sm_121 -- --locked -p bloomery-gpu --release --lib hc_mma_ -- --nocaptureThe tier t0 contribution check on the final head:
DONE tier=t0 total=107 red=0 wall=348s.Reproduce
Run main's binary and this branch's in turn. Each request sends 4,096 token ids from a code corpus as a greedy streamed
POST /v1/completionswithmax_tokens2. The greedy check is aPOST /completionof the same ids withn_predict32,temperature0 andtop_k1.Hardware
A DGX Spark (NVIDIA GB10, driver 595.84, CUDA 13.3, sm_121 release builds). The clock cap was lifted for the timed sitting and restored afterwards. Nothing else used the GPU.
What I ran into
None of this blocks the PR.
PINcomments in the pin files say so. The two GB10 tables use the driver JIT values: the column-independent entry has 0 spill and 0 local bytes, and the fused HC entry has 84 spill bytes and 32 local bytes per thread. I make no zero-spill claim for the fused entry and did not check whether its local accesses are on the hot path.gate_gemmwithout a--caseopens a Qwen3 model fixture that the test machine did not have, so I did not run that gate. The Qwen3 case exercises routed GEMM, which this diff does not change: ingemm/kernels32.rsthe only edits pick the new generic argument in the dense MXFP8 and FP8_B128 MMA calls. The--case dense_mmarun above is the dense path this diff does change.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.