Approximate quantum Fourier transform with O(n log(n)) T gates

The ability to implement the Quantum Fourier Transform (QFT) efficiently on a quantum computer facilitates the advantages offered by a variety of fundamental quantum algorithms, such as those for integer factoring, computing discrete logarithm over Abelian groups, solving systems of linear equations, and phase estimation, to name a few. The standard fault-tolerant implementation of an n-qubit unitary QFT approximates the desired transformation by removing small-angle controlled rotations and synthesizing the remaining ones into Clifford+T gates, incurring the T-count complexity of O(nlog2(n))\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n\,{\mathrm{log}}^{2}\,(n))$$\end{document}. In this paper, we show how to obtain approximate QFT with the T-count of O(nlog(n))\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n\,{\mathrm{log}}\,(n))$$\end{document}. For brevity, the above figures omit the dependence on the approximation error ε, assuming the error is fixed. Our approach relies on quantum circuits with measurements and feedforward, and on reusing a special quantum state that induces the phase gradient transformation. We report asymptotic analysis as well as concrete circuits, demonstrating significant advantages in both theory and practice.


I. INTRODUCTION
Quantum Fourier Transform (QFT) is one of the most important operations in quantum computing. It can extract the periodicity encoded in the amplitudes of a quantum state, which is employed by an efficient algorithm for integer number factoring, widely known as Shor's algorithm [1]. Shor's integer factoring algorithm can be generalized (while still relying on the QFT) into a polynomial-time algorithm for the discrete logarithm problem over Abelian groups [1]. The importance of the above is witnessed through the threat such algorithms pose to modern public-key cryptosystems, such as the RSA or the ECC. Using the QFT as a subroutine, the eigenphase of a black-box unitary can be estimated up to an arbitrary precision [2], which may be used to estimate quantum amplitudes [3,4], simulate quantum chemistry/dynamics [5], find the ground state/energy of a Hamiltonian [6], compute Hessian to optimize molecular geometry [7], exponentiate unitaries [8], construct fractional powers of the QFT using constantly many copies of the controlled-QFT [8,9], extract features of the solution of linear systems [10], and more. QFT has also been used in quantum arithmetics [11,12] and quantum cryptography [13].
QFT can be implemented approximately by removing all rotation gates with angles smaller than a certain threshold value, resulting in the Approximate QFT (AQFT). In practice, it was shown that it suffices to apply AQFT with ∼ 5.3 · 10 4 controlled rotation gates to factor 2048-digit numbers (reflecting the de facto key size for today's standard [14]) with a high expected algorithmic accuracy ( 99.992%) [15]. AQFT has been studied extensively in the literature. The robustness of the quantum computer equipped with the AQFT was investigated in detail [16][17][18][19][20]. A study of the optimal level of the approximation of the AQFT in the presence of certain errors may be found in [21]. Implementation of the QFT and its approximate version over restricted architectures was addressed in [22,23]. An efficient approximate implementation of the AQFT that harnesses certain quantum hardware features was also investigated [24].
Quantum information is fragile, and it is generally accepted that the implementation of large quantum algorithms must rely on the fault-tolerant computations. Fault tolerance suppresses the errors at the cost of using multiple physical qubits to encode a single logical qubit. Fault-tolerant computations must furthermore rely on a quantum gate library consisting of those gates that are constructible fault tolerantly. A standard choice for such a computationally universal gate library is Clifford+t. Within known fault tolerance approaches, Clifford gates can generally be implemented with the relative ease, frequently transversally. On the other hand, a non-Clifford gate typically does not admit such an implementation; for instance, a t gate may be implemented fault tolerantly by distilling a certain quantum state and then teleporting it into the gate [25]. A t gate is indeed far more costly than any of the Clifford gates, and therefore efficient fault-tolerant circuits must minimize the t-count.
AQFT with n = 6 and b = 3. Note that each of the n−1 sets of controlled-z a gates are separated by the h gates.
To implement an n-qubit AQFT fault-tolerantly, the standard approach is to approximate the desired transformation by removing small-angle controlled rotations to bring down the gate count from O(n 2 ) [26, page 219] to O(n log(n)), and then replace the remaining O(n log(n)) controlled rotations with their Clifford+t implementations. The resulting circuit has the t-count of O(n log 2 (n)). Only in the special case of the semiclassical version of AQFT [27], where the AQFT transform is followed by the measurement, the t-count of O(n log(n)) implementation is known [28]. In contrast, in this paper, we focus on the fully coherent AQFT.
We develop a more efficient implementation with the t-count complexity of O(n log(n)) for the general case of fully coherent AQFT, improving over the standard construction by a factor of O(log(n)). Our results show that, in general and regardless of the amenability to the semiclassical approach, the AQFT may be implemented with O(n log(n)) t gates. This allows for the efficient implementation of the AQFT in any quantum algorithm, including those that use the AQFT as subroutines in the midst of the quantum computation; c.f. [5,7,10,12,13]. Since our implementation is more involved compared to the standard, we also make a separate effort to show that the constant factor and smallorder additive terms missing in the asymptotic analyses but otherwise present in our construction do not prevent it from achieving a significant practical advantage.

II. MAIN RESULT
We start with an n-qubit AQFT whose construction relies on O(nb) controlled-z a gates with where a ∈ {1/2, 1/4, ..., 1/2 b }, for b := ⌈log n⌉, and n Hadamard (h) gates (see Fig. 1 for an illustration with n = 6 and b = 3). Such a choice of b implies a very specific approximation error ε, whose analysis will be detailed in the next section. We unite the individual controlled rotations into n−1 sets separated by the h gates, such as illustrated in Fig. 1.
To implement a given controlled-z a rotation, we map its real-valued degree of freedom into that of the uncontrolled power of Pauli-z, such as shown in Fig. 2. This implementation was developed by combining Kitaev's trick [2] with Toffoli-measurement construction of Jones [29] with our own choice of the relative the phase Toffoli gate, and custom 3. A 4-qubit example of the layer of controlled-z a gates. The uncontrolled rotations are grouped together to induce the phase gradient operation [31,32].
circuit simplifications. Our circuit improves over the one reported in [30, Fig. 10] (note that the middle t gate can be replaced with the z a gate) by 4 t gates (8 → 4), 9 cnot gates (12 → 3), 1 h gate (4 → 3), and 1 Phase (p) gate (2 → 1) at the cost of introducing 1 measurement and 1 classically-controlled controlled-z operation. Note that the fault-tolerant cost of those operations introduced is significantly lower than that of a single t gate, as the construction of the t gate itself requires both a measurement and a classically controlled quantum correction [25]. We now group the uncontrolled z a rotations into one layer (time slice), as shown in Fig. 3. This layer applies the transformation that was coined the phase gradient operation in [31], the induction of which by the addition circuit was first reported in [32]. Such a transformation can be implemented by a b-bit adder at the cost of 4b + O(1) t gates [31], so long as one has access to a special quantum state |ψ b+1 := 1 The quantum state |ψ b+1 can be reused to induce phase gradient transformations in all n−1 sets of controlled-z a rotations. A schematic circuit diagram of our AQFT implementation is shown in Fig. 4.
To construct the special (b + 1)-qubit state |ψ b+1 , we first apply h gates to the quantum register |00...0 and then exercise the gates z, z −1/2 , ..., z −1/2 b . The latter step is accomplished via approximating each z a by RUS circuits [33]. Specifically, we approximate complex number e iπa by z * /z, where z ∈ Z[ω] with ω := e iπ/4 being the cyclotomic integer obtained from the PSLQ Algorithm [34]. We choose r ∈ Z[ √ 2] randomly and search the solution y ∈ Z[ω] of the norm equation |y| 2 = 2 L − |rz| 2 with L = ⌈log(|rz| 2 )⌉ [35], such that V := 1 √ 2 L rz y −y * rz * is a unitary. We exactly synthesize the two-qubit gate V 0 0 V † into a Clifford+t circuit [33,36]. Upon measuring the second qubit and obtaining 0, the gate z a is successfully implemented. Otherwise, a z error takes place and can be reversed at zero cost in the t gate count. The expected number of repetitions until success is 2 L /|rz| 2 . We resorted to using this more complex algorithm as opposed to the simpler one given by [35,36], as we already use quantum circuits with measurements and feedforward elsewhere in our constructions, and the RUS approach results in about 2.5-fold improvement [33] in the number of the t gates required to obtain the desired z a .

III. DETAILS OF THE IMPLEMENTATION
In the following, we slightly optimize the improved fault-tolerant AQFT implementation described above. We start by noting that the controlled-p gate may be implemented by two cnot gates and three t gates (including inverses) as shown in Fig. 5. We know from our construction above that each controlled-z a gate in the AQFT is implemented using 8 t gates. Therefore, instead of relying on inducing the gradient operation through the adder, we implement controlled-p gates directly, according to Fig. 5.
Next, we consider controlled-t gates. As per Fig. 1, we see that each controlled-t gate in the AQFT neighbors a controlled-p gate in the following layer of controlled-z a gates in the target qubit line. Since we implement controlled-p gates according to Fig. 5, we may obtain t-count savings via gate cancellation (tt † = Id) by rewriting the controlledt gate as the controlled-z 3/4 gate followed by the controlled-z −1/2 , where the controlled-z −1/2 gate is implemented according to Fig. 5, inducing t-count reduction by 2 on the 'target' of controlled-z −1/2 and controlled-t gates, and by another 2 for each layer of controlled-z a gates by cancellations on the 'control' line, and the controlled-z 3/4 gate is implemented directly as per the top panel of Fig. 2, which costs 5 t gates.
Altogether, the above implementation of the controlled-t and controlled-p gate pair requires 7(= 5+3+3−2−2) t |0 / ψ 4. A schematic diagram of the full implementation of the fault-tolerant AQFT. ψ denotes the preparation of the special state |ψ b+1 . Ui illustrate the operations that precede the ith adder, including h gates and the relative phase Toffoli gates used to map controlled-z a into uncontrolled z a rotations. U ′ i denotes the operations that follow the adder up to the in-circuit measurements. Adderi denotes the ith adder. U ′′ i are the classically controlled controlled-z gates, applied at the ith step. gates. This is in comparison to 16 t gates that would otherwise have been used by the implementation based on the adder. What remains to be investigated at this point is the modification that needs to be made to the gradient operation so as to induce a partial gradient operation, i.e., |k |ψ d+1,b+1 → e 2πik/2 b+1 |k |ψ d+1,b+1 , where k < 2 b−d , d ≤ b, and |ψ d+1,b+1 is the state |ψ b+1 without first d+1 qubits, to implement the remaining z a gates in a layer.
To obtain the partial gradient operation, we analyze how the gradient operation works. Firstly, we formally define the state |ψ d+1,b+1 := 1 e −2πij/2 b+1 |j . The application of (b−d)-bit addition (see [31]) to |k |ψ d+1,b+1 results in two cases: k+j < 2 b−d and k+j ≥ 2 b−d . In order for the partial gradient operation to work, we need k+j → k+j mod 2 b−d . This may be achieved by applying z 1/2 d gate to the most significant bit of the modular addition circuit. Since in our case d = 2, this amounts to applying a t gate for each gradient operation. This means that the overall result of our optimization detailed in this section is by about 8(n − 2) t gates.

IV. COMPARISONS TO PRIOR WORK
Our improved implementation of AQFT n with n > b > 2 requires the qubit count of n q = n + 3b − 4, the cnotgate count of 7.5n − 13 + n−1 denotes the count of the faulttolerant gate g in the RUS circuit synthesizing z −1/2 b ′ , and p b ′ denotes the success probability of the RUS circuit. As follows from our constructions, the t gate count can be fairly accurately approximated by the simple formula 8n(b−1). This may be compared to the previous state of the art that uses a variant of [30, Fig. 10] to implement the controlled-z a , which requires n q =n+1 qubits, the cnot gate count of 12 · n−1 l=0 min(b, l), and the t-count of 3(n − 1) + where C t (Gridsynth) is the t-count of the Gridsynth algorithm [35] synthesizing z 1/2 b ′ and C t = 1 when considering z ±1/4 gate. For a concrete comparison with the previous state of the art [30,37] at the gate-by-gate level, we implemented our improved fault-tolerant construction as described in Section III in software. We synthesized the RUS circuits for z a gates with a ∈ {−1/2 3 , −1/2 4 , ..., −1/2 13 }, motivating the choice of the smallest angle π/2 b by that sufficient to launch a quantum attack on the classically-infeasible instance of the integer factoring problem corresponding to cracking the RSA-2048. We also chose the overall fault-tolerance error that arises from the gate synthesis to be below 1.1 · 10 −4 for all sizes of the AQFT (n ≤ 4096 and b = 13) we considered. In particular, we chose the error 10 −5 per z a gate approximation for our improved construction. This amounts to the gate-synthesis error budget of ∼ 10 −5 /n per rotation for the previous state-of-the-art AQFT circuit. The improvement of the accuracy per z a gate is justified by the fact that our implementation of the AQFT requires the approximation of only O(b) rotations instead of O(nb) in the previous constructions.
Summary of the resulting quantum resource cost of our improved AQFT implementation is shown in Table I. We included a comparison of the gate costs of our implementation to those circuits known previously: first set relying on [30, Fig. 10] to implement controlled-z a gates in the AQFT and the second set resulting from an automated AQFT TABLE I. Quantum resource counts for implementing an n-qubit AQFT with b = 13. nq denotes the number of qubits required to execute the corresponding circuit. Columns cnot and t report the number of respective gates in the circuits. All circuits are available in [38].
Our AQFT implementation AQFT with controlled-z a per [30, Fig. 10 circuit optimization [37]. For both implementations, we used Gridsynth algorithm [35] to synthesize z a gates. Note that our implementation carries a significant practical advantage, saving quantum resource cost in the form of the t-count by a factor of as large as 12 (AQFT 4096 with b = 13). The slight increase in n q and the cnot-gate counts are completely offset by the savings in the t-count in the fault-tolerant regime.

V. COMPLEXITY ANALYSIS
The total t-count in our AQFT circuit is 8n . This is because each of the nb−b(b + 1)/2 = nb + O(b 2 ) controlled-z a gates consumes 4 t gates to be first mapped into an uncontrolled z a and another 4 t gates for the z a to be implemented as a part of the adder circuit, except for controlled-z 1/2 and controlled-z 1/4 gates; the two require 7 t gates to implement and 1 t gate to correct for the phase in the partial gradient operation. The construction of the special state |ψ d+1,b+1 requires implementation of O(b) z a rotations, and we approximate each rotation with O(log(b/ε)) t gates [33] to achieve accuracy ε/b per rotation.
There are two sources of approximation errors in our construction. Our circuit differs from the ideal AQFT circuit only in the preparation of the special state |ψ d+1,b+1 . Therefore, the spectral norm distance between our AQFT circuit and the ideal AQFT is O(b · ε/b) = O(ε). This ensures that, with 1 − O(ε 2 ) probability, regardless of how many operations to follow from the |ψ d+1,b+1 state preparation stage, our circuit implements the ideal AQFT. If we choose b = O(log(n/ε)), the spectral norm error of the ideal AQFT circuit will be O(ε). Due to the triangle inequality, the total error can be upper bounded by adding the error of the Clifford+t synthesis and the error of AQFT, which is still O(ε).
The above error analysis shows that for all effective purposes (specifically, when ε ≻ n/2 n ) we can drop the dependence on the approximation error ε, resulting in the claimed t-count of O(n log n).

VI. CONCLUSION
Before our contribution, the best known coherent approximation of the n-qubit QFT to an error ε by a quantum fault-tolerant Clifford+t circuit featured the t-count of O n log(n/ε) log( n log(n/ε) ε ) , with the term O(n log(n/ε)) originating from the standard AQFT construction using controlled rotations, and term O log( n log(n/ε) ε ) coming from the fault-tolerance overhead. In this paper we reported an improved approximation of the QFT by a quantum Clifford+t circuit with the t-count of O n log(n/ε) + log(n/ε) log( log(n/ε) ε ) . Our improvement is twofold: first, we reduce the dependence on n from O(n log 2 (n)) to O(n log(n)), and second, we moved the dependence on ε from the leading term into a lower order additive term. This means that the smaller the desired approximation error the more efficient our construction is compared to those known previously.
Our implementation includes constant factor improvements that are not captured by the asymptotics. We report significant practical advantages from applying our construction, as is evidenced by the numbers in Table I, showing the improvement by a factor of 10 to 12 in the t-count for values of n of the size expected in practical applications of quantum computers. This shows that our result carries both theoretical and practical value.