Sample-Guided Exact Top-K Selection for Long-Context Sparse Attention
Siran Liu, Yang Xue, Theo Tang, Changxu Shao, Qian Cheng, Haimeng Ren, Donghua Jiang, Haipeng Ming, Lehua Ding, Zhonghan Lin, Shengying Wei, Wei Liu, Kai Liu, Jianchen Zhu
Abstract
Sparse attention bounds downstream attention work by retaining a fixed-size subset of indexed tokens, but its standalone exact Top- stage must still process materialized score rows whose length grows with context. Production radix selectors discover their first actionable boundary only after a complete-row pass, forcing another row-scale traversal before exact refinement. We observe that locating a compact upper tail requires substantially less resolution than identifying the exact rank boundary, and that fixed-stride partial views of the current row remain calibrated to the corresponding complete-row rank across ragged lengths. We present HPC-Ops Top-K, a sample-guided exact selector for ragged sparse-attention score rows. A fixed-stride view proposes a row-local coarse boundary; the mandatory complete-row pass certifies its sufficiency, forms the admitted candidate set, and initializes exact FP32 refinement over the unresolved frontier. A nested secondary boundary and exact recovery handle underfilled proposals before any output is committed, so sampling controls common-path work but never correctness. The GPU implementation fuses complete-row certification and candidate formation, and combines persistent, KV-split, and direct-exact execution behind graph-capturable ragged-row dispatch. We evaluate HPC-Ops Top-K on indexer scores from Hy4-Preview. It outperforms the fastest verified external exact baseline by -- across 20 operator configurations, with a geometric-mean speedup. It further achieves and speedups on two framework-derived sparse-attention traces. The implementation is available in HPC-Ops, Tencent's open-source high-performance operator library for LLM inference, at https://github.com/Tencent/hpc-ops.
Create a lesson
Metadata
- Comments
- 28 pages. Code: https://github.com/Tencent/hpc-ops
Related papers
SplitVerify: CPU-GPU Speculative Verification for Exact Long-Context Decoding
Shared title terminologycs.DCAswin Raj R
AttnEx: Sparse-Attention Indexing with Per-Layer Head Allocation and Streaming Top-k
Shared title terminologycs.DCDongfang Zhao
KVSeal: Serving Long-Context LLMs with Losslessly Compressed KV Caches
Shared title terminologycs.DCHangyu Liang, Zeyu Mi
Flattening Every Memory Peak in Long-Context Mixture-of-Experts Training
Shared title terminologycs.DCShrey Pandit, Xuan-Phi Nguyen, Yiran Zhao et al.
VPP: Virtual Pipeline Parallelism for Efficient Chunked Prefill in Long-Context LLM Inference
Shared title terminologycs.DCYan Shi, Xiaochao Wang, Jingchun Gao et al.
IndexServe: Disaggregating the Indexer as a Service for Efficient Sparse-Attention LLM Serving
Shared title terminologycs.DCYuzheng Wang, Yilong Luo, Junhao Hu et al.