Skip to content

[Feat] attention: Add the MSA-v1 sparse backend and NVFP4 KV pool - #46141

Merged
ispobock merged 31 commits into
mainfrom
m31-sparse-nvfp4-backend
Oct 25, 2026
Merged

ispobock merged 31 commits into
mainfrom
m31-sparse-nvfp4-backend

Conversation

@ispobock

@ispobock ispobock commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The MSA-v1 sparse attention backend on the NVFP4 KV pool for MiniMax-M3.1: main KV and index K stored as NVFP4 page rows, Q8KV4 decode indexer with an FP8 fallback, MSA-v1 prefill, and pool sizing. It also adds an FP8 Q epilogue to the grouped QK-norm/RoPE kernel.

Changes to existing code

  • The attention registry selects this backend for the minimax_m3_nvfp4 KV stack.
  • The KV cache and pool configurators build the NVFP4 pool and size it by its per-token bytes for minimax_m3_nvfp4.
  • allocate_attention_outputs sizes the sparse output by the V dtype (bf16 when V is FP8) instead of the Q dtype, so an FP8 Q from the QK-norm epilogue does not make the output FP8. Only MiniMax-M3 reaches the sparse branch.
  • New PageRowBufferInfo in the device pool info union.

Verification

  • test_minimax_m31_msa_plan, test_minimax_m31_page_row_views, test_msa_v1_decode_plan, test_minimax_m31_nvfp4, test_minimax_qknorm_rope, test_minimax_sparse_nvfp4_idle

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


CI States

Latest PR Test (Base): 🚫 Run #40194769653
Latest PR Test (Extra): 🚫 Run #40194769621
Latest PR Test (AMD ROCm 10): ❌ Run #40194769625

@github-actions

This comment has been minimized.

@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test --changed

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

cd test/ && python3 registered/kernels/ops/attention/test_minimax_m31_msa_plan.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_m31_page_row_views.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_qknorm_rope.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_m31_nvfp4.py

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

cd test/ && python3 registered/kernels/ops/attention/test_minimax_qknorm_rope.py
cd test/ && python3 registered/kernels/ops/attention/test_msa_v1_decode_plan.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_m31_nvfp4.py

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/layers/attention/test_minimax_sparse_nvfp4_idle.py

ispobock and others added 5 commits October 24, 2026 01:51
Co-authored-by: zhongyu <[email protected]>
Co-authored-by: Denji-kk <[email protected]>
Co-authored-by: Thanhhao <[email protected]>
Co-authored-by: Hao Phan <[email protected]>
Co-authored-by: Shuwen Wang <[email protected]>
Co-authored-by: Qiaolin Yu <[email protected]>
Co-authored-by: Yuhao Yang <[email protected]>
Co-authored-by: Chunan Zeng <[email protected]>
Co-authored-by: zhongyu <[email protected]>
Co-authored-by: Denji-kk <[email protected]>
Co-authored-by: Qiaolin Yu <[email protected]>
Co-authored-by: Chunan Zeng <[email protected]>
Co-authored-by: Denji-kk <[email protected]>
Co-authored-by: zhongyu <[email protected]>
Co-authored-by: Thanhhao <[email protected]>
Co-authored-by: Hao Phan <[email protected]>
Co-authored-by: Denji-kk <[email protected]>
Co-authored-by: Shuwen Wang <[email protected]>
Co-authored-by: Qiaolin Yu <[email protected]>
@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test --changed

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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

cd test/ && python3 registered/kernels/ops/attention/test_minimax_m31_msa_plan.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_m31_page_row_views.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_qknorm_rope.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_m31_nvfp4.py

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

cd test/ && python3 registered/kernels/ops/attention/test_minimax_qknorm_rope.py
cd test/ && python3 registered/kernels/ops/attention/test_msa_v1_decode_plan.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_m31_nvfp4.py

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/layers/attention/test_minimax_sparse_nvfp4_idle.py

Base automatically changed from m31-nvfp4-moe to main October 25, 2026 12:42
@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 25, 2026
@ispobock

Copy link
Copy Markdown
Collaborator Author

/rerun-test registered/kernels/ops/attention/test_minimax_m31_msa_plan.py registered/kernels/ops/attention/test_minimax_m31_page_row_views.py registered/kernels/ops/attention/test_minimax_qknorm_rope.py registered/kernels/ops/attention/test_msa_v1_decode_plan.py registered/kernels/ops/kvcache/test_minimax_m31_nvfp4.py registered/unit/layers/attention/test_minimax_sparse_nvfp4_idle.py registered/unit/model_executor/test_pool_configurator.py registered/unit/model_executor/test_hisparse_pool_configurator.py registered/unit/model_executor/test_kv_canary_headroom.py registered/unit/mem_cache/test_kv_cache_configurator_draft_gate.py registered/unit/mem_cache/test_hisparse_max_token_pool_size.py registered/unit/mem_cache/test_dsa_pool_host_unit.py registered/unit/mem_cache/test_asymmetric_mha_pool_host_unit.py registered/kernels/ops/kvcache/test_hicache_strided_device_rows.py registered/unit/test_split_attention_backend_decisions.py registered/unit/layers/test_radix_attention_padded_extend.py registered/kernels/ops/attention/test_minimax_m3_qk_norm_rope.py registered/kernels/ops/attention/test_minimax_sparse_fp8_attn_gemm.py registered/kernels/ops/attention/test_minimax_sparse_gqa.py

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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

