vllm.models.minimax_m3.common.indexer
¶
MiniMax M3 lightning indexer: side cache, metadata, and impl.
The indexer scores KV blocks with the index heads and selects the top-k blocks
(plus fixed init/local blocks) that the main block-sparse attention
(sparse_attention.py) then attends to. It owns its own side cache
(MiniMaxM3IndexerCache, one index-key vector per token), metadata, and
metadata builder, mirroring how DeepSeek V4 keeps the indexer separate from the
main attention.
MiniMaxM3Indexer is the nn.Module the attention layer holds (like
DeepseekV4Indexer); it picks a kernel impl in __init__ (via
select_indexer_impl_cls) and delegates forward to it.
Classes:
-
MiniMaxM3Indexer–Indexer module held by the attention layer (like
DeepseekV4Indexer). -
MiniMaxM3IndexerBackend–Indexer side-cache backend (key-only).
-
MiniMaxM3IndexerCache–Side KV cache for the indexer's per-token index keys (key-only).
-
MiniMaxM3IndexerDecodeMetadata–Per-decode state (cudagraph-safe).
decode_query_lenis the uniform -
MiniMaxM3IndexerImpl–Abstract base for the indexer kernel impls.
-
MiniMaxM3IndexerMetadata–Indexer metadata, split into prefill and decode sub-metadata.
-
MiniMaxM3IndexerMetadataBuilder–Abstract base: shared setup only. The Triton and MSA builders are
-
MiniMaxM3IndexerPrefillMetadata–Per-prefill index-scoring state.
-
MiniMaxM3IndexerTritonImpl–Triton indexer score + top-k for both prefill and decode.
-
MiniMaxM3IndexerTritonMetadataBuilder–Triton indexer metadata: no SM100 fmha_sm100 plan.
Functions:
-
select_indexer_impl_cls–Pick the indexer impl off the platform, top-k count, and cache dtype.
MiniMaxM3Indexer
¶
Bases: Module
Indexer module held by the attention layer (like DeepseekV4Indexer).
Picks the kernel impl in __init__ (select_indexer_impl_cls) and
delegates forward; exposes the impl's side cache via index_cache.
Source code in vllm/models/minimax_m3/common/indexer.py
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 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | |
MiniMaxM3IndexerBackend
¶
Bases: AttentionBackend
Indexer side-cache backend (key-only).
Source code in vllm/models/minimax_m3/common/indexer.py
MiniMaxM3IndexerCache
¶
Bases: Module, AttentionLayerBase
Side KV cache for the indexer's per-token index keys (key-only).
Registers itself in the static forward context so the KV-cache manager
allocates it (like DeepseekV32IndexerCache).
Source code in vllm/models/minimax_m3/common/indexer.py
MiniMaxM3IndexerDecodeMetadata
dataclass
¶
Per-decode state (cudagraph-safe). decode_query_len is the uniform
per-request query length (1, or 1 + num_speculative_tokens); it is 0 for
a ragged batch, whose query lengths come from query_start_loc.
Source code in vllm/models/minimax_m3/common/indexer.py
MiniMaxM3IndexerImpl
¶
Bases: Module
Abstract base for the indexer kernel impls.
Each impl owns its side cache and reports its backend via
indexer_backend_cls (so each gets its own builder). The Triton and MSA
subclasses each own a full forward returning (decode_topk,
prefill_topk) -- no shared forward code.
Methods:
-
forward–Return
(decode_topk, prefill_topk); implemented per kernel impl. -
reserve_workspace–Reserve the workspace-manager scratch
forwardneeds; called from
Source code in vllm/models/minimax_m3/common/indexer.py
MiniMaxM3IndexerMetadata
dataclass
¶
Bases: AttentionMetadata
Indexer metadata, split into prefill and decode sub-metadata.
Source code in vllm/models/minimax_m3/common/indexer.py
MiniMaxM3IndexerMetadataBuilder
¶
Bases: VarlenDecodeBuilderMixin, AttentionMetadataBuilder[MiniMaxM3IndexerMetadata]
Abstract base: shared setup only. The Triton and MSA builders are
parallel subclasses that each own their full build (no shared code).
Source code in vllm/models/minimax_m3/common/indexer.py
MiniMaxM3IndexerPrefillMetadata
dataclass
¶
Per-prefill index-scoring state.
Source code in vllm/models/minimax_m3/common/indexer.py
MiniMaxM3IndexerTritonImpl
¶
Bases: MiniMaxM3IndexerImpl
Triton indexer score + top-k for both prefill and decode.
Source code in vllm/models/minimax_m3/common/indexer.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
MiniMaxM3IndexerTritonMetadataBuilder
¶
Bases: MiniMaxM3IndexerMetadataBuilder
Triton indexer metadata: no SM100 fmha_sm100 plan.
Source code in vllm/models/minimax_m3/common/indexer.py
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 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
select_indexer_impl_cls(*, topk_blocks, indexer_kv_dtype='bf16', use_flashinfer_msa=False)
¶
Pick the indexer impl off the platform, top-k count, and cache dtype.
On Blackwell (SM100) with topk_blocks == 16 (the only width fmha_sm100's
sparse_topk_select kernel supports), the fmha_sm100 score + top-k path is
used for both bf16 and fp8 index caches. An nvfp4 index cache uses the MSA
Q8KV4/Q8KV8 paged indexers (SM100/SM103/SM107 only). On SM90 and SM120/SM121, the
flashinfer.msa_ops impl is used when the caller passes the
minimax_m3_use_flashinfer_msa verdict. Everything else falls back to
the Triton indexer, with fp8 restricted to CUDA platforms that advertise fp8
support and to ROCm gfx942 (MI300-series, CDNA3). gfx950 (MI350-series)
takes the fp8 path through the AITER indexer instead, so this fallback
stays bf16-only there.
Source code in vllm/models/minimax_m3/common/indexer.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 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 | |