arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2302.02451cs.LGcs.CVcs.DS

KDEformer:通过核密度估计加速Transformers

KDEformer: Accelerating Transformers via Kernel Density Estimation

Max-Planck-Institut für Informatik(马克斯·普朗克信息学研究所);Yale University(耶鲁大学);New York University(纽约大学)

Amir Zandieh, Insu Han, Majid Daliri, Amin Karbasi

AI总结:

提出KDEformer,利用核密度估计求解器在亚二次时间内近似注意力计算,提供可证明的谱范数界限,并在图像生成与分类任务中实现显著加速且精度损失极小。

摘要:

点积注意力机制在现代深度架构(如Transformer)的序列建模中起着至关重要的作用,然而,该模型朴素精确计算在序列长度上产生二次时间和内存复杂度,阻碍了长序列模型的训练。关键瓶颈源于softmax函数分母中配分函数的计算,以及softmax矩阵与值矩阵的乘法。我们的关键观察是,前者可归约为核密度估计(KDE)问题的变体,且高效的KDE求解器可通过基于子采样的快速矩阵乘积进一步加速后者。我们提出的KDEformer能在亚二次时间内近似注意力,并提供可证明的谱范数界限,而所有先前结果仅提供逐项误差界限。在实验上,我们验证了KDEformer在各种预训练模型上的准确率、内存和运行时间均优于其他注意力近似方法。在BigGAN图像生成中,我们获得了比精确计算更好的生成得分,且加速超过4倍。对于使用T2T-ViT的ImageNet分类,KDEformer显示出超过18倍的加速,同时准确率下降不到0.5%。

英文摘要:

Dot-product attention mechanism plays a crucial role in modern deep architectures (e.g., Transformer) for sequence modeling, however, naïve exact computation of this model incurs quadratic time and memory complexities in sequence length, hindering the training of long-sequence models. Critical bottlenecks are due to the computation of partition functions in the denominator of softmax function as well as the multiplication of the softmax matrix with the matrix of values. Our key observation is that the former can be reduced to a variant of the kernel density estimation (KDE) problem, and an efficient KDE solver can be further utilized to accelerate the latter via subsampling-based fast matrix products. Our proposed KDEformer can approximate the attention in sub-quadratic time with provable spectral norm bounds, while all prior results merely provide entry-wise error bounds. Empirically, we verify that KDEformer outperforms other attention approximations in terms of accuracy, memory, and runtime on various pre-trained models. On BigGAN image generation, we achieve better generative scores than the exact computation with over $4\times$ speedup. For ImageNet classification with T2T-ViT, KDEformer shows over $18\times$ speedup while the accuracy drop is less than $0.5\%$.

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

↑