cd test/ && python3 registered/kernels/ops/attention/test_minimax_m31_msa_plan.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_m31_page_row_views.py
cd test/ && python3 registered/kernels/ops/attention/test_minimax_qknorm_rope.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_m31_nvfp4.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

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

cd test/ && python3 registered/kernels/ops/attention/test_minimax_qknorm_rope.py
cd test/ && python3 registered/kernels/ops/attention/test_msa_v1_decode_plan.py
cd test/ && python3 registered/kernels/ops/kvcache/test_minimax_m31_nvfp4.py
cd test/ && python3 registered/kernels/ops/kvcache/test_hicache_strided_device_rows.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

🚀 1-gpu-5090 (2 tests): ✅ View workflow run

cd test/ && python3 registered/unit/layers/attention/test_minimax_sparse_nvfp4_idle.py
cd test/ && python3 registered/unit/mem_cache/test_dsa_pool_host_unit.py

🚀 ubuntu-latest (8 tests): ❌ View workflow run

cd test/ && python3 registered/unit/model_executor/test_pool_configurator.py
cd test/ && python3 registered/unit/model_executor/test_hisparse_pool_configurator.py
cd test/ && python3 registered/unit/model_executor/test_kv_canary_headroom.py
cd test/ && python3 registered/unit/mem_cache/test_kv_cache_configurator_draft_gate.py
cd test/ && python3 registered/unit/mem_cache/test_hisparse_max_token_pool_size.py
cd test/ && python3 registered/unit/mem_cache/test_asymmetric_mha_pool_host_unit.py
cd test/ && python3 registered/unit/test_split_attention_backend_decisions.py
cd test/ && python3 registered/unit/layers/test_radix_attention_padded_extend.py

⛔ registered/kernels/ops/attention/test_minimax_m3_qk_norm_rope.py: test/registered/kernels/ops/attention/test_minimax_m3_qk_norm_rope.py is registered for AMD, not for CUDA or CPU; rerun-test.yml has no AMD job. Rerun it with /rerun-failed-ci, or dispatch the AMD workflow manually.

@ispobock
ispobock merged commit 4991bd3 into main Oct 25, 2026
234 of 256 checks passed
@ispobock
ispobock deleted the m31-sparse-nvfp4-backend branch October 25, 2026 14:34
mlleo added a commit to mlleo/sglang that referenced this pull request Oct 26, 2026
…stry

msa_plan.py's capability probe reads envs.SGLANG_DISABLE_MSA_V1_Q8KV4,
but the name was never registered in sglang/srt/environ.py, and Envs has
no __getattr__, so the read raises AttributeError. The probe runs inside
MiniMaxSparseNvfp4AttnBackend.__init__, so constructing the backend
(sgl-project#46141, two days old) crashes before the FP8 fallback can be selected.

The existing unit test constructs the backend via __new__ and never runs
__init__, which is why this did not fail in review.

Register the field next to SGLANG_DISABLE_MSA, and add a registry
completeness test to test_environ.py that collects every envs.<NAME>
read made through bindings of sglang.srt.environ.envs (plain or aliased)
and fails if any has no registration, so the next unregistered reference
fails in CPU CI instead of at backend construction.
@ispobock ispobock mentioned this pull request Oct 27, 2026
13 tasks done
detain added a commit to detain/sglang that referenced this pull request Oct 29, 2026
…mily + S-EXT1 + riders + S-RACE + LLGUARD/ENVREG), S-EXT1 and S-RACE items CLOSED, entry-256's raw-env deviation and LL-vs-PCIe-IPC collision warning both marked CLOSED with the BOOT_DELTA (h') needle in landing terms, sgl-project#35617 left as the sole FAM-A7 survivor, sgl-project#44732 re-pointed to the operator's merge-sgl-project#5 answer, and the KV-ROUTE DECISION RECORD added (HOLD NVFP4-KV until armed PCIe-IPC is measured post-merge; preferred-if-ever sequence merge -> sgl-project#43356-delta -> sgl-project#46452 NOT sgl-project#43240 -> optional sgl-project#43471 -> fork BUILD-A QSA FP4 reads (template sgl-project#38724) -> BUILD-B L3 scale sidecar -> one GPU window; sgl-project#46141 template, sgl-project#44462 NEXT, MXFP4 declined, entry-247 re-sync watch-string modelopt_e4m3_k32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blackwell SM100/SM120 bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) jit-kernel 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