vllm.model_executor.layers.sparse_attn_indexer ¶
Custom Sparse Attention Indexer layers.
Classes:
-
SparseAttnIndexer–Sparse Attention Indexer Custom Op Layer. This layer is extracted as a
Functions:
-
kv_cache_as_quant_view–4D
[num_blocks, block_size, 1, head_width]view expected by
SparseAttnIndexer ¶
Bases: CustomOp
Sparse Attention Indexer Custom Op Layer. This layer is extracted as a separate custom op since it involves heavy custom kernels like mqa_logits, paged_mqa_logits and top_k_per_row, etc. Those kernels maybe requires specific memory layout or implementation for different hardware backends to achieve optimal performance.
For now, the default native path will use CUDA backend path. Other platform may requires add the corresponding Custom Op name sparse_attn_indexer to custom_ops in CompilationConfig to enable the platform specific path.
Source code in vllm/model_executor/layers/sparse_attn_indexer.py
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 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | |
_gather_workspace_shapes(total_seq_lens, head_dim, fp8_dtype, use_fp4_cache) ¶
Return ((values_shape, values_dtype), (scales_shape, scales_dtype)) for the K-gather workspace. FP8 path: (T, head_dim) fp8 + (T, 4) uint8 fp32 scales. MXFP4 path: (T, head_dim // 2) uint8 packed mxfp4 + (T, head_dim // MXFP4_BLOCK_SIZE) uint8 ue8m0 scales.
Source code in vllm/model_executor/layers/sparse_attn_indexer.py
kv_cache_as_quant_view(kv_cache, head_dim, use_fp4_cache) ¶
4D [num_blocks, block_size, 1, head_width] view expected by DeepGEMM, from the 3D indexer kv-cache allocation.