Skip to content

[Perf] minimax-sparse: Speed up MiniMax-M3 sparse attention on Hopper - #46135

Merged
ispobock merged 3 commits into
mainfrom
m3-sparse-hopper
Oct 25, 2026
Merged

ispobock merged 3 commits into
mainfrom
m3-sparse-hopper

Conversation

@ispobock

@ispobock ispobock commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Faster MiniMax-M3 sparse attention on Hopper: Triton decode and prefill kernels with tiled block pointers (Triton >= 3.9), fp16-widened decode for fp8 KV on the paged path, and a fused bf16-to-fp8 cast in the fused K/V/index store.

Changes to existing code

  • On Hopper with fp8_e4m3 KV, the sparse index K cache is stored in fp8 (it was bf16 unless fp8 attention GEMMs were on). Other platforms keep the previous dtype.
  • The fused K/V/index store also handles an unscaled bf16-to-fp8_e4m3 cast (CUDA only); other inputs use the separate stores as before.

Verification

  • Kernel tests on H200: test_minimax_sparse_fp8_attn_gemm.py 88 passed; the fused store cast is bit-exact against x.float().clamp(-448, 448).to(torch.float8_e4m3fn).
  • MiniMax-M3.1-Flash on 8xH200, H200 cookbook recipe plus --kv-cache-dtype fp8_e4m3, sgl-eval 0.1.3, this PR vs. fp16 widening disabled:
GSM8K (greedy, 2 runs) AIME26 (avg@8)
this PR 96.21 / 96.06 91.25
widening off 96.36 / 96.51 93.75

The between-arm per-question divergence and correctness flips are within the run-to-run noise of either arm.

Cut from #45925 (MiniMax-M3.1-Flash support) at 10e655a.


CI States

Latest PR Test (Base): 🚫 Run #40114646995
Latest PR Test (Extra): ✅ Run #40114646930
Latest PR Test (AMD ROCm 10): ❌ Run #40114646909

@github-actions

This comment has been minimized.

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/kernels/ops/attention/test_minimax_sparse_flash_with_topk_idx.py test/registered/kernels/ops/attention/test_minimax_sparse_decode_paged_tile.py test/registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py test/registered/kernels/ops/attention/test_minimax_decode_topk_page_table.py test/registered/kernels/ops/attention/test_minimax_sparse_gqa.py test/registered/kernels/ops/kvcache/test_minimax_store_kv_index.py

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (5 tests): ❌ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_flash_with_topk_idx.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_decode_paged_tile.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_gqa.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_store_kv_index.py

🚀 4-gpu-b200 (6 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_flash_with_topk_idx.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_decode_paged_tile.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_decode_topk_page_table.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_gqa.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_store_kv_index.py

Co-authored-by: zijiexia <37504505+zijiexia@users.noreply.github.com>
Co-authored-by: Chunan Zeng <zcnrex@gmail.com>
@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/kernels/ops/attention/test_minimax_sparse_flash_with_topk_idx.py test/registered/kernels/ops/attention/test_minimax_sparse_decode_paged_tile.py test/registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py test/registered/kernels/ops/attention/test_minimax_decode_topk_page_table.py test/registered/kernels/ops/attention/test_minimax_sparse_gqa.py test/registered/kernels/ops/kvcache/test_minimax_store_kv_index.py

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (5 tests): ❌ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_flash_with_topk_idx.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_decode_paged_tile.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_gqa.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_store_kv_index.py

🚀 4-gpu-b200 (6 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_flash_with_topk_idx.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_decode_paged_tile.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_decode_topk_page_table.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_gqa.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_store_kv_index.py

@ispobock ispobock added run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) labels Oct 24, 2026
@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py test/registered/kernels/ops/kvcache/test_minimax_store_kv_index.py test/registered/kernels/benchmark/kvcache/bench_minimax_store_kv_index.py

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (3 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_store_kv_index.py
cd test/ && python3 registered/kernels/benchmark/kvcache/bench_minimax_store_kv_index.py

🚀 4-gpu-b200 (2 tests): ✅ View workflow run

cd test/ && python3 registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_store_kv_index.py

@ispobock

Copy link
Copy Markdown
Collaborator Author

/run-full-ci

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@ispobock
ispobock merged commit db7b66c into main Oct 25, 2026
332 of 354 checks passed
@ispobock
ispobock deleted the m3-sparse-hopper branch October 25, 2026 03:28
akhilg-nv added a commit to akhilg-nv/sglang that referenced this pull request Oct 26, 2026
Conflict in minimax_sparse/decode/topk_sparse.py: main (sgl-project#46135) ported the
MiniMax sparse kernels off block pointers and replaced the stale block_size
autotune key with BLOCK_SIZE_N, which supersedes this branch's key fix, so
take main's version of the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
akhilg-nv added a commit to akhilg-nv/sglang that referenced this pull request Oct 26, 2026
Main (sgl-project#46135) ported the MiniMax sparse kernels off block pointers, so
minimax_sparse no longer needs the shim. Only the FLA kernels use it now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ispobock ispobock mentioned this pull request Oct 27, 2026
13 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) jit-kernel memory-pool run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant