Adamas:面向高效长上下文推理的阿达马稀疏注意力
Adamas: Hadamard Sparse Attention for Efficient Long-Context Inference
AI总结:
针对长上下文下自注意力二次开销高、现有稀疏注意力精度下降的问题,提出基于阿达马变换、分桶压缩和曼哈顿距离估计的Adamas稀疏注意力机制,在高稀疏度下实现近乎无损的精度和显著的推理加速。
摘要:
大语言模型(LLM)目前支持数十万到数百万token的上下文窗口,可实现长文档摘要、大规模代码合成、多文档问答以及持续多轮对话等应用。然而,这种扩展的上下文加剧了自注意力的二次计算开销,导致自回归解码出现严重延迟。现有的稀疏注意力方法虽能缓解这些开销,但依赖启发式模式,难以为每个查询召回关键的键值(KV)对,进而导致精度下降。我们提出Adamas——一种专为长上下文推理设计的轻量且高精度的稀疏注意力机制。Adamas运用阿达马变换、分桶和2位压缩生成紧凑表示,并利用曼哈顿距离估计实现高效的top-k选择。实验表明,Adamas仅用64个token的预算就能达到全注意力的精度,在128个token时实现近乎无损的性能,支持的稀疏度比现有最优(SOTA)方法最高高出8倍,同时在32K长度序列上实现最高4.4倍的自注意力加速和1.5倍的端到端加速。值得注意的是,Adamas的困惑度与全注意力相当甚至更低,凸显了其在高稀疏度下保持精度的有效性。
英文摘要:
Large language models (LLMs) now support context windows of hundreds of thousands to millions of tokens, enabling applications such as long-document summarization, large-scale code synthesis, multi-document question answering and persistent multi-turn dialogue. However, such extended contexts exacerbate the quadratic cost of self-attention, leading to severe latency in autoregressive decoding. Existing sparse attention methods reduce these costs by attending to only a subset of key-value (KV) tokens, but fixed or coarse-grained selection strategies can miss important tokens or retain substantial redundancy under constrained token budgets. We introduce \textbf{Adamas}, an accurate and efficient token-level sparse attention mechanism for long-context inference. Adamas applies the Hadamard transform, bucketization and 2-bit compression to produce compact representations, and uses lightweight distance-based estimation for efficient top-$k$ candidate selection. The selected positions are then used to gather the corresponding original KV states for sparse attention. Comprehensive evaluations show that Adamas maintains near-lossless performance within the effective context length of Llama-3.1-8B-Instruct. In efficiency evaluations, Adamas achieves up to $6.5\times$ self-attention speedup and $1.7\times$ end-to-end decoding speedup at a 32K context length. Adamas also maintains performance comparable to full attention on challenging long-form reasoning benchmarks, including AIME 2024 and AIME 2025.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。