The Grover quantum search algorithm is a hallmark application of a quantum computer with a well-known speedup over classical searches of an unsorted database. Here, we report results for a complete three-qubit Grover search algorithm using the scalable quantum computing technology of trapped atomic ions, with better-than-classical performance. Two methods of state marking are used for the oracles: a phase-flip method employed by other experimental demonstrations, and a Boolean method requiring an ancilla qubit that is directly equivalent to the state marking scheme required to perform a classical search. We also report the deterministic implementation of a Toffoli-4 gate, which is used along with Toffoli-3 gates to construct the algorithms; these gates have process fidelities of 70.5% and 89.6%, respectively.
Searching large databases is an important problem with broad applications. The Grover search algorithm1,2 provides a powerful method for quantum computers to perform searches with a quadratic speedup in the number of required database queries over classical computers. It is an optimal search algorithm for a quantum computer3, and has further applications as a subroutine for other quantum algorithms4,5. Searches with two qubits have been demonstrated on a variety of platforms6,7,8,9,10,11,12 and proposed for others13, but larger search spaces have only been demonstrated on a non-scalable NMR system14.
The Grover search algorithm has four stages: initialization, oracle, amplification, and measurement, as shown in Fig. 1a. The initialization stage creates an equal superposition of all states. The oracle stage marks the solution(s) by flipping the sign of that state’s amplitude. The amplification stage performs a reflection about the mean, thus increasing the amplitude of the marked state. Finally, the algorithm output is measured. For a search database of size N, the single-shot probability of measuring the correct answer is maximized to near-unity by repeating the oracle and amplification stages O((N)1/2) times1,2. By comparison, a classical search algorithm will get the correct answer after an average of N/2 queries of the oracle. For large databases, this quadratic speedup represents a significant advantage for quantum computers.
Here, we implement the Grover search algorithm using a scalable trapped atomic ion system15 on n = 3 qubits, which corresponds to a search database of size N = 2n = 8. The algorithm is executed for all eight possible single-result oracles and all 28 possible two-result oracles. All searches are performed with a single iteration. For a single-solution algorithm (t = 1), the algorithmic probability of measuring the correct state after one iteration is 2, compared to for the optimal classical search strategy, which consists of a single query followed by a random guess in the event the query failed. In the two-solution case (t = 2), where two states are marked as correct answers during the oracle stage and both states’ amplitudes are amplified in the algorithm’s amplification stage, the probability of measuring one of the two correct answers is 100% for the quantum case, as compared to for the classical case. The algorithm is performed with both a phase oracle, which has been previously demonstrated on other experimental systems, and a Boolean oracle, which requires more resources but is directly comparable to a classical search. All quantum solutions are shown to outperform their classical counterparts.
We examine two alternative methods of encoding the marked state within the oracle. While both methods are mathematically equivalent16, only one is directly comparable to a classical search. The Boolean method requires the use of an ancilla qubit initialized to |1〉, as shown in Fig. 1b. The oracle is determined by constructing a circuit out of NOT and C k(NOT) (k ≤ n) gates such that, were the oracle circuit to be implemented classically, the ancilla bit would flip if and only if the input to the circuit is one of the marked states. By using classically available gates, this oracle formulation is directly equivalent to the classical search algorithm, and therefore can most convincingly demonstrate the quantum algorithm’s superiority. On a quantum computer, because the initialization sets up an equal superposition of all possible input states, the C n(NOT) gate targeted on the ancilla provides a phase kickback that flips the phase of the marked state(s) in the data qubits. An example oracle is shown in Fig. 1c to illustrate this. The phase method of oracle implementation does not require the ancilla qubit. Instead, the oracle is implemented with a circuit consisting of Z and C k(Z) (k ≤ n − 1) gates that directly flip the phase(s) of the state(s) to be marked (Fig. 1d, e).
The experiments presented here were performed on a programmable quantum computer consisting of a linear chain of five trapped 171Yb+ ions17,18 that are laser cooled near the motional ground state. Qubits are comprised of the first-order magnetic-field-insensitive pair of clock states in the hyperfine-split 2 S 1/2 manifold, with |0〉 ≡ |F = 0; m F = 0〉 and |1〉 ≡ |F = 1; m F = 0〉 having a 12.642821 GHz frequency difference. Optical pumping initializes all qubits to the |0〉 state. We execute modular one- and two-qubit gates through Raman transitions driven by a beat note between counter-propagating beams from a pulsed laser19, which couples the qubit transition to the collective transverse modes of motion of the ion chain. The qubit–motion interaction provides entangling two-qubit Ising gates17,20,21. A pulse segmentation scheme modulates the amplitude and phase of the Raman laser to drive high-fidelity entangling gates using all modes of motion22,23. Individual optical addressing of each ion with one Raman beam provides arbitrary single-qubit rotations (R(θ,ϕ)) as well as gates between arbitrary pairs of ions (XX(χ)) (see Methods for details). State-dependent fluorescence detection with each ion mapped to a separate photomultiplier tube (PMT) channel allows for individual ion readout15.
Successful demonstration of the Grover search algorithm first requires the implementation of its subroutines. Controlled-NOT (CNOT) gates constructed from an gate and single-qubit rotations (Methods) have been demonstrated on this system previously15. Here, we show results for a controlled-controlled-NOT (C 2(NOT)), or Toffoli-3, gate, with a process fidelity of 89.6(2)% (Fig. 2a). Toffoli-3 gates have been previously performed in NMR systems24 and ion traps25, including this system26. We employed a limited tomography procedure to verify that the Toffoli-3 gate performed had no spurious phases on the outputs (Supplementary Note 1; Supplementary Fig. 1).
Our Toffoli-3 gate is constructed from five two-qubit gates (three and two gates) in a manner similar to the Toffoli gate demonstrated in ref. 14. Any doubly-controlled unitary C 2(U) operation can be performed with five two-qubit interactions (two CNOTs, two C(V)s, and one C(V †)) if a controlled-V operation is available such that V 2 = U 27. Since , we can add single-qubit rotations to construct a Toffoli-3 gate with minimal use of two-qubit gates, as shown in Fig. 2b (see Methods for a detailed circuit diagram). This compares favorably to the six two-qubit gates that would be necessary if only CNOT (or equivalently, ) gates were available. These constructions also provide for the implementation of C(Z) and C 2(Z) gates, which can be constructed by adding a few single-qubit rotations to a CNOT or Toffoli-3 gate, respectively (see Methods for circuits). For all circuits, the single-qubit rotations are further optimized to minimize total rotation time28.
We use a related strategy to construct a Toffoli-4 gate, and report an average process fidelity of 70.5(3)% (Fig. 2c). Using the methods described in ref. 29, we construct a circuit with three control qubits, one target, and one ancilla qubit, requiring 11 two-qubit gates (see Methods for circuit). By again using both and gates, we are able to save one two-qubit gate relative to a construction limited to CNOT gates29.
Figures 3 and 4 show the results, respectively, of single- and two-solution Grover search algorithms, each using both the Boolean and phase marking methods (see Methods for optimized circuits performed.). All possible oracles are tested to demonstrate a complete Grover search (Tables 1, 2). Two figures of merit are provided with the data for each oracle. The algorithm success probability (ASP) is the probability of measuring the marked state as the experimental outcome. For the two-solution algorithm, the ASP is calculated by summing the probabilities of measuring each of the two marked states. The squared statistical overlap (SSO) measures the statistical overlap between the measured and expected populations for all states: , where e j is the expected population and m j is the measured population for each state j 30. Additionally, all of the data shown in this paper is corrected to account for state preparation and measurement (SPAM) errors (see figure captions for values), similar to the method proposed in ref. 31 while also accounting for multi-ion crosstalk15. All uncertainties given are statistical uncertainties based on the number of experiments performed.
The single iteration, single-solution Grover search algorithm shown in Fig. 3 has a theoretical ASP of 78.1%, as discussed above. The SSO takes into account that the seven unmarked states then have equal expected probabilities totaling 21.9% of being measured. For all Boolean oracles, the average ASP is 38.9(4)% and the average SSO is 83.2(7)%, while phase oracles have an average ASP of 43.7(2)% and an average SSO of 84.9(4)%; the reduced use of resources in the phase oracles (10 XX(χ) gates and 3 qubits for phase oracles compared to 16 XX(χ) gates and 5 qubits for Boolean oracles) results in better performance, as expected. These results compare favorably with the classical ASP of 25%.
The two-solution Grover search algorithm shown in Fig. 4 has a theoretical ASP of 100%, as discussed above. For all Boolean oracles, the average ASP is 67.9(2)% and the average SSO is 67.6(2)%, while phase oracles have an average ASP of 75.3(2)% and an average SSO of 74.4(2)%; the reduced use of resources in the phase oracles (6–8 XX(χ) gates and three qubits for phase oracles compared to 10–14 XX(χ) gates and four qubits for Boolean oracles) results in better performance, as expected. For all oracles in both cases, the two states with the highest measurement probability are also the two marked states. These results compare favorably with the classical ASP of 46.4%.
We note that this implementation of the Grover search algorithm scales linearly in the two-qubit gate count and ancilla count for increasing search database size as a function of the number of qubits n, and for a constant number of solutions t. For a database of size N = 2n stored on n qubits, the amplification stage requires one Toffoli-n gate, and the t-solution oracle stage requires at worst t Toffoli-n (for a phase oracle) or Toffoli-(n + 1) (for a Boolean oracle) gates; optimal oracles for particular sets of marked states may require even fewer two-qubit gates. The method used here to construct the Toffoli-4 circuit scales to Toffoli-n gates as 6n − 13 in the two-qubit gate count and as in the ancilla count29. This paves the way for more extensive use of the Grover search algorithm in solving larger problems on quantum computers, including using the circuit as a subroutine for other quantum algorithms.
Here we present detailed circuit diagrams for all of the operations presented in the paper above, shown in terms of the R(θ,ϕ) and XX(χ) gates directly implemented by the experiment. The single-qubit rotation is defined as
Rotations about the X-axis (R x (θ)) are achieved by setting ϕ = 0, and rotations about the Y-axis (R y (θ)) are achieved by setting . Rotations about the Z-axis (R z (θ)) are comprised of three rotations about axes in the XY plane, as demonstrated in Fig. 5a.
The two-qubit entangling gate is
The parameter χ can be varied continuously by adjusting the overall power applied to the gate, but the gates used here require only or . The gate is maximally entangling for , so .
Two-qubit XX gates are combined with rotation R gates to construct the composite gates needed for the Grover search algorithm implementation. The parameter χ can be positive or negative, depending on what ion pair is chosen and the particulars of the pulse segmentation solution chosen for the ion pair in question; the sign of χ (sgn(χ)) is determined experimentally for each ion pair. Consequently, some composite gate circuits include rotations with parameters that depend on sgn(χ). Composite gates were constructed by starting with known circuits, converting constituent parts into R and XX gates using lower-level constructions, and then optimizing the circuit. First, the number of XX gates was minimized (as in the Toffoli-3 gate, described in the main text). Second, the single-qubit gates were optimized by minimizing the sum of all rotation angles θ, as this minimizes the total time for the experiment. Additional details can be found in refs. 28,29.
The two-qubit CNOT and controlled-Z gates are shown in Fig. 5b, c. They each require one XX gate and several rotations. The three-qubit gates used here are the Toffoli-3 and controlled-controlled-Z (CCZ) gates, shown in Fig. 6a, b. The Toffoli-3 gate requires two control qubits (q 1 and q 2) and one target qubit (q t). Finally, the four-qubit Toffoli-4 gate is shown in Fig. 7. It governs a four-qubit interaction between three control qubits (q 1, q 2, and q 3) and one target qubit (q t), and it additionally requires an ancilla qubit (q a).
The Grover search algorithm is implemented using circuits that are equivalent to those shown in Fig. 1b, d, but with the initialization and amplification stages optimized to minimize gate times, as shown in Fig. 8a, b. The circuits shown are for use with Boolean oracles; in the phase oracle case, the ancilla qubit q a is simply omitted. To preserve the modularity of the algorithm, the initialization stage and amplification stage were each optimized without regard to the contents of the oracle, so each possible oracle can simply be inserted into the algorithm without making any changes to the other stages.
Oracles for the Grover search algorithm were constructed using a combination of reversible and classical logic synthesis techniques. For Boolean oracles, reversible logic synthesis was employed to find a set of X, C N(NOT) gates that marked the desired state(s) for each oracle. For phase oracles, EXOR polynomial synthesis was used to find a set of Z, C N(Z) gates that marked the desired state(s) for each oracle. For example, for Boolean oracles, the selection was limited to the classically available X (or NOT) and C N(NOT) gates, and a reversible circuit was constructed such that the output bit (corresponding to the ancilla qubit in the quantum oracle) would be flipped if and only if a marked state was used as the input to the circuit. While there are many possible circuit constructions for each oracle, the oracle chosen for implementation was one that first minimized the number of two-qubit interactions required, and then minimized the number of single-qubit interactions needed. The synthesis techniques used are scalable and can be applied to oracles of any size. The oracles used here were implemented as per the circuit diagrams shown in Table 1 for single-solution oracles and Table 2 for two-solution oracles.
Other quantum algorithms may be implemented on this system in a similar fashion. First, decompose the algorithm’s subroutines into high-level circuits. Second, optimize those circuits to minimize the number of two-qubit interactions required. Third, decompose the high-level circuits into physical-level R and XX gates. Finally, perform further optimizations to first minimize the number of two-qubit XX gates required, and then to minimize the total rotation time (the sum of all rotation angles θ) across all R gates. However, since the optimization of quantum circuits is QMA-Hard, we anticipate that future improvements in algorithm design, circuit synthesis, and circuit optimization techniques may result in more efficient circuit implementations, facilitating increased experimental performance.
All relevant data are available from the corresponding author upon request.
Publisher's note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
We thank S. Kimmel for helpful discussions. Circuits were drawn using the qcircuit.tex package. This work was supported by the ARO with funds from the IARPA LogiQ program, the AFOSR MURI program, and the NSF Physics Frontier Center at JQI. This material was partially based on work supported by the National Science Foundation during D.M.’s assignment at the Foundation. Any opinion, finding, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.