vllm.models.glm5next.amd.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/amd/sparse_indexer.py
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 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 | |
_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.
Source code in vllm/models/glm5next/amd/sparse_indexer.py
_kpool_decode_topk_backend(configured, *, num_rows, max_valid_seq_len, select_k, index_kpool, full_cudagraph)
¶
Select the topk backend for decodes.
Heuristic based on ctx lengths: - <16k pools: in-tree hip kernel - 16-256k pools: use aiter - >256k pools: in-tree because not measured on >1m ctx
Since under FULL cudagraphs we cannot access the context length, and the aiter kernel does not always outperform the in-tree kernel, we default to in-tree kernel under FULL cudagraphs. Users can opt in if they know their context length is long enough to benefit from aiter.