Repository navigation
qwen38: a load whose every layer runs hostless over native NVFP4 downs keeps its card route's down rows in BF16, the product rounding each to nearest even and the block's card sum widening it - #914
Conversation
…uad and loads its fragments before their MMAs
… their count a literal
…s keeps its card route's down rows in BF16, the product rounding each to nearest even and the block's card sum widening it
…res the product stages
There was a problem hiding this comment.
Verdict: CLEAN: I built no failure path that the code does not block; three questions about evidence stay open.
Non-blocking
⚠ The timing does not isolate the BF16 route: wide38.rs:1077 turns BF16 on only when !tiered, every layer is hostless and every down is NVFP4. The timed runs use BLOOMERY_HOST_ROOM=96G on FP4-Local, and the body does not say that load is hostless. The 4.9% may come from the walk changes alone. Only the prompt walk reads BF16 rows; decode and verify keep F32 rows (card38.rs:456, card38.rs:659). State which change gives +4.9%, or add a timed A/B on a hostless NVFP4 load.
⚠ Unexplained decode loss: the body shows decode -1.0% (draft off, code) and -3.6% (MTP, prose), ranges not overlapping, cause not found. The walk change is a restructure (ldmatrix pairs, 16-byte scale load, literal tile arms), so it needs a timed A/B on every decode arm. Add a base-versus-base run for the noise floor, or find the cause.
⚠ The gate-up live arms are not pinned by committed cases: gate_gemm.rs:8927 adds the Varied cases to nvfp4_native only. The body says the nvfp4_gate_up run used "a build that differs only in those case inputs"; that build is not in this PR. Mutant: change $live <= 4 to $live <= 6 at nvfp4mma.rs:1534. Warp wc = 1 then skips columns 32 to 47 of a 33 to 48 column tile. No committed gate-up case is shown to make such a tile. Add one.
Checked
- Duplicates: about 14 new items checked (
DownRows,Down38,DownWin,ProductCell,ProductOut,has_native_form,all_hostless,cells_view,RowValues for &[u16]and others), none duplicated. Dryer pairs read:wide38.rs:856/:871(a merge adds elements),nvfp4mma.rs:1189/:1231,q38.rs:592/:627(separate kernel entries). None is one fact twice. - Complexity:
check_hostless25 to 37 andnvfp4_native_case89 to 96 are gate bodies with new checks.CardRoute38::new18 to 23 is one decision beside its owner.enqueue+1 is a match arm. Kernel bodies stay whole, asAGENTS.mdrequires. - Silent failure: 6 sites followed. BF16 rows in the Acc path and the tier join are refused by name (
DownRows::f32). A BF16 product without the native form is refused by name (gemm32.rs:1861). Overflow becomes infinity, which the combine's finite check raises.CardSum::AccandJoincannot meet BF16 rows: the caller picksBlockfor a hostless layer (wide38.rs:2368). - Tests: the
bf16_eqtruncation mutant turns red. A wrong cell read in the BF16 card sum turnsq38_card_hostless[bf16_rows]red. The gate-up arm is the gap above. - Gates: no band or tolerance moved; PIN lines are dated with reasons. Safety:
scale_quadalignment holds by the const assert;col_scalesits under$sr < 64. - Escape catalog: no pattern matched.
Notes
- The body names head
7a90733and base51ed64b;pr.jsonhas head5512da6and based74b53e. Re-run the gates on this head or say the kernels are unchanged. - The body lists
contrib-checkas not run and the clippy item as unchecked. - The
nvidia-smiline is a paraphrase and the gate output is a count, so it is not gate evidence.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_gemm.rs, crates/gpu-gates/src/bin/shared/q38_combine.rs, crates/gpu/src/arch/qwen3moe/body.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. |
DGX Spark에서 Qwen3.8 FP4-Local의 prompt 처리를 빠르게 하는 PR입니다. native NVFP4 expert GEMM이 tile마다 하는 일을 줄이고, routed down 출력을 BF16으로 두어 카드 합산이 읽는 양을 절반으로 줄입니다.
Supersedes #909.
Part of #565.
What and why
Prompt processing of Qwen3.8 FP4-Local spends most of its time in the routed experts' native NVFP4 tensor-core GEMM and in the per-layer sum of the experts' outputs. This PR cuts the work in both.
ldmatrix, and runs a whole tile's live fragments with a literal count, so the checks for unused fragments no longer run in the hot loop.gemm_nvfp4_mma_bf16entry, and the card sum (q38_card_sum_shared_add_bf16) widens each value back to F32 and adds the slots in the same ascending order as before, so the sum reads half the bytes. Any other load keeps F32 rows. A value outside the BF16 range becomes infinity and the existing finite check in the combine raises its named error.Greedy tokens differ from the base: the first difference is at token 40 of the first MTP code request, where the BF16 rounding of the down values changes the numeric result.
Release notes: Changed: Qwen3.8 FP4-Local prompt processing is 4.9% faster on a DGX Spark, with TTFT p95 4.6% lower.
Code shape
product_body) that the F32 and BF16 entries share.card_acc_atreads either down form, and both card-sum entries sharecard_sum_shared_add_at.live_walk!calls the onewalk!body with literal tile lengths, so the generated code has several bodies and the source has one.bf16_eqingate_gemmand twobf16_rowslines ingate_kquantare new checks. The two new entries and one changed walk entry carryPIN(2026-10-28)rows in the PTX shape tables, and the unsafe ratchet is raised for them with its PIN lines. Thesm_86andsm_121rows of the BF16 entries copy their F32 sibling's values because I measured no card of those classes.cargo clippyis clean. Atsm_121ait exits 0 and reports one warning,needless_range_loopin the gate-up kernel's input-scale loop, which this PR does not change.Duplication found or removed (
path:line), or "none": none.What I ran
Timed runs use one DGX Spark,
bloomery-servewith--parallel 1 --ctx-size 16896, andnvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300. A request is a 4096-token prompt with 128 generated tokens at temperature 0, on eight prompt windows of the code corpus (and of the prose corpus for the prose arm). Each side has three recorded rounds after one discarded lead-in round, and the sides alternate base, head, head, base, base, head. There are three arms: draft off on the code prompt, and the checkpoint's own MTP layers on the code and the prose prompts. Prefill and decode are the server's timings and TTFT is the client's.The base is built the same way in its own checkout.
Each cell is the median of three rounds with its range in parentheses.
Prefill is 4.9% higher on all three arms (2198.9 to 2305.7, 2092.5 to 2195.2 and 2144.5 to 2248.9 tok/s) and TTFT p95 is 4.6% lower; the sample ranges do not overlap.
MTP decode is 4.3% higher on the code prompt and 3.6% lower on the prose prompt. Draft-off decode is 1.0% lower with ranges that do not overlap; I have not found the cause.
Checks on the code of this branch, on a DGX Spark at
arch=sm_121a:just gate-gpu-gemm --case nvfp4_native(the recipe's GPU step): 51 PASS lines and no FAIL.The four whole-tile cases of that gate (128 rows, K = 128, 14, 25, 49 and 73 slots over two experts) use varied inputs, so an activation row the walk fails to copy cannot match a value an earlier case left in shared memory. With
live_rows(6)changed to return 32, the two 73-slot lines fail withwrong=1152(the 9 uncopied columns of 128 rows) and the gate exits 1.just gate-gpu-gemm --case nvfp4_gate_up: 9 PASS lines and no FAIL.just gate-gpu-kquant: 164 PASS lines and no FAIL, bothq38_card_hostless[bf16_rows, ...]lines among them.A mutant that replaces the round-to-nearest-even product with truncation fails 16
bf16_eqlines ofnvfp4_native, and a mutant of the widening fails 2 of the 4q38_card_hostlesslines.cargo fmt --check: fmt rc=0.Precision on the whole model, with the NVIDIA NVFP4 checkpoint (the
preparesplit ofnvidia/Qwen3.8-Flash-Next-NVFP4) loaded with every routed expert on the card, so every layer runs hostless over NVFP4 down projections and the card route keeps its down rows in BF16:just gate-gpu-qwen4exp-nvfp4withBLOOMERY_CARD_ALL_EXPERTS=1: exit 0; batch set by one pass kld=0.015775904, by one ubatch kld=0.066061804, 3000-token prompt by ubatches kld=0.028200012; the argmax equals the oracle's in every set; 36 flips (36 allowed)../tools/contrib-check.sh --tier t0: 37 checks, 0 red.Result lines of the
nvfp4_nativegate, for a 73-slot case, and the same lines withlive_rows(6)changed to return 32:Hardware
DGX Spark,
nvidia-smiquery: NVIDIA GB10, 595.84, CUDA 13.3.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.