arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2403.02352cs.LGcs.AI
收藏

ATP: 通过对Top Principal Keys执行注意力实现快速大语言模型服务

ATP: Enabling Fast LLM Serving via Attention on Top Principal Keys

University of Southern California(南加州大学);University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校)

Yue Niu, Saurav Prakash, Salman Avestimehr

AI总结:

该研究提出线性复杂度注意力机制ATP,利用输入序列低秩特性,仅对top主基计算注意力,还优化低秩输入的线性层,在BERT、Llama等模型上以更低的计算和内存开销实现了接近标准注意力的准确率。

摘要:

我们提出了一种具有线性复杂度的新型注意力机制ATP(对Top Principal Keys执行注意力),它将注意力聚焦于Top Principal Keys,而非每个单独的token。具体而言,ATP的提出基于一项重要观察:输入序列通常是低秩的,即输入序列可由少数主基表示。因此,ATP无需直接遍历所有输入token,而是将输入转换到正交空间,仅对top主基(键)计算注意力。由于输入序列存在低秩结构,ATP能够通过少数主键捕捉输入序列中的语义关系,且将注意力复杂度从二次降至线性,同时不会引发明显的性能下降。ATP还进一步降低了其他处理低秩输入的线性层的复杂度,与仅针对注意力模块的现有工作相比,实现了更高的加速比。我们在多种模型(如BERT和Llama)上的评估表明,与标准注意力机制相比,ATP在计算和内存复杂度低得多的情况下,仍能达到相当的准确率。具体而言,仅使用1/2的主键时,ATP几乎没有准确率损失;使用1/4的主键时,准确率仅下降约2%。

英文摘要:

We propose a new attention mechanism with linear complexity, ATP, that fixates \textbf{A}ttention on \textbf{T}op \textbf{P}rincipal keys, rather than on each individual token. Particularly, ATP is driven by an important observation that input sequences are typically low-rank, i.e., input sequences can be represented by a few principal bases. Therefore, instead of directly iterating over all the input tokens, ATP transforms inputs into an orthogonal space and computes attention only on the top principal bases (keys). Owing to the observed low-rank structure in input sequences, ATP is able to capture semantic relationships in input sequences with a few principal keys. Furthermore, the attention complexity is reduced from \emph{quadratic} to \emph{linear} without incurring a noticeable performance drop. ATP further reduces complexity for other linear layers with low-rank inputs, leading to more speedup compared to prior works that solely target the attention module. Our evaluations on various models (e.g., BERT and Llama) demonstrate that ATP achieves comparable accuracy with much lower computation and memory complexity than the standard attention mechanism. In particular, ATP barely loses accuracy with only $1/2$ principal keys, and only incurs around $2\%$ accuracy drops with $1/4$ principal keys.

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

↑