Sublinear Time Quantum Algorithm for Attention Approximation
Listen
Radio episode about this paper
Transcript
Introduction to the show: ident: Quantum Radio. Generated commentary on the latest quantum physics and condensed matter papers.
Kai: I'm Kai.
Mira: And I'm Mira, here with Lev.
Kai: We're looking at the paper: "Sublinear Time Quantum Algorithm for Attention Approximation".
Paper summary: Kai: So we're looking at the paper "Sublinear Time Quantum Algorithm for Attention Approximation" and what it actually claims. They are tackling that quadratic time complexity in the attention module for large language models, which is a huge problem because of how much data these models can process >
Mira: The thesis is that they propose a quantum data structure that approximates any row of the attention module Att(Q, K, V) using only row queries to Q, K and V >
Lev: So they’re not trying to compute the whole matrix Att(Q, K, V) = D minus one A directly but instead focusing on approximating just one of those rows >
Kai: The claim is that their algorithm preprocesses these matrices in big O of epsilon minus one n point zero five s squared point five lambda plus s point one five lambda d plus alpha point zero five d time >
Mira: And the key result they prove is that each row query can be answered in time big O of s squared lambda plus s sub lambda d time >
Lev: This gives them sublinear runtime with respect to n for a single query, which is what they're trying to achieve >
Kai: They achieve this by combining several quantum techniques: a quantum Nyström approximation of the exponential kernel matrix, quantum multivariate mean estimation for computing D, and quantum leverage score sampling for the multiplication with V >
Mira: That’s how they build up each component of the attention module: D, A, and V using these specialized quantum approaches >
Lev: The authors provide a formal theorem that gives an end-to-end guarantee on estimating the normalization factor by combining these approximations for D, A, and V >
Kai: That theorem shows the error in Frobenius norm is bounded by something involving epsilon times the inverse of beta times some terms related to n squared and lambda >
Mira: And they also acknowledge that their result gives a Frobenius norm guarantee rather than a spectral norm guarantee and there’s an additive term in the error bound that could be pessimistic >
Lev: So, while it’s sublinear in n for row queries, we have to consider how those approximations translate to actual performance on real quantum hardware >
Conclusion: Kai: So looking at this paper "Sublinear Time Quantum Algorithm for Attention Approximation" and the title itself, it’s about finding a way around the big quadratic cost in transformer attention modules >
Mira: It sounds like they are proposing a quantum data structure that lets you approximate any row of that attention module using just row queries to Q, K and V >
Lev: The implication is that if we can achieve this sublinear time performance for inference settings where only row queries are needed, it could significantly improve the scalability of these models >
Kai: It’s about moving away from the need to compute the entire attention matrix, which is what causes all that quadratic scaling on training and inference >
Mira: And they used quantum techniques like Grover search and multivariate mean estimation to build up approximations for D, A, and V in a way that scales better than classical methods allow >
Lev: From an engineering standpoint, the challenge right now is figuring out how to map this theoretical complexity onto the actual physical constraints of qubits and memory access for this kind of operation >
Zhao Song, Jianfei Xue, Jiahao Zhang, Lichen Zhang
Simons Institute for the Theory of Computing, UC Berkeley · New York University · Massachusetts Institute of Technology
quant-ph, cs.DS, cs.LG
Submitted: 2026-01-31
Updated: 2026-11-23
Comments: ICLR 2026. This version corrects the main theorem: the preprocessing time, the row-query count, and the error bound, whose $λ\sqrt{n}$ term is additive and which needs large row sums and a full-rank Nystrom factor. The product with V now samples rows by squared norms, as the published leverage-score step and its boosting were invalid, and the error proof is completed
License: http://creativecommons.org/licenses/by-nc-sa/4.0/
Importance score: 100/100
The gist: Given the query, key and value matrices Q, K, V ∈ R n×d, the attention module is defined as Att(Q, K, V) = D−1AV where.
Key concepts
- Attention Matrix Approximation
- The attention matrix is central to transformers but requires $O(n^2)$ time classically. This paper aims to approximate any single row of this matrix efficiently using only queries against the input matrices Q, K, and V without forming the full $n \times n$ matrix.
- Quantum Nyström Approximation
- This technique is used to approximate the exponential kernel that defines the attention mechanism. It leverages quantum primitives to create a low-rank approximation of this complex kernel matrix, which is crucial for reducing computational complexity during preprocessing.
- Row Query Model
- Instead of calculating the entire attention matrix, this model focuses on answering only row queries. This is particularly useful in inference settings where only specific output rows are needed, allowing for sublinear time computation relative to the input size $n$.
Terminology
Summary
Given the query, key and value matrices Q, K, V ∈ R n×d, the attention module is defined as Att(Q, K, V) = D−1AV where. p. 0 Sublinear Time Quantum Algorithm for Attention Approximation
Zhao Song∗ Jianfei Xue† Jiahao Zhang‡ Lichen Zhang§
Abstract
Given the query, key and value matrices Q, K, V ∈ R
n×d
, the attention module is defined as Att(Q, K, V ) = D−1AV where A = exp(QK⊤/
√
d) with exp(·) applied entrywise,
D = diag(A1n). The attention module is the backbone of modern transformers and large
language models, but explicitly forming the softmax matrix D−1A incurs Ω(n
2
) time, motivating numerous approximation schemes that reduce runtime to Oe(nd) via sparsity or low-rank
factorization. Sublinear Time Quantum Algorithm for Attention Approximation
Zhao Song∗ Jianfei Xue† Jiahao Zhang‡ Lichen Zhang§
Abstract
Given the query, key and value matrices Q, K, V ∈ R
n×d
, the attention module is defined as Att(Q, K, V ) = D−1AV where A = exp(QK⊤/
√
d) with exp(·) applied entrywise,
D = diag(A1n). The attention module is the backbone of modern transformers and large
language models, but explicitly forming the softmax matrix D−1A incurs Ω(n
2
) time, motivating numerous approximation schemes that reduce runtime to Oe(nd) via sparsity or low-rank
factorization. Sublinear Time Quantum Algorithm for Attention Approximation
Zhao Song∗ Jianfei Xue† Jiahao Zhang‡ Lichen Zhang§
Abstract
Given the query, key and value matrices Q, K, V ∈ R
n×d
, the attention module is defined as Att(Q, K, V ) = D−1AV where A = exp(QK⊤/
√
d) with exp(·) applied entrywise,
D = diag(A1n). The attention module is the backbone of modern transformers and large
language models, but explicitly forming the softmax matrix D−1A incurs Ω(n
2
) time, motivating numerous approximation schemes that reduce runtime to Oe(nd) via sparsity or low-rank
factorization. The attention module is the backbone of modern transformers and large
language models, but explicitly forming the softmax matrix D−1A incurs Ω(n
2
) time, motivating numerous approximation schemes that reduce runtime to Oe(nd) via sparsity or low-rank
factorization. We propose a quantum data structure that approximates any row of Att(Q, K, V ) using only
row queries to Q, K, V . We propose a quantum data structure that approximates any row of Att(Q, K, V ) using only
row queries to Q, K, V . Our algorithm preprocesses these matrices in Oe
ϵ
−1n
0. 5
λ
d + α
0. 5d
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/srank(V ), the
stable rank of V . 5d
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/srank(V ), the
stable rank of V . Each row query can be answered in Oe(s
2
λ + sλd) time. Each row query can be answered in Oe(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. 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . In this setting, we aim to preprocess Q, K, V
into a data structure such that, for any index i ∈ [n], the structure can return a vector rei ∈ R
d
that approximates the i-th row of Att(Q, K, V ). This model circumvents the Ω(nd) lower bound
by focusing on partial output. Given any
index i ∈ [n], the data structure returns an approximation to the i-th row of Att(Q, K, V ) in time
Oe(s
2
λ + sλd). To our knowledge, this is the first quantum algorithm to implement the row query model in
sublinear time. Given any
index i ∈ [n], the data structure returns an approximation to the i-th row of Att(Q, K, V ) in time
Oe(s
2
λ + sλd). To our knowledge, this is the first quantum algorithm to implement the row query model in
sublinear time. Prior works either require superlinear preprocessing time or impose structural
assumptions [GSYZ23]. Our approach avoids both: it makes no assumptions on Q, K, V , making
it broadly applicable in practice. Our approach avoids both: it makes no assumptions on Q, K, V , making
it broadly applicable in practice. Moreover, our construction is conceptually simple — it combines
quantum techniques such as Grover search [Gro96], Nystr¨om kernel approximation, and quantum
1We use Oe(·) to suppress polylogarithmic factors in n, d, sλ, and 1/ϵ. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. We pause to make some remarks on Theorem 3. The preprocessing time scales with n
0. The preprocessing time scales with n
0. 5
,
achieving a quadratic speedup with respect to n over any classical algorithm. There exists a
quantum data structure that preprocesses Q, K, V through only row queries to these matrices and
maintains matrices D, e A, e Ve implicitly such that, with probability at least 1 − 1/ poly(n),
∥De−1AeVe − Att(Q, K, V )∥F ≤ ϵ · (β · ∥D−1
∥) · (∥A∥F + λ
√
n) · ∥V ∥F . Moreover, the data structure has the specification
• It preprocesses Q, K, V in Oe(ϵ
−1n
0. To our knowledge, this is the first quantum algorithm to implement the row query model in
sublinear time. Prior works either require superlinear preprocessing time or impose structural
assumptions [GSYZ23]. This ensures α ≤ d and becomes smaller if the value
matrix V has close to d stable rank. We empirically verify that (1) the assumption on ∥D−1∥ is
easy to satisfy with wide range of choices for ϵ, (2) the Frobenius norm of A is only a small constant
factor of its spectral norm, (3) the row distortion α = O(1) and (4) the infinity norm of A is only
a small constant factor of its spectral norm, implying in practice, the additive λ
√
n term is likely
to be O(λ). This ensures α ≤ d and becomes smaller if the value
matrix V has close to d stable rank. We empirically verify that (1) the assumption on ∥D−1∥ is
easy to satisfy with wide range of choices for ϵ, (2) the Frobenius norm of A is only a small constant
factor of its spectral norm, (3) the row distortion α = O(1) and (4) the infinity norm of A is only
a small constant factor of its spectral norm, implying in practice, the additive λ
√
n term is likely
to be O(λ). This ensures α ≤ d and becomes smaller if the value
matrix V has close to d stable rank. We empirically verify that (1) the assumption on ∥D−1∥ is
easy to satisfy with wide range of choices for ϵ, (2) the Frobenius norm of A is only a small constant
factor of its spectral norm, (3) the row distortion α = O(1) and (4) the infinity norm of A is only
a small constant factor of its spectral norm, implying in practice, the additive λ
√
n term is likely
to be O(λ). 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 4 Main Result
Now that we have described how to approximate each of the matrices D, A, and V , we are in a
position to state our main result. We provide an overview of our algorithm below in Algorithm 3. The attention module is the backbone of modern transformers and large
language models, but explicitly forming the softmax matrix D−1A incurs Ω(n
2
) time, motivating numerous approximation schemes that reduce runtime to Oe(nd) via sparsity or low-rank
factorization. We propose a quantum data structure that approximates any row of Att(Q, K, V ) using only
row queries to Q, K, V . For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. The attention module is the backbone of modern transformers and large
language models, but explicitly forming the softmax matrix D−1A incurs Ω(n
2
) time, motivating numerous approximation schemes that reduce runtime to Oe(nd) via sparsity or low-rank
factorization. We propose a quantum data structure that approximates any row of Att(Q, K, V ) using only
row queries to Q, K, V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. For a matrix A, we use ∥A∥ to denote its spectral norm and ∥A∥∞ to denote its max row
ℓ1 norm, and ∥A∥F to denote its Frobenius norm. Throughout the paper, we will also exclusively
work with weighted sampling matrices, usually denoted by S ∈ R
n×s
for where s is the total number
of samples taken, let i(j) be the index of the i-th sample, then the i-th column of S is √
1
pj
ej , where
pj is the probability of choosing the index j. 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. Algorithm 2 Algorithm for estimating normalization factor. 1: data structure QRowNorm
2: begin members
3: s ∈ N
4: S ∈ (R
2
)
s
5: N ∈ R
s×s
6: µe ∈ R
s
7: end members
8:
9: procedure Preprocess(Q ∈ R
n×d
, K ∈ R
n×d
, λ ∈ (0, ∞), ϵ ∈ (0, 1))
10: s ← O(sλ log(sλn))
11: S ← QNystromKernel ¨ (Q ∪ K,(xi
, xj ) 7→ exp(⟨xi
, xj ⟩), 1/ poly(n), λ) ▷ Algorithm 1, S
is a list of sampled indices and weights
12: N ← (S
⊤ES)
†/2
13: Implement row oracle (U2)j,∗ as follows:
14: e(U2)j(k),∗ ← Sk · exp(⟨xj+n, xk⟩), ∀k ∈ S ▷ e(U2)j(k),∗ ∈ R
s
15: (U2)j,∗ ← Ne(U2)j(k),∗ ▷ S stores pairs of indices and weights, Sk is the weight
corresponding to index k, (U2)j,∗ ∈ R
s
16: Implement entry oracle for a vector v = 1n ∈ R
n
17: µe ← QMatVec(U2, v, ϵ) ▷ µe ∈ R
s
, Lemma 2. 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V . 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¨om
approximation of the exponential kernel, quantum multivariate mean estimation for computing
D, and quantum leverage score sampling for the multiplication with V .Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.
Improvements for AI systems
-
Sublinear Attention Row Query Data Structure: The proposed quantum data structure allows preprocessing of Q, K, and V in time Oe(epsilon-1n 0.5 poly(sλ, d, α)) while answering any row query in Oe(s 2λ + sλd) time. This enables approximating any row of Att(Q, K, V) using only row queries to Q, K, and V in sublinear time with respect to n.
-
Efficient Value Matrix Approximation: The system can approximate the value matrix V by sampling Oe(epsilon-1n 0.5α 0.5d) rows of V according to its leverage score distribution, achieving an approximate matrix multiplication guarantee in Frobenius norm using (ϵ, 1/poly(n))-AMM for any fixed matrix B.
-
Sublinear Time Attention Row Approximation: Given the data structure, for any index i in [n], it returns a vector rei which approximates the i-th row of Att(Q, K, V) in Oe(s 2λ + sλd) time. This circumvents the Omega(nd) lower bound for output size by focusing on partial output.
Abstract
Given the query, key and value matrices Q, K, V in R n times d, the attention module is defined as Att(Q, K, V)=D-1AV where A= (QK/sqrt d) with (times) applied entrywise, D= diag(A 1 n). The attention module is the backbone of modern transformers and large language models, but explicitly forming the softmax matrix D-1A incurs Ω(n 2) time, motivating numerous approximation schemes that reduce runtime to O(nd) via sparsity or low-rank factorization. We propose a quantum data structure that approximates any row of Att(Q, K, V) using only row queries to Q, K, V. Our algorithm preprocesses these matrices in (ε-1 n 0.5 (s λ cubed + s λ squared d + d) + ε-2 s λd) time, where ε is the target accuracy and s λ is the λ-statistical dimension of the exponential kernel defined by Q and K. Each row query can be answered in (s λ squared + s λd) time. If every row sum of A exceeds ε|A|+λ sqrt n, then with probability 1-1/poly(n) the answers have Frobenius-norm error O(β|D-1|(ε|A| F+λ sqrt n)|V| F). Here β=(1-(ε|A|+λ sqrt n)|D-1|)-1 at least 1 is close to 1 when every row sum is much larger than ε|A|+λ sqrt n. 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 sampling of the rows of V by their squared norms, with a median over independent samples, for the multiplication with V.
Sources
- Quantum speedups for linear programming via interior point methods
- RocketKV: Accelerating Long-Context LLM Inference via Two-Stage KV Cache Compression
- Generating Long Sequences with Sparse Transformers
- Visual Autoregressive Transformers Must Use $\Omega(n^2 d)$ Memory
- Time and Memory Trade-off of KV-Cache Compression in Tensor Transformer Decoding
- CriticalKV: Optimizing KV Cache Eviction from an Output Perturbation Perspective
- DeepSeek-V3 Technical Report
- HashEvict: A Pre-Attention KV Cache Eviction Strategy using Locality-Sensitive Hashing
- Gemini: A Family of Highly Capable Multimodal Models
- LLaMA: Open and Efficient Foundation Language Models
- Explaining the Attention Mechanism of End-to-End Speech Recognition Using Decision Trees
- SubGen: Token Generation in Sublinear Time and Memory
Related papers
- Quantum memory advantage for quantum process tomography
- The Quantum Kicked Rotor: A Paradigm of Quantum Chaos. Foundational aspects and new perspectives
- Hybrid Analog-Digital Simulation of the Abelian Higgs model
- Correlations and quantum circuits with dynamical causal order
- Molecular Attoscope: Pulse Shape Spectroscopy of Electronic Coherence
- TopoLS: Lattice Surgery Compilation via Topological Program Transformations