Repository navigation
inkling2 on AMD: batched NVFP4 projections on pretiled WMMA (decode / verify rows 4-16) - #412
Conversation
|
Queued in train #421 ( 🤖 Generated with Claude Code |
… verify rows 4-16) On strix-hip the rows 2..16 Linear::Nvfp4 projections ran w4a16_gemv_batch8/16, issue-bound at ~15-20% of the C8 step and ~21% of the DSpark verify step. This routes rows 4..16 (N >= 1024) to a new pretiled split-K WMMA kernel derived from Ciru AI's hip_moe_decode.hip source-NVFP4 decode GEMM (Apache-2.0, attribution in the file header): - weights.rs: at load (AMD only) each Nvfp4 projection's packed E2M1 + E4M3 scales are repacked by w4a16_wmma_pretile into the WMMA tile replay ([N/128][K/64][128][32] packed, [..][128][4] scale words) as extra device buffers beside the original q, so the rows=1 w4a16_gemv_sw path is untouched and bit-identical. ~560 MB extra device memory (same bytes, permuted). - w4a16_wmma: one block per 128 outputs x K slice, 8 warps, K64 software- pipelined bf16 WMMA, register-side NVFP4 unpack with the same E2M1 decode and scale math as the GEMV path, zero smem for B, next-tile prefetch. gridDim.y splits K (host picks 1-8 slices by shape) into f32 partials; w4a16_wmma_reduce sums them to BF16 (order-exact adds, deterministic). - Routing is measured: rows 2-3 and the N=384 rel-bias projection stay on w4a16_gemv_batch8/16 where WMMA's fixed per-launch cost does not pay off; the remaining shapes gain ~1.75x at M=8. Microbench (us/call, M=8, cold weights): 3072x2304 batch8 57.4 -> 32.9 (121 GB/s); 1024x2304 batch8 19.5 -> 12.5 (106 GB/s); 2304x3072 batch8 51.6 -> 32.5 (122 GB/s); relbias 384 stays on batch8. M is flat on the WMMA side; batch8 still wins at M <= 3. Gate vs main 7a717b6 (bin 2a4d92163021), start-script serve (prefix cache, batch 8): greedy C1 spark+strict IDENTICAL (mean|dlp| 0.00000); decode_h2h C2 51.5=51.5, C4 69.4->70.7, C8 89.6->93.6; task_probe 30/30+10/10 all arms; pd_check 6x96/96 aligned within f373 noise; NLL unchanged; 0 ERROR/panic/illegal on every arm; C8 rocprofv3 shows w4a16_wmma 22.1 us/call at 6.4% of GPU (was batch8 47 us, 15.5%).
258d9a5 to
fbb7f4f
Compare
…logue bound #412 and #413 were re-pushed with one change: w4a16_wmma's prologue loads a K group's first weight tile only when the slice has one (a short last slice read one tile past the pretiled buffer; HSA memory fault on a 16-row Spark prefill chunk, DevLab 45568957561 / 45587106711). The earlier heads are already merged above; this brings in the fixed ones. # Conflicts: # kernels/strix-hip/inkling-2-mini/nvfp4/inkling2_w4a16_wmma.cu
|
The re-pushed head (with the guarded 🤖 Generated with Claude Code |
Runner + framework verification at
|
| C1 | C2 | C4 | C8 | |
|---|---|---|---|---|
| framework, main | 42.3 | 51.5 | 69.4 | 89.6 |
| framework, this PR | 42.4 | 51.5 | 70.7 | 93.6 |
| runner, main | — | — | 63.2 | 80.4 |
| runner, this stack | — | — | 66.2 | 85.3 |
CI: the workspace jobs pass. Env budget (1139 = main), the PR benchmark gate and cargo deny fail on main too.
…ute.rs, code moves only) #408, #412 and #414 each grew glue.rs; merged it is 505 lines and the file-size-cap job fails. The router top-k and the KV page write move as is to a second impl block in glue/route.rs (446 + 74 lines). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Prefill: 1,362 -> 1,525 tok/s @7.7K and 1,109 -> 1,383 @31k on framework (hipcc 7.13); runner (hipcc 7.16) 1,192/954 -> 1,327/1,174 (+11%/+23%) after staging V as fp16 in LDS, which drops 7.16 VGPR spill slots 128 -> 16 (fused softmax row staging; no tm/pv temporaries). pd_check 96/96 aligned x6 prompts, mean|dlp| 0.0046-0.0188 (f373 noise); NLL code 0.63684 (-0.00005), text 0.89670 (+0.00052, accepted: flash accumulation order + fp16 P on AMD; pd within noise). task_probe math 30/30 + tools 10/10 spark and strict; agentic 10/10. gb10 inkling-2-mini PTX byte-identical to main. ST-995 (bfcl-subset n=995): 77.99/78.19 vs main's 79.10/79.63. Per-sample rescore vs #412-only responses: 57 verdict flips, 34 lost / 23 gained (-1.11 net); two-sided sign test p ~= 0.19, indistinguishable from accumulation-order noise at temp 0. Deterministic across reruns (bit-identical rerun).
inkling2 on AMD: batched NVFP4 projections on pretiled WMMA (decode / verify rows 4-16)
On strix-hip the rows 2..16 Linear::Nvfp4 projections ran w4a16_gemv_batch8/16,
issue-bound at ~15-20% of the C8 step and ~21% of the DSpark verify step. This
routes rows 4..16 (N >= 1024) to a new pretiled split-K WMMA kernel derived
from Ciru AI's hip_moe_decode.hip source-NVFP4 decode GEMM (Apache-2.0,
attribution in the file header):
scales are repacked by w4a16_wmma_pretile into the WMMA tile replay
([N/128][K/64][128][32] packed, [..][128][4] scale words) as extra device
buffers beside the original q, so the rows=1 w4a16_gemv_sw path is
untouched and bit-identical. ~560 MB extra device memory (same bytes,
permuted).
pipelined bf16 WMMA, register-side NVFP4 unpack with the same E2M1 decode
and scale math as the GEMV path, zero smem for B, next-tile prefetch.
gridDim.y splits K (host picks 1-8 slices by shape) into f32 partials;
w4a16_wmma_reduce sums them to BF16 (order-exact adds, deterministic).
w4a16_gemv_batch8/16 where WMMA's fixed per-launch cost does not pay off;
the remaining shapes gain ~1.75x at M=8.
Microbench (us/call, M=8, cold weights): 3072x2304 batch8 57.4 -> 32.9
(121 GB/s); 1024x2304 batch8 19.5 -> 12.5 (106 GB/s); 2304x3072 batch8
51.6 -> 32.5 (122 GB/s); relbias 384 stays on batch8. M is flat on the
WMMA side; batch8 still wins at M <= 3.
Gate vs main 7a717b6 (bin 2a4d92163021), start-script serve (prefix
cache, batch 8): greedy C1 spark+strict IDENTICAL (mean|dlp| 0.00000);
decode_h2h C2 51.5=51.5, C4 69.4->70.7, C8 89.6->93.6; task_probe
30/30+10/10 all arms; pd_check 6x96/96 aligned within f373 noise; NLL
unchanged; 0 ERROR/panic/illegal on every arm; C8 rocprofv3 shows
w4a16_wmma 22.1 us/call at 6.4% of GPU (was batch8 47 us, 15.5%).
First of a linear stack of AMD Inkling 2 Mini perf PRs (PR-2: flash prefill attention, based on this branch). AMD-only (
cfg!(atlas_scale)+ a strix-hip-only kernel file); gb10 untouched. DevLab strix-hip build 45338457830: success.Generated with Devin