SlowGuess/NeurIPS_2023_OCR huggingface dataset:
So from the definition of the Algorithm 3, we know that our observation holds.
This observation, together with Proposition A.3, gives the following inequalities. For any  $u \in \Delta_m$ ,  $v \in \Delta_n$ , we have:
$$
\sum_ {t = 1} ^ {T} \left\langle u _ {t} - u, \mathbf {A} \eta_ {t} \right\rangle \leq \frac {\log m}{\lambda} + \lambda \sum_ {t = 1} ^ {T - 1} \left\| \mathbf {A} \left(\eta_ {t + 1} - \eta_ {t}\right) \right\| ^ {2} - \frac {1}{4 \lambda} \sum_ {t = 1} ^ {T - 1} \left\| u _ {t + 1} - u _ {t} \right\| ^ {2}, \tag {2}
$$
$$
\sum_ {t = 1} ^ {T} \left\langle v _ {t} - v, - \mathbf {A} ^ {\top} \zeta_ {t} \right\rangle \leq \frac {\log n}{\lambda} + \lambda \sum_ {t = 1} ^ {T - 1} \left\| \mathbf {A} ^ {\top} \left(\zeta_ {t + 1} - \zeta_ {t}\right) \right\| ^ {2} - \frac {1}{4 \lambda} \sum_ {t = 1} ^ {T - 1} \left\| v _ {t + 1} - v _ {t} \right\| ^ {2}. \tag {3}
$$
However, we find that the loss function is slightly different from what we expect.
Let us consider the difference  $q_{t} \coloneqq \mathbf{A}(v_{t} - \eta_{t})$  and  $p_{t} \coloneqq -\mathbf{A}^{\top}(u_{t} - \zeta_{t})$ , we have the decomposition of the regret:
$$
\sum_ {t = 1} ^ {T} \left\langle u _ {t} - u, \mathbf {A} v _ {t} \right\rangle = \sum_ {t = 1} ^ {T} \left\langle u _ {t} - u, \mathbf {A} \eta_ {t} \right\rangle + \sum_ {t = 1} ^ {T} \left\langle u _ {t} - u, q _ {t} \right\rangle .
$$
Notice that  $\mathbb{E}[q_t] = \mathbb{E}[p_t] = 0$ , we have:
Lemma B.2.
$$
\mathbb {E} \left[ \sum_ {t = 1} ^ {T} \langle u _ {t} - u, q _ {t} \rangle \right] = 0, \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \langle v _ {t} - v, p _ {t} \rangle \right] = 0
$$
Proof. By symmetry, we only prove the case for  $u$ . It suffices to prove that for every  $t$ ,  $\mathbb{E}[\langle u_t - u, q_t \rangle] = 0$ . Since  $u$  is fixed,  $\mathbb{E}[\langle u, q_t \rangle] = \langle u, \mathbb{E}[q_t] \rangle = 0$ .
Now consider  $\mathbb{E}\left[\langle u_t,q_t\rangle\right]$ , notice that given  $\eta_{1},\ldots ,\eta_{t - 1}$  then  $u_{t}$  is a constant. We have:
$$
\begin{array}{l} \mathbb {E} \left[ \langle u _ {t}, q _ {t} \rangle \right] = \mathbb {E} \left[ \mathbb {E} \left[ \langle u _ {t}, q _ {t} \rangle | \eta_ {1}, \eta_ {2}, \dots , \eta_ {t - 1} \right] \right] \\ = \mathbb {E} \left[ \langle u _ {t}, \mathbb {E} \left[ q _ {t} | \eta_ {1}, \eta_ {2}, \dots , \eta_ {t - 1} \right\rangle \rangle \right] \\ = \mathbb {E} [ \langle u _ {t}, 0 \rangle ] = 0. \\ \end{array}
$$
Now we are going to bound the term  $\sum_{t=1}^{T-1}\|\mathbf{A}(\eta_{t+1} - \eta_t)\|^2$ .
Lemma B.3.
$$
\sum_ {t = 1} ^ {T - 1} \left\| \mathbf {A} \left(\eta_ {t + 1} - \eta_ {t}\right) \right\| ^ {2} \leq 6 + 3 \sum_ {t = 1} ^ {T - 1} \left\| v _ {t + 1} - v _ {t} \right\| ^ {2}, \tag {4}
$$
$$
\sum_ {t = 1} ^ {T - 1} \left\| \mathbf {A} ^ {\top} \left(\zeta_ {t + 1} - \zeta_ {t}\right) \right\| ^ {2} \leq 6 + 3 \sum_ {t = 1} ^ {T - 1} \left\| u _ {t + 1} - u _ {t} \right\| ^ {2}. \tag {5}
$$
Proof. Recall that by rescaling we have  $\| \mathbf{A}\| \leq 1$ . Hence,
$$
\sum_ {t = 1} ^ {T - 1} \left\| \mathbf {A} \left(\eta_ {t + 1} - \eta_ {t}\right) \right\| ^ {2} \leq \sum_ {t = 1} ^ {T - 1} \left\| \eta_ {t + 1} - \eta_ {t} \right\| ^ {2}.
$$
Write  $\eta_{t + 1} - \eta_t = (\eta_{t + 1} - v_{t + 1}) + (v_{t + 1} - v_t) + (v_t - \eta_t)$ . Using the triangle inequality of the  $l_1$  norm and the Cauchy inequality  $(a + b + c)^2\leq 3(a^2 +b^2 +c^2)$ , we get
$$
\sum_ {t = 1} ^ {T - 1} \left\| \eta_ {t + 1} - \eta_ {t} \right\| ^ {2} \leq 6 \sum_ {t = 1} ^ {T} \left\| \eta_ {t} - v _ {t} \right\| ^ {2} + 3 \sum_ {t = 1} ^ {T - 1} \left\| v _ {t + 1} - v _ {t} \right\| ^ {2}. \tag {6}
$$
$$
\sum_ {t = 1} ^ {T - 1} \left\| \zeta_ {t + 1} - \zeta_ {t} \right\| ^ {2} \leq 6 \sum_ {t = 1} ^ {T} \left\| \zeta_ {t} - u _ {t} \right\| ^ {2} + 3 \sum_ {t = 1} ^ {T - 1} \left\| u _ {t + 1} - u _ {t} \right\| ^ {2}. \tag {7}
$$
Observing that in our algorithm we collect  $T$  independent and identically distributed samples and take their average, we have:
$$
\mathbb {E} \left[ \sum_ {t = 1} ^ {T} \| \zeta_ {t} - u _ {t} \| ^ {2} \right] \leq 1,
$$
$$
\mathbb {E} \left[ \sum_ {t = 1} ^ {T} \| \eta_ {t} - v _ {t} \| ^ {2} \right] \leq 1.
$$
Combining the result above, we just get the desired equation.
We also need the following lemma to guarantee that the sum of the regret is always non-negative.
Lemma B.4. The sum of the regrets of two players in Algorithm 1 is always non-negative. In other words:
$$
\max _ {u \in \Delta_ {m}} \max _ {v \in \Delta_ {n}} \left(\sum_ {t = 1} ^ {T} \langle u _ {t} - u, \mathbf {A} v _ {t} \rangle + \sum_ {t = 1} ^ {T} \langle v _ {t} - v, - \mathbf {A} ^ {\mathsf {T}} u _ {t} \rangle\right) \geq 0.
$$
$$
\begin{array}{l} \max  _ {u \in \Delta_ {m}} \max  _ {v \in \Delta_ {n}} \left(\sum_ {t = 1} ^ {T} \langle u _ {t} - u, \mathbf {A} v _ {t} \rangle + \sum_ {t = 1} ^ {T} \langle v _ {t} - v, - \mathbf {A} ^ {\top} u _ {t} \rangle\right) \\ = \max  _ {u \in \Delta_ {m}} \max  _ {v \in \Delta_ {n}} \left(\sum_ {t = 1} ^ {T} \langle - u, \mathbf {A} v _ {t} \rangle + \sum_ {t = 1} ^ {T} \langle v, \mathbf {A} ^ {\top} u _ {t} \rangle\right) \\ = \max  _ {v \in \Delta_ {n}} \sum_ {t = 1} ^ {T} \left\langle v, \mathbf {A} ^ {\top} u _ {t} \right\rangle - \min  _ {u \in \Delta_ {m}} \sum_ {t = 1} ^ {T} \left\langle u, \mathbf {A} v _ {t} \right\rangle \geq 0 \\ \end{array}
$$
The last step is because
$$
\max  _ {v \in \Delta_ {n}} \sum_ {t = 1} ^ {T} \left\langle v, \mathbf {A} ^ {\top} u _ {t} \right\rangle \geq \left\langle \mathbf {A} \sum_ {t = 1} ^ {T} v _ {t} / T, \sum_ {t = 1} ^ {T} u _ {t} \right\rangle ,
$$
$$
\min  _ {u \in \Delta_ {m}} \sum_ {t = 1} ^ {T} \left\langle u, \mathbf {A} v _ {t} \right\rangle \leq \left\langle \mathbf {A} \sum_ {t = 1} ^ {T} v _ {t}, \sum_ {t = 1} ^ {T} u _ {t} / T \right\rangle .
$$
Combining the result above, we finally have the following theorem.
Theorem B.5. Suppose that in our Algorithm 1, we choose the episode  $T = \widetilde{\Theta}(1 / \varepsilon)$ , and choose a constant learning rate  $\lambda$  that satisfies  $\lambda < \sqrt{3} / 6$ . Then with probability at least  $2/3$  the total regret of the algorithm is  $\widetilde{O}(1)$ . To be more clear, we have:
$$
T \left(\max  _ {v \in \Delta_ {n}} \langle v, \mathbf {A} ^ {\top} \hat {u} \rangle - \min  _ {u \in \Delta_ {m}} \langle u, \mathbf {A} \hat {v} \rangle\right) \leq 3 6 \lambda + \frac {3 \log (m n)}{\lambda},
$$
and so our algorithm returns an  $\varepsilon$ -approximate Nash equilibrium.
Proof. Adding the inequalities (2) and (3) together, we get
$$
\begin{array}{l} \sum_ {t = 1} ^ {T} \left\langle u _ {t} - u, \mathbf {A} \eta_ {t} \right\rangle + \sum_ {t = 1} ^ {T} \left\langle v _ {t} - v, - \mathbf {A} ^ {\intercal} \zeta_ {t} \right\rangle \leq \frac {\log m}{\lambda} + \frac {\log n}{\lambda} \\ + \lambda \sum_ {t = 1} ^ {T - 1} \| \mathbf {A} \left(\eta_ {t + 1} - \eta_ {t}\right) \| ^ {2} - \frac {1}{4 \lambda} \sum_ {t = 1} ^ {T - 1} \| v _ {t + 1} - v _ {t} \| ^ {2} \tag {8} \\ + \lambda \sum_ {t = 1} ^ {T - 1} \left\| \mathbf {A} ^ {\top} \left(\zeta_ {t + 1} - \zeta_ {t}\right) \right\| ^ {2} - \frac {1}{4 \lambda} \sum_ {t = 1} ^ {T - 1} \left\| u _ {t + 1} - u _ {t} \right\| ^ {2}. \\ \end{array}
$$
Taking expectation, and using the inequalities (6) we have
$$
\begin{array}{l} \mathbb {E} \left[ \lambda \sum_ {t = 1} ^ {T - 1} \| \mathbf {A} (\eta_ {t + 1} - \eta_ {t}) \| ^ {2} - \frac {1}{4 \lambda} \sum_ {t = 1} ^ {T - 1} \| v _ {t + 1} - v _ {t} \| ^ {2} \right] \\ \leq \left(3 \lambda - \frac {1}{4 \lambda}\right) \mathbb {E} \left[ \sum_ {t = 1} ^ {T - 1} \| v _ {t + 1} - v _ {t} \| ^ {2} \right] + 6 \lambda \cdot \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \| \eta_ {t} - v _ {t} \| ^ {2} \right] \\ \leq 6 \lambda . \\ \end{array}
$$
Similarly we can prove
$$
\mathbb {E} \left[ \lambda \sum_ {t = 1} ^ {T - 1} \| \mathbf {A} ^ {\top} (\zeta_ {t + 1} - \zeta_ {t}) \| ^ {2} - \frac {1}{4 \lambda} \sum_ {t = 1} ^ {T - 1} \| u _ {t + 1} - u _ {t} \| ^ {2} \right] \leq 6 \lambda .
$$
So, taking expectations of Equation (8), and using the above inequalities and the Lemma B.2, we get
$$
\mathbb {E} \left[ \max  _ {u \in \Delta_ {m}} \sum_ {t = 1} ^ {T} \langle u _ {t} - u, \mathbf {A} v _ {t} \rangle + \max  _ {v \in \Delta_ {n}} \sum_ {t = 1} ^ {T} \langle v _ {t} - v, - \mathbf {A} ^ {\top} u _ {t} \rangle \right] \leq 1 2 \lambda + \frac {\log (m n)}{\lambda}. \tag {9}
$$
Using the fact that
$$
\mathbb {E} [ \hat {u} ] \cdot T = \sum_ {t = 1} ^ {T} \mathbb {E} [ u _ {t} ],
$$
$$
\mathbb {E} [ \hat {v} ] \cdot T = \sum_ {t = 1} ^ {T} \mathbb {E} [ v _ {t} ],
$$
$$
\mathbb {E} \left[ \max  _ {v \in \Delta_ {n}} \langle v, \mathbf {A} ^ {\top} \hat {u} \rangle - \min  _ {u \in \Delta_ {m}} \langle u, \mathbf {A} \hat {v} \rangle \right] \cdot T \leq 1 2 \lambda + \frac {\log (m n)}{\lambda}. \tag {10}
$$
By Lemma B.4, we know that the regret is always non-negative. So applying Markov's inequality, we know with probability at least  $2/3$ , the following inequality holds:
$$
\max  _ {v \in \Delta_ {n}} \left\langle v, \mathbf {A} ^ {\top} \hat {u} \right\rangle - \min  _ {u \in \Delta_ {m}} \left\langle u, \mathbf {A} \hat {v} \right\rangle \leq \frac {1}{T} \left(3 6 \lambda + \frac {3 \log (m n)}{\lambda}\right).
$$
B.2 Samplers with Errors
Theorem B.6 (Restatement of Theorem 3.2). Suppose that in our Algorithm 1, we choose the episode  $T = \widetilde{O}(1 / \varepsilon)$ , and choose a constant learning rate  $\lambda$  that satisfies  $0 < \lambda < \sqrt{3} / 6$ . The quantum implementation of the oracle in the algorithm will return  $T$  independent and identically distributed samples from a distribution that is  $\epsilon_{\mathrm{G}}$ -close to the desired distribution in total variational distance in quantum time  $T_{\mathrm{G}}^{Q}$ .
Then with probability at least  $2/3$  the total regret of the algorithm is  $\widetilde{O}(1 + \epsilon_{\mathrm{G}} / \varepsilon)$  and the algorithm returns an  $\widetilde{O}(\varepsilon + \epsilon_{\mathrm{G}})$ -approximate Nash equilibrium in quantum time  $\widetilde{O}(T_{\mathrm{G}}^{\mathrm{Q}} / \varepsilon)$ .
Proof. We will follow similar steps of proof for Theorem B.5. Since the sampling is not from the ideal distribution, we must bound the terms where  $\eta_t$  and  $\zeta_t$  take place.
Notice that in this case, we have
$$
\left\| A \left(v _ {t} - \mathbb {E} [ \eta_ {t} ]\right) \right\| \leq \left\| v _ {t} - \mathbb {E} [ \eta_ {t} ] \right\| \leq \epsilon_ {\mathrm {G}}.
$$
So for the term  $q_{t}$  in Lemma B.2 we now have the bound:
$$
\begin{array}{l} \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \langle u _ {t} - u, A (v _ {t} - \eta_ {t}) \rangle \right] \\ = \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \langle u _ {t} - u, A (v _ {t} - \mathbb {E} [ \eta_ {t} ]) \rangle \right] + \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \langle u _ {t} - u, A (\mathbb {E} [ \eta_ {t} ] - \eta_ {t}) \rangle \right] \\ = \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \langle u _ {t} - u, A (v _ {t} - \mathbb {E} [ \eta_ {t} ]) \rangle \right] \leq 2 T \epsilon_ {\mathrm {G}}, \\ \end{array}
$$
where the last step is by Hölder's inequality.
Then for the other term, we have
$$
\begin{array}{l} \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \| \eta_ {t} - v _ {t} \| ^ {2} \right] \leq 2 \cdot \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \| \eta_ {t} - \mathbb {E} [ \eta_ {t} ] \| ^ {2} \right] + 2 \cdot \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \| v _ {t} - \mathbb {E} [ \eta_ {t} ] \| ^ {2} \right] \\ \leq 2 + 2 T \epsilon_ {\mathrm {G}} ^ {2}. \\ \end{array}
$$
So following the similar steps of proof for Theorem B.5, and using the above bounds, we can get
$$
\begin{array}{l} \mathbb {E} \left[ \max  _ {u \in \Delta_ {m}} \sum_ {t = 1} ^ {T} \langle u _ {t} - u, \mathbf {A} v _ {t} \rangle + \max  _ {v \in \Delta_ {n}} \sum_ {t = 1} ^ {T} \langle v _ {t} - v, - \mathbf {A} ^ {\top} u _ {t} \rangle \right] \\ \leq 2 4 \lambda + 2 4 \lambda T \epsilon_ {\mathrm {G}} ^ {2} + \frac {\log (m n)}{\lambda} + 4 T \epsilon_ {\mathrm {G}}. \\ \end{array}
$$
Again using linearity of expectation and Markov's inequality, we conclude that with probability at least 2/3
$$
T \left(\max  _ {v \in \Delta_ {n}} \langle v, \mathbf {A} ^ {\top} \hat {u} \rangle - \min  _ {u \in \Delta_ {m}} \langle u, \mathbf {A} \hat {v} \rangle\right) \leq 7 2 \lambda + \frac {3 \log (m n)}{\lambda} + 7 2 T \lambda \epsilon_ {\mathrm {G}} ^ {2} + 1 2 T \epsilon_ {\mathrm {G}}.
$$
C Consistent Quantum Amplitude Estimation
Theorem C.1 (Consistent phase estimation, [2, 47]). Suppose  $U$  is a unitary operator. For every positive real  $\epsilon, \delta$ , there is a quantum algorithm ( $a$  unitary quantum circuit)  $\mathcal{A}$  such that, on input  $O\left(\log \left(\epsilon^{-1}\right)\right)$ -bit random string  $s$ , it holds that
- For every eigenvector  $|\psi_{\theta}\rangle$  of  $U$  (where  $U|\psi_{\theta}\rangle = \exp (\mathrm{i}\theta)|\psi_{\theta}\rangle$ ), with probability  $\geq 1 - \epsilon$ :
$$
\langle \psi_ {\theta} | \langle f (s, \theta) | \mathcal {A} | \psi_ {\theta} \rangle | 0 \rangle \geq 1 - \epsilon ;
$$
-  $f(s, \theta)$  is a function of  $s$  and  $\theta$  such that  $|f(s, \theta) - \theta| < \delta$ ,
with time complexity  $\widetilde{O}(\delta^{-1}) \cdot \mathrm{poly}(\epsilon^{-1})$ .
Theorem C.2 (Consistent quantum amplitude estimation). Suppose  $U$  is a unitary operator such that
$$
U | 0 \rangle_ {A} | 0 \rangle_ {B} = \sqrt {p} | 0 \rangle_ {A} | \phi_ {0} \rangle_ {B} + \sqrt {1 - p} | 1 \rangle_ {A} | \phi_ {1} \rangle_ {B}.
$$
where  $p \in [0,1]$  and  $|\phi_0\rangle$  and  $|\phi_1\rangle$  are normalized pure quantum states. Then for every positive reals  $\epsilon, \delta$ , there is a quantum algorithm that, on input  $O\big(\log (\epsilon^{-1})\big)$ -bit random string  $s$ , outputs  $f(s,p) \in [0,1]$  such that
$$
\mathbf {P r} \left[ | f (s, p) - p | \leq \delta \right] \geq 1 - \epsilon ,
$$
with time complexity  $\widetilde{O} (\delta^{-1})\cdot \mathrm{poly}(\epsilon^{-1})$
Proof. Suppose  $U$  is a unitary operator such that
$$
Q = - U (I - 2 | 0 \rangle_ {A} \langle 0 | \otimes | 0 \rangle_ {B} \langle 0 |) U ^ {\dagger} (I - 2 | 0 \rangle_ {A} \langle 0 | \otimes I _ {B}).
$$
Similar to the analysis in Brassard et al. [9], we have
$$
U | 0 \rangle_ {A} | 0 \rangle_ {B} = \frac {- \mathbf {i}}{\sqrt {2}} \bigl (\exp \bigl (\mathbf {i} \theta_ {p} \bigr) | \psi_ {+} \rangle_ {A B} - \exp \bigl (- \mathbf {i} \theta_ {p} \bigr) | \psi_ {-} \rangle_ {A B} \bigr),
$$
where  $\sin^2 (\theta_p) = p$ $(0\leq \theta_{p} <   \pi /2)$  , and
$$
| \psi_ {\pm} \rangle_ {A B} = \frac {1}{\sqrt {2}} (| 0 \rangle_ {A} | \phi_ {0} \rangle_ {B} \pm \mathrm {i} | 1 \rangle_ {A} | \phi_ {1} \rangle_ {B}).
$$
Note that  $|\psi_{\pm}\rangle_{AB}$  are eigenvectors of  $Q$ , i.e.,  $Q|\psi_{\pm}\rangle_{AB} = \exp (\pm \mathrm{i}2\theta_p)|\psi_{\pm}\rangle_{AB}$ .
Now applying the algorithm  $\mathcal{A}$  of consistent phase estimation of  $Q$  by Theorem C.1 on state  $U|0\rangle_A|0\rangle_B\otimes |0\rangle_C$  (with an  $O\bigl (\log \bigl (\epsilon^{-1}\bigr)\bigr)$ -bit random string  $s$ ), we obtain
$$
\mathcal {A} (U | 0 \rangle_ {A} | 0 \rangle_ {B} \otimes | 0 \rangle_ {C}) = \frac {- \mathrm {i}}{\sqrt {2}} \Big (\exp (\mathrm {i} \theta_ {p}) \mathcal {A} (| \psi_ {+} \rangle_ {A B} | 0 \rangle_ {C}) - \exp (- \mathrm {i} \theta_ {p}) \mathcal {A} (| \psi_ {-} \rangle_ {A B} | 0 \rangle_ {C}) \Big).
$$
Since each of  $|\psi_{\pm}\rangle_{AB}$  is an eigenvector of  $Q$ , it holds that, with probability  $\geq 1 - \epsilon$
$$
\langle \psi_ {\pm} | _ {A B} \langle f (s, \pm 2 \theta_ {p}) | _ {C} \mathcal {A} (| \psi_ {\pm} \rangle_ {A B} | 0 \rangle_ {C}) \geq 1 - \epsilon .
$$
which implies that  $\mathcal{A}(U|0\rangle_A|0\rangle_B\otimes |0\rangle_C)$  is  $O\big(\sqrt{\epsilon}\big)$ -close to
$$
\frac {- \mathrm {i}}{\sqrt {2}} \left(\exp (\mathrm {i} \theta_ {p}) | \psi_ {+} \rangle_ {A B} | f (s, 2 \theta_ {p}) \rangle_ {C} - \exp (- \mathrm {i} \theta_ {p}) | \psi_ {-} \rangle_ {A B} | f (s, - 2 \theta_ {p}) \rangle_ {C}\right)
$$
in trace distance, where  $\left|f(s,\pm 2\theta_p)\mp 2\theta_p\right| < \delta$ . Measuring register  $C$ , we denote the outcome as  $\gamma$  which will be either  $f(s,2\theta_{p})$  or  $f(s, - 2\theta_{p})$ . Finally, output  $\sin^2 (\gamma /2)$  as the estimate of  $p$  (which is consistent). Since  $\sin^2 (\cdot)$  is even and 2-Lipschitz, the additive error is bounded by
$$
\left| \sin^ {2} \left(\frac {\gamma}{2}\right) - p \right| \leq 2 \left| \left| \frac {\gamma}{2} \right| - \left| \theta_ {p} \right| \right| <   \delta .
$$
Note that  $\mathcal{A}$  makes  $\widetilde{O}(\delta^{-1}) \cdot \mathrm{poly}(\epsilon^{-1})$  queries to  $Q$ , thus our consistent amplitude estimation has quantum time complexity  $\widetilde{O}(\delta^{-1}) \cdot \mathrm{poly}(\epsilon^{-1})$ .
Theorem C.3 (Error-Reduced Consistent quantum amplitude estimation). Suppose  $U$  is a unitary operator such that
where  $p \in [0,1]$  and  $|\phi_0\rangle$  and  $|\phi_1\rangle$  are normalized pure quantum states. Then for every positive integers  $r$  and positive real  $\delta$ , there is a quantum algorithm that, on input  $O(r)$ -bit random string  $s$ , outputs  $f^{*}(s,p) \in [0,1]$  such that
$$
\Pr \left[ | f ^ {*} (s, p) - p | \leq \delta \right] \geq 1 - O (\exp (- r)),
$$
with time complexity  $\widetilde{O}(\delta^{-1}) \cdot \mathrm{poly}(r)$ .
Proof. Consider that we divide the input random string  $s$  into  $r$  strings  $s_1, s_2, \ldots, s_r$  of length  $O(1)$ . For each  $i \in [r]$ , we use Theorem C.2 with input string  $s_i$  and parameter  $\epsilon = 1/10$ . So we get, for each  $i \in [r]$ ,
$$
\Pr \left[ | f (s _ {i}, p) - p | \leq \delta \right] \geq \frac {9}{1 0}.
$$
Now we set  $f^{*}(s,p)$  to be the median of the estimations  $f(s_{i},p)$  for  $i\in [r]$ . We claim it satisfies the desired property. To show that, we define random variables  $X_{i}$  for  $i\in [r]$  as follows:
$$
X _ {i} = \left\{ \begin{array}{l l} 1, & \text {i f} | f (s _ {i}, p) - p | \leq \delta , \\ 0, & \text {o t h e r w i s e .} \end{array} \right.
$$
Noticing  $\mathbb{E}\left[\sum_{i = 1}^{r}X_{i}\right]\geq 9r / 10$ , and by Chernoff bound, we have:
$$
\Pr \left[ \sum_ {i = 1} ^ {r} X _ {i} <   \frac {r}{2} \right] \leq \exp \left(- \frac {8 r}{4 5}\right).
$$
Thus with probability at least  $1 - \exp (-8r / 45)$ , we know that at least half of the estimations fall into the interval  $[p - \delta, p + \delta]$ , and then  $f^{*}(s,p)$  returns a correct answer.
D Details and Proofs of Fast Quantum Multi-Gibbs Sampling
We present the detailed version of the fast quantum multi-Gibss sampling. Here, we use the shorthand  $\mathcal{O}_p^{\mathrm{Gibbs}} = \mathcal{O}_p^{\mathrm{Gibbs}}(1,0)$ , and it also means the distribution of the sample.
We first define the notion of amplitude-encoding (a unitary operator that encodes a vector in its amplitudes).
Definition D.1 (Amplitude-encoding). A unitary operator  $V$  is said to be a  $\beta$ -amplitude-encoding of a vector  $u \in \mathbb{R}^n$  with non-negative entries, if
$$
\langle 0 | _ {C} V | 0 \rangle_ {C} | i \rangle_ {A} | 0 \rangle_ {B} = \sqrt {\frac {u _ {i}}{\beta}} | i \rangle_ {A} | \psi_ {i} \rangle_ {B}
$$
for all  $i\in [n]$
Then, as shown in Algorithm 4, we can construct a quantum multi-Gibbs sampler for a vector  $u$  if an amplitude-encoding of the vector  $u$  is given. To complete the proof of Theorem 4.2, we only have to construct an amplitude-encoding of  $\mathbf{A}z$  (see Appendix D.2 for details).
Algorithm 4 Quantum Multi-Gibbs Sampling implementing  $\mathcal{O}_u^{\mathrm{Gibbs}}(k,\epsilon_{\mathrm{G}})$
Input: Sample count  $k$ , a  $\beta$ -amplitude-encoding  $V$  of vector  $u \in \mathbb{R}^n$ , polynomial  $P_{2\beta} \in \mathbb{R}[x]$  that satisfies Lemma 4.1 with parameter  $\epsilon_P = k\epsilon_G^2 / 300n$ .
1: Obtain  $\mathcal{O}_{\tilde{u}}\colon |i\rangle |0\rangle \mapsto |i\rangle |\tilde{u}_i\rangle$  using  $\widetilde{O} (\beta)$  queries to  $V$ , where  $u_{i}\leq \tilde{u}_{i}\leq u_{i} + 1$ , by consistent quantum amplitude estimation (Theorem C.3).
2: Find the  $k$  largest  $\tilde{u}_i$ 's by quantum  $k$ -maximum finding (Theorem D.3) and let  $S$  be the set of their indexes. This can be done with  $\widetilde{O}(\sqrt{n k})$  queries to  $\mathcal{O}_{\tilde{u}}$ .
3: Compute  $\tilde{u}^{*} = \min_{i\in S}\tilde{u}_{i}$ , and  $W = (n - k)\exp (\tilde{u}^{*}) + \sum_{i\in S}\exp (\tilde{u}_i)$ .
4: for  $\ell = 1,\dots ,k$  do
5: Prepare the quantum state
$$
\left| u _ {\text {g u e s s}} \right\rangle = \sum_ {i \in S} \sqrt {\frac {\exp \left(\tilde {u} _ {i}\right)}{W}} | i \rangle + \sum_ {i \notin S} \sqrt {\frac {\exp \left(\tilde {u} ^ {*}\right)}{W}} | i \rangle .
$$
6: Obtain  $U_{u} = (V_{CAB}^{\dagger}\otimes I_{D})(V_{DAB}\otimes I_{C})$  being a block-encoding of  $\mathrm{diag}(u) / \beta$ . Similarly, obtain  $U_{\tilde{u}}^{\max}$  being a block-encoding of  $\mathrm{diag}(\max \{\tilde{u},\tilde{u}^{*}\}) / 2\beta$ .
7: Obtain  $U^{-}$  being a block-encoding of  $\mathrm{diag}(u - \max\{\tilde{u}, \tilde{u}^{*}\}) / 4\beta$  by the LCU (Linear-Combination-of-Unitaries) technique (Theorem D.6), using  $O(1)$  queries to  $U_{u}$  and  $U_{\tilde{u}}^{\max}$ .
8: Obtain  $U^{\mathrm{exp}}$  being a block-encoding of  $P_{2\beta}(\mathrm{diag}(u - \max \{\tilde{u},\tilde{u}^{*}\}) / 4\beta)$  by the QSVT technique (Theorem D.7), using  $O(\beta \log (\epsilon_P^{-1}))$  queries to  $U^{-}$ .
9: Post-select  $|\tilde{u}_{\mathrm{post}} \rangle = \langle 0|^{\otimes a}U^{\mathrm{exp}}|u_{\mathrm{guess}} \rangle |0\rangle^{\otimes a}$  by quantum amplitude amplification (Theorem D.8), and obtain  $|\tilde{u}_{\mathrm{Gibbs}} \rangle = |\tilde{u}_{\mathrm{post}} \rangle / \| |\tilde{u}_{\mathrm{post}} \rangle \|$ . (Suppose  $U^{\mathrm{exp}}$  has  $a$  ancilla qubits.)
10: Measure  $\left| \tilde{u}_{\mathrm{Gibbs}} \right\rangle$  in the computational basis and let  $i_{\ell} \in [n]$  be the outcome.
11: end for
12: Return  $i_1, i_2, \ldots, i_k$ .
D.1 Useful Theorems
Theorem D.2 (Quantum state preparation, [23, 32]). There is a data structure implemented on QRAM maintaining an array  $a_1, a_2, \ldots, a_\ell$  of positive numbers that supports the following operations.
- Initialization: For any value  $c$ , set  $a_i \gets c$  for all  $i \in [\ell]$ .
- Assignment: For any index  $i$  and value  $c$ , set  $a_i \gets c$ .
- State Preparation: Prepare a quantum state
$$
\left| a \right\rangle = \sum_ {i \in [ \ell ]} \sqrt {\frac {a _ {i}}{\| a \| _ {1}}} \left| i \right\rangle .
$$
Each operation costs polylog(  $\ell$  ) time.
Theorem D.3 (Quantum  $k$ -maximum finding, Theorem 6 of Durr et al. [19]). Given  $k \in [n]$  and quantum oracle  $\mathcal{O}_u$  for an array  $u_1, u_2, \ldots, u_n$ , i.e., for every  $i \in [n]$ ,
$$
\mathcal {O} _ {u} | i \rangle | 0 \rangle = | i \rangle | u _ {i} \rangle ,
$$
there is a quantum algorithm that, with probability  $\geq 0.99$ , finds a set  $S \subseteq [n]$  of cardinality  $|S| = k$  such that  $u_i \geq u_j$  for every  $i \in S$  and  $j \notin S$ , using  $O\left(\sqrt{nk}\right)$  queries to  $\mathcal{O}_u$ .
We now recall the definition of block-encoding, a crucial concept in quantum singular value transformation [20], which is used in line 9 to 12 in Algorithm 4.
Definition D.4 (Block-encoding). Suppose  $A$  is a linear operator on  $b$  qubits,  $\alpha, \epsilon \geq 0$  and  $a$  is a positive integer. A  $(b + a)$ -qubit unitary operator  $U$  is said to be an  $(\alpha, \epsilon)$ -block-encoding of  $A$ , if
$$
\left\| \alpha \langle 0 | ^ {\otimes a} U | 0 \rangle^ {\otimes a} - A \right\| _ {\mathrm {o p}} \leq \epsilon .
$$
Definition D.5 (State Preparation Pair, Definition 28 of Gilyén et al. [20]). Let  $y \in \mathbb{R}^n$  be a vector, specially in this context the number of coordinates starts from 0. Suppose  $\| y \|_1 \leq \beta$ . Let  $\epsilon$  be a positive real. We call a pair of unitaries  $(P_L, P_R)$  acting on  $b$  qubits a  $(\beta, \epsilon)$ -state-preparation pair for  $y$  if