arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.11332cs.CCcs.LG
收藏

Transformer 的计算难度

On the Computational Hardness of Transformers

Barna Saha, Yinzhan Xu, Christopher Ye, Hantao Yu

AI总结:

本文研究了 Transformer 的计算难度,证明了在小嵌入和大嵌入 regime 下,多头多层 Transformer 的计算下界,表明无法通过并行计算更高效地解决注意力问题。

摘要:

Transformer 已经在语言、视觉等领域彻底改变了现代人工智能。它由 L 层组成,每层并行运行 H 个注意力头,并将综合输出馈送至下一层。在注意力机制中,输入由 N 个标记组成,每个标记是一个维度为 m 的向量。注意力机制涉及乘以三个 N×m 矩阵,对中间产品应用 softmax。近年来,一些工作已推动了我们对注意力复杂性的理解。已知的 Transformer 算法计算每个注意力头独立进行。这提出了一个在 TCS 中反复出现的问题:是否可以比单独解决每个实例更高效地解决多个相同问题的实例?在通信复杂性和算法设计等领域,许多正反两方面的答案已经出现。因此,我们问是否可以比单独计算 LH 个注意力头更高效地计算 Transformer。在本文中,我们以否定方式回答这个问题,并给出了多头多层 Transformer 的第一个非平凡计算下界。在小嵌入 regime(m = N^{o(1)})中,单独计算 LH 个注意力头需要 LHN^{2 + o(1)} 时间。我们证明这在 SETH 下本质上是最优的。在大嵌入 regime(m = N)中,可以使用 LHN^{ω+ o(1)} 算术运算(加指数)来单独计算 LH 个注意力头。我们证明这是最优的,通过显示当 ω> 2 时,需要 LHN^{ω- o(1)} 算术运算。在大嵌入 regime 中的下界依赖于 Baur-Strassen 定理的新应用,这是著名反向传播算法背后强大的算法工具。

英文摘要:

The transformer has revolutionized modern AI across language, vision, and beyond. It consists of $L$ layers, each running $H$ attention heads in parallel and feeding the combined output to the subsequent layer. In attention, the input consists of $N$ tokens, each a vector of dimension $m$. The attention mechanism involves multiplying three $N \times m$ matrices, applying softmax to an intermediate product. Several recent works have advanced our understanding of the complexity of attention. Known algorithms for transformers compute each attention head independently. This raises a fundamental question that has recurred throughout TCS under the guise of ``direct sum'' problems: can multiple instances of the same problem be solved more efficiently than solving each instance separately? Many answers to this question, both positive and negative, have arisen in fields spanning communication complexity and algorithm design. Thus, we ask whether transformers can be computed more efficiently than $LH$ independent evaluations of attention. In this paper, we resolve this question in the negative, and give the first non-trivial computational lower bounds for multi-head multi-layer transformers. In the small embedding regime ($m = N^{o(1)}$), computing $LH$ attention heads separately takes $LHN^{2 + o(1)}$ time. We establish that this is essentially optimal under SETH. In the large embedding regime ($m = N$), one can compute $LH$ attention heads separately using $LHN^{ω+ o(1)}$ arithmetic operations (plus exponents), where $ω$ is the matrix multiplication exponent. We establish that this is optimal, by showing that $LHN^{ω- o(1)}$ arithmetic operations are necessary when $ω> 2$. Our lower bound in the large embedding regime relies on a novel application of the Baur-Strassen theorem, a powerful algorithmic tool underpinning the famous backpropagation algorithm.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