arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.00874quant-phcs.DScs.LG
收藏

亚线性时间的注意力近似量子算法

Sublinear Time Quantum Algorithm for Attention Approximation

Simons Institute for the Theory of Computing, UC Berkeley(Simons理论计算研究所,伯克利大学);New York University(纽约大学);Massachusetts Institute of Technology(麻省理工学院)

Zhao Song, Jianfei Xue, Jiahao Zhang, Lichen Zhang

AI总结:

本文提出了一种量子算法,以亚线性时间近似注意力矩阵的行,利用量子Nyström近似、均值估计和杠杆得分采样技术。

摘要:

给定查询、键和值矩阵$Q, K, V\in \mathbb{R}^{n\times d}$,注意力模块定义为$\mathrm{Att}(Q, K, V)=D^{-1}AV$,其中$A=\exp(QK^\top/\sqrt{d})$,其中$\exp(\cdot)$是逐元素应用的指数函数,$D=\mathrm{diag}(A{\bf 1}_n)$。注意力模块是现代transformers和大语言模型的核心,但显式形成softmax矩阵$D^{-1}A$需要$Ω(n^2)$时间,这促使了众多近似方案,这些方案将运行时间减少到$\widetilde O(nd)$通过稀疏性或低秩分解。我们提出了一种量子数据结构,该结构仅使用行查询$Q, K, V$来近似任何行$\mathrm{Att}(Q, K, V)$。我们的算法预处理这些矩阵的时间为$\widetilde{O}\left( ε^{-1} n^{0.5} \left( s_λ^{2.5} + s_λ^{1.5} d + α^{0.5} d \right) \right)$,其中$ε$是目标精度,$s_λ$是指数核的$λ$-统计维度,定义由$Q$和$K$给出,$α$测量$V$的行扭曲,最大值为$d/{\rm srank}(V)$,即$V$的稳定秩。每个行查询可以在$\widetilde{O}(s_λ^2 + s_λd)$时间内回答。据我们所知,这是第一个以亚线性时间近似注意力矩阵行的量子数据结构,该时间与$n$无关。我们的方法依赖于指数核的量子Nyström近似、量子多变量均值估计用于计算$D$,以及量子杠杆得分采样用于与$V$的乘法。

英文摘要:

Given the query, key and value matrices $Q, K, V\in \mathbb{R}^{n\times d}$, the attention module is defined as $\mathrm{Att}(Q, K, V)=D^{-1}AV$ where $A=\exp(QK^\top/\sqrt{d})$ with $\exp(\cdot)$ applied entrywise, $D=\mathrm{diag}(A{\bf 1}_n)$. The attention module is the backbone of modern transformers and large language models, but explicitly forming the softmax matrix $D^{-1}A$ incurs $Ω(n^2)$ time, motivating numerous approximation schemes that reduce runtime to $\widetilde O(nd)$ via sparsity or low-rank factorization. We propose a quantum data structure that approximates any row of $\mathrm{Att}(Q, K, V)$ using only row queries to $Q, K, V$. Our algorithm preprocesses these matrices in $\widetilde{O}\left( ε^{-1} n^{0.5} \left( s_λ^{2.5} + s_λ^{1.5} d + α^{0.5} d \right) \right)$ time, where $ε$ is the target accuracy, $s_λ$ is the $λ$-statistical dimension of the exponential kernel defined by $Q$ and $K$, and $α$ measures the row distortion of $V$ that is at most $d/{\rm srank}(V)$, the stable rank of $V$. Each row query can be answered in $\widetilde{O}(s_λ^2 + s_λd)$ time. To our knowledge, this is the first quantum data structure that approximates rows of the attention matrix in sublinear time with respect to $n$. Our approach relies on a quantum Nyström approximation of the exponential kernel, quantum multivariate mean estimation for computing $D$, and quantum leverage score sampling for the multiplication with $V$.

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

↑