vllm.models.minimax_m3.amd.ops.sparse_attn ¶
ROCm gfx942/gfx950 block-sparse GQA prefill kernel for MiniMax-M3.
Only the prefill path is specialized on CDNA: each 128-token KV block is split into SUB_K-token sub-tiles to right-size the per-block QK/PV MFMAs. Everything else -- the decode split-K kernels, the FP8 dtype set, the sparse block size -- is reused unchanged from common.ops.sparse_attn.
Functions:
-
minimax_m3_sparse_attn–GQA block-sparse attention over the selected blocks. block_size_q == 1.
-
minimax_m3_sparse_attn_decode–GQA block-sparse attention for decode (split-K over the top-k blocks).
_sparse_attn_prefill_kwargs() ¶
MFMA + pipeline launch params for the sub-tiled prefill kernel.
gfx942 and gfx950 share the same params: num_warps=1 keeps one wave resident on the small per-sub-tile GEMM, matrix_instr_nonkdim=16 / kpack=2 select the MFMA_16x16 path, and num_stages=1 fits LDS and is fastest in the sweep. Only the sub-tile width (_SPARSE_ATTN_SUB_K) differs by arch. Empty on other AMD archs. Cached: arch is fixed per process.
Source code in vllm/models/minimax_m3/amd/ops/sparse_attn.py
minimax_m3_sparse_attn(q, kv_cache, topk_idx, block_table, cu_seqlens_q, seq_lens, prefix_lens, max_query_len, num_kv_heads, sm_scale, output, k_scale=None, v_scale=None) ¶
GQA block-sparse attention over the selected blocks. block_size_q == 1.
Source code in vllm/models/minimax_m3/amd/ops/sparse_attn.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
minimax_m3_sparse_attn_decode(q, kv_cache, topk_idx, block_table, seq_lens, num_kv_heads, sm_scale, output, decode_query_len, k_scale=None, v_scale=None) ¶
GQA block-sparse attention for decode (split-K over the top-k blocks).
Source code in vllm/models/minimax_m3/common/ops/sparse_attn.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | |