arXiv:2608.04405cs.LGcs.AI2026-08

无需训练的二值主成分哈希注意力,提升长文本大模型推理速度

Training-Free Hashing-Based Attention via Binary Principal Components

论文配图:Training-Free Hashing-Based Attention via Binary Principal Components
图 1 · 摘自论文原文
  • 基于数据结构信息构造二值哈希码,不依赖训练或随机投影
  • 在多个长文本基准上保持全注意力精度,解码吞吐提升3.56倍
  • 适合追求高效推理且不想改模型的工程师与研究者

长上下文大语言模型在实际应用中日益普及,但自注意力机制仍是主要效率瓶颈,尤其在解码阶段需反复处理不断增长的键值缓存。现有稀疏注意力通过减少关注的键值对来降低计算量,但常导致精度显著下降、需要额外训练或依赖昂贵的哈希方法。本文提出BinaryPC,一种无需训练、数据感知的基于哈希的稀疏注意力方法。BinaryPC通过计算数据的二值主成分,构建紧凑的二值哈希码及其对应哈希函数。与依赖数据无关的随机投影或学习型非线性哈希不同,BinaryPC生成的二值码能显式保留数据结构信息,且无需梯度训练。在多个模型家族和长文本基准上的综合实验表明,BinaryPC在保持全注意力精度的同时,优于现有稀疏与基于哈希的基线方法。在现代GPU上,相比FlashAttention内核,其端到端解码吞吐提升3.56倍。代码已开源:https://github.com/yudaohai666/BPC。

原文摘要 · Abstract (English)

Long-context large language models (LLMs) are increasingly deployed in real-world applications, yet self-attention remains a major efficiency bottleneck -- especially during decoding -- due to the necessity of repeatedly processing ever-growing key-value (KV) caches. Existing sparse attention reduce computation by attending to fewer KV pairs, but often suffer from substantial accuracy degradation, require additional training, or rely on expensive hashing. In this work, we present BinaryPC, a training-free, data-aware hashing-based sparse attention for long-context LLMs. BinaryPC constructs compact binary hash codes and corresponding hash function by computing binary principal components of data. Unlike Locality-Sensitive Hashing (LSH) with data-independent random projections or learned non-linear hashing methods, BinaryPC constructs binary codes that explicitly preserve the structural information of data without requiring gradient-based training. Comprehensive experiments across multiple model families and long-context benchmarks show that BinaryPC preserves accuracy relative to full attention while achieving superior performance among sparse and hashing-based baselines. On modern GPUs, BinaryPC improves end-to-end decoding throughput by 3.56$\times$ over the FlashAttention kernel. Our code is available at https://github.com/yudaohai666/BPC.

注意力机制哈希方法长文本生成推理加速

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。