在变压器研究中,人们普遍认为“注意力即一切所需”,但所需的注意力量从未被系统量化。二次$O(L^2)$注意力是否必要,还是存在一种亚二次注意力机制能够实现类似性能?为回答这一问题,我们引入了基于功率的局部注意力(PPA),其注意力顺序为$O(L^{1+p})$,其中$0 \leq p \leq 1$,$p=0$对应线性复杂度的滑动窗口注意力,$p=1$对应全注意力。通过这种注意力构造,我们可以探索transformer架构性能如何随注意力缩放行为(由$p$控制)而变化。我们的实验总体趋势显示,性能在$p$值的狭窄范围内从滑动窗口(线性复杂度)注意力过渡到全注意力,并在$p$接近1时趋于平稳。在我们的实验中,我们展示了存在$0<p<1$使得$O(L^{1+p})$注意力足以实现与$O(L^2)$全注意力相似的结果。
英文摘要:
It is widely accepted from transformer research that "attention is all we need", but the amount of attention required has never been systematically quantified. Is quadratic $O(L^2)$ attention necessary, or is there a sub-quadratic attention mechanism that can achieve comparable performance? To answer this question, we introduce power-based partial attention (PPA), an attention mechanism of order $O(L^{1+p})$, where $0 \leq p \leq 1$, such that $p=0$ corresponds to sliding window attention with linear complexity, and $p=1$ corresponds to full attention. With this attention construction, we can explore how transformer architecture performance varies as a function of the attention scaling behavior controlled by $p$. The overall trend from our experiments shows an S-curve-like behavior where the performance transitions from sliding-window (linear-complexity) attention to full attention over a narrow window of $p$ values, and plateaus as $p$ approaches $1$. In our experiments, we show that there exists $0<p<1$ such that $O(L^{1+p})$ attention is sufficient to achieve similar results as $O(L^2)$ full attention.
QFlash: Bridging Quantization and Memory Efficiency in Vision Transformer Attention
University of Science and Technology(科学技术大学);Electronics and Telecommunications Research Institute(电信研究所);Pusan National University(釜山国立大学);Jeonbuk National University(全州国立大学)
RollVerify: Bridging Efficiency and Accuracy in Long-Tail Rollout Reinforcement Learning
Shanghai Jiao Tong University(上海交通大学);Central South University(中南大学);SenseTime Research(商汤科技研究院);The Chinese University of Hong Kong(香港中文大学);Beihang University(北京航空航天大学)
Efficiently Dispatching Flash Attention For Partially Filled Attention Masks
University of Tübingen(蒂宾根大学);Tübingen AI Center(蒂宾根人工智能中心);ELLIS Institute Tübingen(ELLIS蒂宾根研究所);Max Planck Institute for Intelligent Systems(马克斯·普朗克智能系统研究所)