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
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 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | |
_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.