Conversation
Introduces minimax_m3_qknorm_rope_cache_shuffle_insert, a single HIP kernel that replaces the three-kernel sequence (fused QK-norm/RoPE -> reshape_and_cache(asm_layout=True) -> index-cache scatter) used by the MiniMax-M3 sparse attention layer, writing K/V directly into the page-16 SHUFFLE layout consumed by pa_decode_gluon. Includes correctness tests against a torch reference and, where vLLM is available, end-to-end equivalence tests against the existing unfused path. Co-authored-by: Cursor <cursoragent@cursor.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Unblocks the Checks workflow so downstream Aiter CI can run on PR ROCm#4813. Co-authored-by: Cursor <cursoragent@cursor.com>
|
We exercised this exact implementation at commit Correctness:
Performance:
This is the same fused op carried by our downstream experiment, so we do not plan to open a duplicate AITER PR. The current PR is conflicting with main; I am happy to help rebase it onto current AITER main and attach a compact gfx950 reproduction if that would help move it forward. AI disclosure: OpenAI Codex assisted with organizing the existing test evidence and drafting this comment; the reported numbers come from preserved run artifacts. |
Preserve the implementation and tests from AITER PR ROCm#4813 while retaining the newer composable_kernel submodule already present on main and relocating the pybind macro to its current context. Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: andyluo7 <andy.luo@amd.com>
|
I prepared a current-main rebase helper branch without opening a duplicate PR:
The six added source/test files are byte-identical to this PR's Static checks on the rebased tree pass: Black 26.3.0, Ruff 0.16.0, Python byte-compilation, and Please feel free to use the branch to update this PR. I am intentionally not opening a competing AITER PR. AI disclosure: OpenAI Codex assisted with applying and checking the rebase; original authorship remains Wei-Ting Liao. |
|
dulicated with fused_qknorm_idxrqknorm? |
|
Introduces minimax_m3_qknorm_rope_cache_shuffle_insert, a single HIP kernel that replaces the three-kernel sequence (fused QK-norm/RoPE -> reshape_and_cache(asm_layout=True) -> index-cache scatter) used by the MiniMax-M3 sparse attention layer, writing K/V directly into the page-16 SHUFFLE layout consumed by pa_decode_gluon.
Includes correctness tests against a torch reference and, where vLLM is available, end-to-end equivalence tests against the existing unfused path.
Motivation
The current 3-kernel path adds launch overhead and extra memory traffic (K/V written to
qkv, then read again for cache insert). Fusing into one kernel reduces both on a hot prefill/decode path.Technical Details
qkvrow per token:[q | k | v | index_q | index_k],head_dim=128q_out,index_q_out, and pagedk_cache/v_cache/index_cachein page-16 SHUFFLE layoutslot_mapping=-1),skip_index_branch=TrueTest Plan
pytest op_tests/test_minimax_m3_fused_qknorm_rope_cache_shuffle.py -v
pytest op_tests/test_minimax_m3_fused_shuffle_vs_unfused.py -v # requires vLLM
Test Result
pytest op_tests/test_minimax_m3_fused_qknorm_rope_cache_shuffle.py -v| Test | Cases | Result |
|---|---|---|
|
test_fused_insert(tokens × fp8_index × quantized) | 1/7/64 × {False,True} × {False,True} (12) | PASSED ||
test_skip_index_branch_leaves_index_outputs_untouched| 1 | PASSED ||
test_multi_kv_head_and_full_rotary| 1 | PASSED |Submission Checklist