Skip to content

[ASM] [gfx1250] mla v4 prefill: rebuild sparse_pfl with the tail store rework - #5580

Merged
valarLip merged 2 commits into
mainfrom
junxiaguo/mla-v4-sparse-pfl-tail-0916
Sep 17, 2026
Merged

valarLip merged 2 commits into
mainfrom
junxiaguo/mla-v4-sparse-pfl-tail-0916

Conversation

@junxiaguo

@junxiaguo junxiaguo commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

update head and tail part
🤖 Generated with Claude Code

… rework

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]>
@junxiaguo
junxiaguo requested a review from a team September 16, 2026 07:54
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5580 --add-label <label>

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to opt this PR out.

@github-actions github-actions Bot changed the title [ASM][gfx1250] mla v4 prefill: rebuild sparse_pfl with the tail store rework [ASM] [gfx1250] mla v4 prefill: rebuild sparse_pfl with the tail store rework Sep 16, 2026
@github-actions github-actions Bot added the ASM label Sep 16, 2026
@valarLip
valarLip merged commit b132917 into main Sep 17, 2026
33 checks passed
@valarLip
valarLip deleted the junxiaguo/mla-v4-sparse-pfl-tail-0916 branch September 17, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants