vllm.models.glm5next.nvidia.sparse_indexer
¶
Custom Sparse Attention Indexer layers.
Classes:
-
SparseAttnIndexerKpool–Sparse Attention Indexer Custom Op Layer. This layer is extracted as a
SparseAttnIndexerKpool
¶
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/models/glm5next/nvidia/sparse_indexer.py
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 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 | |
_kpool_compress_insert(k, gate_score, ape, kv_cache, slot_mapping, kpool, head_dim, round_scale)
¶
Pool kpool consecutive tokens into one fp8 K and write at pool slots.
slot_mapping is pool-granular (compress_ratio == kpool on the spec):
only the last token of each complete pool carries a valid (>=0) slot;
intra-pool tokens are -1. Every position is treated as a pool-completion
candidate and non-completions are masked off inside the kernel. Compacting
the valid rows first costs two device syncs on the eager prefill path and
buys nothing numerically. Assumes pool-aligned chunk starts.