Skip to main content
CenXiv.org
此网站处于试运行阶段,支持我们!
我们衷心感谢所有贡献者的支持。
贡献
赞助
cenxiv logo > cs > arXiv:2505.14840

帮助 | 高级搜索

计算机科学 > 机器学习

arXiv:2505.14840 (cs)
[提交于 2025年5月20日 ]

标题: 任意温度下注意力的次二次算法和难度

标题: Subquadratic Algorithms and Hardness for Attention with Any Temperature

Authors:Shreya Gupta, Boyang Huang, Barna Saha, Yinzhan Xu, Christopher Ye
摘要: 尽管Transformer架构很受欢迎,但计算Attention的标准算法在上下文长度上具有二次时间复杂度$n$。 Alman和Song [NeurIPS 2023]表明,当头维度$d = \Theta(\log n)$时,在强指数时间假设($\mathsf{SETH}$)下,只有当输入的绝对值被$B = o(\sqrt{\log n})$界限时,才能实现次二次Attention。 等价地,当对$d=\Theta(\log n)$使用高温softmax时,才能实现次二次Attention。 这些算法的运行时间呈指数级依赖于$B$,因此它们在$B$的特定范围之外并不能导致多项式时间算法。 这自然引出了一个问题:在不施加强温度假设的情况下,何时可以高效地计算Attention? 有快速注意力算法能够在条目大小上以多项对数时间复杂度进行吗$B$? 在本工作中,我们解决了这个问题,并描述了在任意温度下实现快速注意力的条件。 首先,对于所有常数$d = O(1)$,我们给出了第一个次二次$\tilde{O}(n^{2 - 1/d} \cdot \mathrm{polylog}(B))$时间的注意力算法,适用于大的$B$。 即使矩阵具有较大的头维度,只要它们的秩较低,我们的结果仍然成立。 在这个范围内,我们也为注意力梯度计算提供了类似的运行时间,因此也适用于完整的LLM训练过程。 此外,我们表明对我们的算法进行重大改进是不太可能的。 特别是,我们证明了即使当$d = 2^{\Theta(\log^* n)}$时,注意力在$\mathsf{SETH}$下需要$n^{2 - o(1)}$时间。 最后,在$d = \mathrm{poly}(n)$的情况下,我们证明在流行的细粒度复杂性假设下,标准算法是最佳的。
摘要: Despite the popularity of the Transformer architecture, the standard algorithm for computing Attention suffers from quadratic time complexity in context length $n$. Alman and Song [NeurIPS 2023] showed that when the head dimension $d = \Theta(\log n)$, subquadratic Attention is possible if and only if the inputs have small entries bounded by $B = o(\sqrt{\log n})$ in absolute values, under the Strong Exponential Time Hypothesis ($\mathsf{SETH}$). Equivalently, subquadratic Attention is possible if and only if the softmax is applied with high temperature for $d=\Theta(\log n)$. Running times of these algorithms depend exponentially on $B$ and thus they do not lead to even a polynomial-time algorithm outside the specific range of $B$. This naturally leads to the question: when can Attention be computed efficiently without strong assumptions on temperature? Are there fast attention algorithms that scale polylogarithmically with entry size $B$? In this work, we resolve this question and characterize when fast Attention for arbitrary temperatures is possible. First, for all constant $d = O(1)$, we give the first subquadratic $\tilde{O}(n^{2 - 1/d} \cdot \mathrm{polylog}(B))$ time algorithm for Attention with large $B$. Our result holds even for matrices with large head dimension if they have low rank. In this regime, we also give a similar running time for Attention gradient computation, and therefore for the full LLM training process. Furthermore, we show that any substantial improvement on our algorithm is unlikely. In particular, we show that even when $d = 2^{\Theta(\log^* n)}$, Attention requires $n^{2 - o(1)}$ time under $\mathsf{SETH}$. Finally, in the regime where $d = \mathrm{poly}(n)$, we show that the standard algorithm is optimal under popular fine-grained complexity assumptions.
评论: 34页,2图,摘要已缩短以符合arXiv要求
主题: 机器学习 (cs.LG) ; 计算复杂性 (cs.CC)
ACM 类: F.2.1
引用方式: arXiv:2505.14840 [cs.LG]
  (或者 arXiv:2505.14840v1 [cs.LG] 对于此版本)
  https://doi.org/10.48550/arXiv.2505.14840
通过 DataCite 发表的 arXiv DOI

提交历史

来自: Christopher Ye [查看电子邮件]
[v1] 星期二, 2025 年 5 月 20 日 19:12:43 UTC (41 KB)
全文链接:

获取论文:

    查看标题为《》的 PDF
  • 查看中文 PDF
  • 查看 PDF
  • HTML(实验性)
  • TeX 源代码
许可图标 查看许可
当前浏览上下文:
cs.LG
< 上一篇   |   下一篇 >
新的 | 最近的 | 2025-05
切换浏览方式为:
cs
cs.CC

参考文献与引用

  • NASA ADS
  • 谷歌学术搜索
  • 语义学者
a 导出 BibTeX 引用 加载中...

BibTeX 格式的引用

×
数据由提供:

收藏

BibSonomy logo Reddit logo

文献和引用工具

文献资源探索 (什么是资源探索?)
连接的论文 (什么是连接的论文?)
Litmaps (什么是 Litmaps?)
scite 智能引用 (什么是智能引用?)

与本文相关的代码,数据和媒体

alphaXiv (什么是 alphaXiv?)
CatalyzeX 代码查找器 (什么是 CatalyzeX?)
DagsHub (什么是 DagsHub?)
Gotit.pub (什么是 GotitPub?)
Hugging Face (什么是 Huggingface?)
带有代码的论文 (什么是带有代码的论文?)
ScienceCast (什么是 ScienceCast?)

演示

复制 (什么是复制?)
Hugging Face Spaces (什么是 Spaces?)
TXYZ.AI (什么是 TXYZ.AI?)

推荐器和搜索工具

影响之花 (什么是影响之花?)
核心推荐器 (什么是核心?)
IArxiv 推荐器 (什么是 IArxiv?)
  • 作者
  • 地点
  • 机构
  • 主题

arXivLabs:与社区合作伙伴的实验项目

arXivLabs 是一个框架,允许合作伙伴直接在我们的网站上开发和分享新的 arXiv 特性。

与 arXivLabs 合作的个人和组织都接受了我们的价值观,即开放、社区、卓越和用户数据隐私。arXiv 承诺这些价值观,并且只与遵守这些价值观的合作伙伴合作。

有一个为 arXiv 社区增加价值的项目想法吗? 了解更多关于 arXivLabs 的信息.

这篇论文的哪些作者是支持者? | 禁用 MathJax (什么是 MathJax?)
  • 关于
  • 帮助
  • contact arXivClick here to contact arXiv 联系
  • 订阅 arXiv 邮件列表点击这里订阅 订阅
  • 版权
  • 隐私政策
  • 网络无障碍帮助
  • arXiv 运营状态
    通过...获取状态通知 email 或者 slack

京ICP备2025123034号