Repository navigation
gpu: load a pair of columns' chunks of a multi-column F32 row walk before their multiply-adds - #707
Conversation
…fore their multiply-adds f32_lane_partials, the row walk of the F32 and BF16 gemv at 2 to 8 columns (the dense sites of a verify pass or a batch of slots, and the router's gated walk), guarded each column's chunk loads and their multiply-adds behind that column's branch, so a trip waited on one load round trip per live column. A trip now loads the chunks of two columns before either column's multiply-adds, one branch per pair; when m_cols is odd, the last pair's second column reads column 0's chunks and its sum is zeroed before the tail. Each column still adds its chunks in increasing order, so every output keeps its bits (f32_walks_are_the_scalar_walk).
There was a problem hiding this comment.
Verdict: CLEAN: The changed walk preserves live-column bounds and accumulation order; no must-fix defect was found.
Non-blocking
⚠ Complete the timing evidence: crates/gpu/src/q8f32.rs:267. The changed loop feeds bf16_gemv; the PR reports sm_86 static blocks/SM falling from 5 to 4, an occupancy/geometry change.
The GB10 A/B table omits the measured head SHA and timing commands/output. Attach the original run record with both measured SHAs, commands/output, and the GB10 resource calculation.
Checked
Duplicates: 1 new function and 2 local closures checked. The pair walk and single-column fold share the fold sequence.
Complexity: pair guards replace individual column guards.
Silent failure: 2 zero fallbacks followed; they select valid padding reads and clear only inactive sums.
Tests: none added or changed. The existing scalar oracle checks all eight slots; removing the reset at line 306 fails its bit assertion, as the PR's mutant output reports.
Bounds and order: checked one column, odd widths, the last lane of a full chunk group, and partial tails. Live columns retain increasing chunk order and explicit FMA.
Gates: no gate or pin changed. BF16 and NVFP4 gate output is present in the PR.
Escape catalog: C1–C4 do not match.
Notes
Static validation only; tests and GPU gates were not rerun.
Card check: needs-gpu. This pull request changes crates/gpu/src/q8f32.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. |
2열에서 8열까지 처리하는 F32와 BF16 행 읽기가 열 두 개의 chunk를 먼저 읽은 뒤 계산하도록 바꿔, DGX Spark의 NVFP4 MTP 디코드가 코드 기준 40.93 tok/s에서 44.47 tok/s로 빨라집니다.
Part of #565.
What and why
With MTP (multi-token prediction), the target verifies a draft in one step of 2 to 8 rows. Besides the routed experts, every extra row costs the dense BF16 projections, the router and the F32 beta and alpha gemvs. These calls share one row walk,
f32_lane_partialsincrates/gpu/src/q8f32.rs. For 2 to 8 columns it used to load each column's chunk and multiply-add it behind that column's branch, so a trip waited for one load round trip per live column.A trip now loads the chunks of two columns, then does their multiply-adds, so it waits for one round trip per pair. When the column count is odd, the last pair's second column reads column 0's chunk, which keeps the pair under one branch, and its sum is reset to zero before the tail. Every column still adds its chunks in increasing order, so the output bits are the same.
f32_fold_valuesis the one place that fixes the order of the eight multiply-adds, shared by the pair walk and the one-column fold. The change touches one file and adds no CUDA entry, flag or per-model branch.Release notes: Changed: NVFP4 MTP verify steps and batched decode on a DGX Spark run about 6 to 9 percent faster, with the same output tokens.
Code shape
f32_fold_values, so the fold order has one owner.cargo fmtis clean on what I touched.Duplication found or removed (
path:line): none.What I ran
Speed A/B
Main is
a83dd0df93eded2e88dcf7be7a886d5c3c97646f, and the measured head is this change on that main. This PR's head is the same commit rebased onto mainb9dfc4a748ea7d7b713ec831100761ef047b5472.git range-diffshows the commit unchanged, so the patch is the same, and I did not measure again after the rebase. The whole A/B ran in one sitting.The model is
nvidia/Qwen3.8-Flash-Next-NVFP4at revisionfc694b54fb0174e0913e6adf86691ef85a4ead47, served with its own MTP layer. Each arm starts a fresh server, with one load per arm, and the clock cap is lifted for the timed arm only. Prompts are 4,096 token ids from a code corpus and a prose corpus, and each request generates 128 tokens with greedy decoding. The four-request arm sends four 256-id prompts at once and ignores EOS. Decode tok/s is the request's generated tokens divided by its decode time. Steady total tok/s counts the tokens all four requests produce while all four decode.Delta (head minus main): MTP decode on code +8.66% and on prose +6.37%; four requests: steady total +8.30%, TPOT p95 -7.13%.
Main and head generate the same tokens on every request, with MTP on and off. The paired requests move in the same direction: both code requests gain 6.4 percent and 10.9 percent, and both prose requests gain 6.1 percent and 6.6 percent. This is a short sample with two requests per corpus and one sitting, so it has no confidence interval. The no-MTP gain is small. With MTP on, the chooser also picked different widths, which changes the draft count between the two builds.
GPU evidence
Card and driver, from
nvidia-smion the DGX Spark that ran the A/B:The card at idle, and its clock under load with the cap lifted:
The NVFP4 MTP gate, with the folder's own MTP layer, on a second DGX Spark (GB10):
The BF16 gate checks the output bits of the BF16 site and the F32 site for 1 to 8 columns, graph replay included, on an RTX 5090:
The host test
f32_walks_are_the_scalar_walkcompares 1 to 8 columns, k from 32 to 1536, against a scalar fma walk bit by bit, and checks that columns past the live count read 0.0. It succeeds on the head. With the padding column's sum reset removed, it stops on the first odd pair:sm_86 PTX
The three
selkernels (nvfp4_gemv_sel32,nvfp4_gemv_sel_f32andnvfp4_gate_up_sel) are not changed, so the sm_86 build, the spill pins and thejit_localpins stay as they are.just ptx-compareshows six changed entries and none added or removed:bf16_gemvandqwen35moe_router_fusedalso serve the one-row path, so on sm_86 their higher register counts lower the static blocks per SM by one step for plain decode too (5 to 4 forbf16_gemv). I have no sm_86 card here and did not measure that path, so its speed there is unknown.Hardware
DGX Spark (NVIDIA GB10, driver 595.84, CUDA 13.3, sm_121) for the A/B and the MTP gate, and an RTX 5090 for the BF16 gate and the host test.
What I ran into
None of this blocks the PR. The A/B for the final code is one sitting, so the gain is not confirmed across sittings. The draft-off gain is small enough that run-to-run variation may account for part of it. I did not profile the kernels after the change, so I do not know which kernel gives the gain.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.