Repository navigation
[ASM] [gfx1250] mla v4 prefill: rebuild the sparse_pfl kernel - #5367
Merged
Merged
Conversation
Rebuild mla_a8w8_qh128_1tg_32mx4_32nx1_sparse_pfl.co from the current 32mx4_32nx1 source. Binary-only change; no host or dispatch code moves. What is in the new build, on top of the one shipped by #4926: * head/tail schedule rework -- the prologue index chain is hoisted and the Q/K TDM descriptor setup is packed into the blocking window, so the non-core-loop cost stops dominating at small nnz_prefix. * core-loop reorder -- 124 DS ops moved into WMMA shadows, ~2129 -> ~1933 issue slots per tile. * PTL (page-table) prefetch hazard fixed: the CSR index prefetch is bounded and waits for the writelane before the shift reads it. * fp8 e8m0 scale granularity corrected to one scale per 32 elements, and the packed row's 448:511 tail is zeroed (with the S_to_P MSB fix it exposed). Measured with op_tests/test_pa_sparse_prefill.py, backend=asm prec=fp8 h_q=128 d=512, on gfx1250: mode N total_pages before us after us speedup sparse 1024 4096 296.55 255.17 1.16x sparse 1024 16384 911.10 791.55 1.15x sparse 4096 4096 1559.73 1346.34 1.16x sparse 4096 16384 3736.42 3235.25 1.16x dense 1024 4096 455.32 399.01 1.14x dense 1024 16384 1480.73 1296.32 1.14x dense 4096 4096 2836.98 2478.22 1.14x dense 4096 16384 6975.46 6109.89 1.14x Peak moves 3155 -> 3605 TFLOPS. All eight cases pass the test's PyTorch reference check (atol=rtol=0.01, err=0.0). Also validated end to end on DeepSeek-V4-Pro (gsm8k 100q 3-shot, 0.94/0.94, no memory faults). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
junhaha666
approved these changes
Sep 10, 2026
valarLip
pushed a commit
that referenced
this pull request
Sep 17, 2026
… rework (#5580) Rebuild mla_a8w8_qh128_1tg_32mx4_32nx1_sparse_pfl.co from the current 32mx4_32nx1 source. Binary-only change; the kernarg layout, the symbol name and the mla_v4_asm.csv row are all unchanged, so no host or dispatch code moves. What is in the new build, on top of the one shipped by #5367: * tail store address hoist (T1 + T5-b) -- the store address comes out of the inner loop, two alternating pack buffers on a global parity let the fence relax to `vm_vsrc: 1`, and the WAR distance becomes two stores everywhere. The 46 idle cycles per iteration were not free issue slots before: the wave was parked on the `s_wait_alu { vm_vsrc: 0 }` sitting right after ds_store. * split final R writeback (T6) -- the 32 KB tensor_store_from_lds became two per-q transfers. A 20-tile ttrace measured the TAIL as one hole, not many: every one of the 16 waves had exactly one gap above 100 cycles, four instructions from the end, 2519..4050 cyc, 56-67% of TAIL. q0's sixteen rows are complete in LDS halfway through the batched store, so issuing that half early puts it in flight across q1's scale/convert work. Same bytes, same order. * prologue index prefetch and prologue scheduling reworked; the final R LDS stores are pipelined and batched. * HEAD_KV_PTL_PREFETCH added behind a knob and left OFF -- on a warmed capture it moved nothing (HEAD 3423 -> 3500, K0 span 796 -> 836) and cost 28 B when off. Whether it pays on a genuinely cold first dispatch is untested. Measured with op_tests/test_pa_sparse_prefill.py, backend=asm prec=fp8 h_q=128 d=512, on gfx1250 (256 CU). Each figure is the median of three alternating before/after passes; both binaries ran in the same window on an otherwise idle GPU. mode N total_pages before us after us speedup sparse 1024 4096 241.57 235.57 1.025x sparse 1024 16384 741.08 739.83 1.002x sparse 4096 4096 1278.32 1269.58 1.007x sparse 4096 16384 3081.76 3073.65 1.003x dense 1024 4096 378.67 375.47 1.009x dense 1024 16384 1231.62 1227.15 1.004x The gain is small here and that is expected: this round of work is all in the head and the tail, which are a fixed cost per dispatch, so their share shrinks as the tile count grows. It is largest at the shortest rows (N=1024, total_pages=4096) and the ordering is consistent -- across two independent runs the new binary was faster in 36 of 36 repeat-wise pairs. Source: my_agent_skills 0805_base/32mx4_32nx1.sp3 at 07257d72c6a7, SHA256 e017a703168b88b885f5a00080ff60dd6cb966723c175ad8a1d4556eff3ca99f. New .co SHA256 f55d85ece7ab7b6b3f26a1d3097a9d1687fcb8b7f9b5c4cff12f6bde3a43475f. Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: HaonanWang98 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebuild
mla_a8w8_qh128_1tg_32mx4_32nx1_sparse_pfl.co448:511tail is zeroed (with theS_to_PMSB fix it exposed).Performance
op_tests/test_pa_sparse_prefill.py,--backend asm --prec fp8 --h_q 128 -d 512, on gfx1250. Three interleaved A/B runs, best run each:Peak moves 3155 → 3605 TFLOPS. Run-to-run spread also tightens: the old build had a run where sparse regressed 40% (1024/16384 at 1260 µs, 4096/16384 at 5242 µs); the new build stayed within 1% across all three runs.
Correctness
atol=rtol=0.01,err=0.0).🤖 Generated with Claude Code