Article | Open

# Complete 3-Qubit Grover search on a programmable quantum computer

• Nature Communicationsvolume 8, Article number: 1918 (2017)
• doi:10.1038/s41467-017-01904-7
Accepted:
Published online:

## Abstract

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.

## Introduction

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 $t⋅ N - 2 t N + 2 ( N - t ) N 1 N 2 = 5 4 2 2 =78.125%$2, compared to $t N + N - t N ⋅ t N - 1 = 1 8 + 7 8 ⋅ 1 7 =25%$ 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 $13 28 ≈46.4%$ 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.

## Results

### Oracles

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 Ck(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 Cn(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 Ck(Z) (k ≤ n − 1) gates that directly flip the phase(s) of the state(s) to be marked (Fig. 1d, e).

### Experimental setup

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 2S1/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.

### Toffoli gates

Successful demonstration of the Grover search algorithm first requires the implementation of its subroutines. Controlled-NOT (CNOT) gates constructed from an $XX π 4$ gate and single-qubit rotations (Methods) have been demonstrated on this system previously15. Here, we show results for a controlled-controlled-NOT (C2(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 $XX π 8$ and two $XX π 4$ gates) in a manner similar to the Toffoli gate demonstrated in ref. 14. Any doubly-controlled unitary C2(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 V2 = U27. Since $X X π 8 2 =XX π 4$, 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, $XX π 4$) gates were available. These constructions also provide for the implementation of C(Z) and C2(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 $XX π 4$ and $XX π 8$ gates, we are able to save one two-qubit gate relative to a construction limited to CNOT gates29.

### Data

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: $SSO= ∑ j = 0 N e j m j 2$, where e j is the expected population and m j is the measured population for each state j30. 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%.

### Outlook

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 $n - 3 2$ 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.

## Methods

### Circuit diagrams

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

$R ( θ , ϕ ) = cos θ 2 - i e - i ϕ sin θ 2 - i e i ϕ sin θ 2 cos θ 2 .$
(1)

Rotations about the X-axis (R x (θ)) are achieved by setting ϕ = 0, and rotations about the Y-axis (R y (θ)) are achieved by setting $ϕ= π 2$. 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

$XX ( χ ) = cos ( χ ) 0 0 - i sin ( χ ) 0 cos ( χ ) - i sin ( χ ) 0 0 - i sin ( χ ) cos ( χ ) 0 - i sin ( χ ) 0 0 cos ( χ ) .$
(2)

The parameter χ can be varied continuously by adjusting the overall power applied to the gate, but the gates used here require only $χ=± π 4$ or $χ=± π 8$. The gate is maximally entangling for $χ=± π 4$, so $XX π 4 00 = 1 2 00 - i 11$.

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 (q1 and q2) and one target qubit (qt). Finally, the four-qubit Toffoli-4 gate is shown in Fig. 7. It governs a four-qubit interaction between three control qubits (q1, q2, and q3) and one target qubit (qt), and it additionally requires an ancilla qubit (qa).

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 qa 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, CN(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, CN(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 CN(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.

### Data availability

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.

## References

1. 1.

Grover, L. K. Quantum Mechanics helps in searching for a needle in a haystack. Phys. Rev. Lett. 79, 325–328 (1997).

2. 2.

Boyer, M., Brassard, G., Høyer, P. & Tapp, A. Tight bounds on quantum searching. Fortschr. Phys. 46, 493–505 (1998).

3. 3.

Bennett, C., Bernstein, E., Brassard, G. & Vazirani, U. Strengths and weaknesses of quantum computing. SIAM J. Comput. 26, 1510–1523 (1997).

4. 4.

Magniez, F., Santha, M. & Szegedy, M. Quantum algorithms for the triangle problem. SIAM J. Comput. 37, 413–424 (2007).

5. 5.

Dürr, C., Heiligman, M., Høyer, P. & Mhalla, M. Quantum query complexity of some graph problems. SIAM J. Comput. 35, 1310–1328 (2006).

6. 6.

Chuang, I. L., Gershenfeld, N. & Kubinec, M. Experimental implementation of fast quantum searching. Phys. Rev. Lett. 80, 3408–3411 (1998).

7. 7.

Bhattacharya, N., van Linden van den Heuvell, H. B. & Spreeuw, R. J. C. Implementation of quantum search algorithm using classical fourier optics. Phys. Rev. Lett. 88, 137901 (2002).

8. 8.

Brickman, K.-A. et al. Implementation of Grover’s quantum search algorithm in a scalable system. Phys. Rev. A 72, 050306(R) (2005).

9. 9.

Walther, P. et al. Experimental one-way quantum computing. Nature 434, 169–176 (2005).

10. 10.

DiCarlo, L. et al. Demonstration of two-qubit algorithms with a superconducting quantum processor. Nature 460, 240–244 (2009).

11. 11.

Barz, S. et al. Demonstration of blind quantum computing. Science 335, 303–308 (2012).

12. 12.

Manning, T. Quantum Information Processing with Trapped Ion Chains (PhD thesis, University of Maryland, 2014).

13. 13.

Mølmer, K., Isenhower, L. & Saffman, M. Efficient Grover search with Rydberg blockade. J. Phys. B At. Mol. Opt. Phys. 44, 184016 (2011).

14. 14.

Vandersypen, L. M. K. et al. Implementation of a three-quantum-bit search algorithm. Appl. Phys. Lett. 76, 646–648 (2000).

15. 15.

Debnath, S. et al. Demonstration of a small programmable quantum computer module using atomic qubits. Nature 536, 63–66 (2016).

16. 16.

Nielsen, M. A. & Chuang, I. L. Quantum Computation and Quantum Information: 10th Anniversary Edition. 10th edn, (Cambridge University Press, New York, 2011).

17. 17.

Milburn, G., Schneider, S. & James, D. Ion trap quantum computing with warm ions. Fortschr. Phys. 48, 801–810 (2000).

18. 18.

Olmschenk, S. et al. Manipulation and detection of a trapped Yb+ hyperfine qubit. Phys. Rev. A 76, 052314 (2007).

19. 19.

Hayes, D. et al. Entanglement of atomic qubits using an optical frequency comb. Phys. Rev. Lett. 104, 140501 (2010).

20. 20.

Solano, E., de Matos Filho, R. L. & Zagury, N. Deterministic bell states and measurement of the motional state of two trapped ions. Phys. Rev. A 59, R2539–R2543 (1999).

21. 21.

Mølmer, K. & Sørensen, A. Multiparticle entanglement of hot trapped ions. Phys. Rev. Lett. 82, 1835–1838 (1999).

22. 22.

Zhu, S.-L., Monroe, C. & Duan, L.-M. Arbitrary-speed quantum gates within large ion crystals through minimum control of laser beams. Europhys. Lett. 73, 485 (2006).

23. 23.

Choi, T. et al. Optimal quantum control of multimode couplings between trapped ion qubits for scalable entanglement. Phys. Rev. Lett. 112, 190502 (2014).

24. 24.

Cory, D. G., Price, M. D. & Havel, T. F. Nuclear magnetic resonance spectroscopy: an experimentally accessible paradigm for quantum computing. Physica D 120, 82–101 (1998).

25. 25.

Monz, T. et al. Realization of the quantum toffoli gate with trapped ions. Phys. Rev. Lett. 102, 040501 (2009).

26. 26.

Linke, N. M. et al. Experimental comparison of two quantum computing architectures. Proc. Natl Acad. Sci. USA 114, 3305–3310 (2017).

27. 27.

Barenco, A. et al. Elementary gates for quantum computation. Phys. Rev. A 52, 3457–3467 (1995).

28. 28.

Maslov, D. Basic circuit compilation techniques for an ion-trap quantum machine. New J. Phys. 19, 023035 (2017).

29. 29.

Maslov, D. Advantages of using relative-phase Toffoli gates with an application to multiple control Toffoli optimization. Phys. Rev. A 93, 022311 (2016).

30. 30.

Chiaverini, J. et al. Implementation of the semiclassical quantum fourier transform in a scalable system. Science 308, 997–1000 (2005).

31. 31.

Shen, C. & Duan, L.-M. Correcting detection errors in quantum state engineering through data processing. New J. Phys. 14, 053053 (2012).

## Acknowledgements

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.

## Author information

### Affiliations

1. #### Joint Quantum Institute, Department of Physics, Joint Center for Quantum Information and Computer Science, University of Maryland, College Park, MD, 20742, USA

• C. Figgatt
• , D. Maslov
• , K. A. Landsman
• , S. Debnath
•  & C. Monroe

• D. Maslov

• C. Monroe

### Contributions

C.F., D.M., N.M.L., S.D. and C.M. designed the research; C.F., K.A.L., N.M.L., S.D. and C.M. collected and analyzed data; D.M. contributed to the theory; and C.F., D.M., K.A.L., N.M.L., S.D. and C.M. contributed to the manuscript.

### Competing interests

C.M. is the co-founder and chief scientist at IonQ, Inc. The remaining authors declare no competing financial interests.

### Corresponding author

Correspondence to C. Figgatt.