Quantum Algorithm Implementations for Beginners
Abhijith J., Adetokunbo Adedoyin, John Ambrosiano, Petr Anisimov, Andreas Bärtschi, William Casper, Gopinath Chennupati, Carleton Coffrin, Hristo Djidjev, David Gunter, Satish Karra, Nathan Lemons, Shizeng Lin, Alexander Malyzhenkov, David Mascarenas, Susan Mniszewski, Balu Nadiga, Daniel O'Malley, Diane Oyen, Scott Pakin, Lakshman Prasad, Randy Roberts, Phillip Romero, Nandakishore Santhi, Nikolai Sinitsyn, Pieter J. Swart, James G. Wendelberger, Boram Yoon, Richard Zamora, Wei Zhu, Stephan Eidenbenz, Patrick J. Coles, Marc Vuffray, Andrey Y. Lokhov
QuQuantum Algorithm Implementations for Beginners
ABHIJITH J., ADETOKUNBO ADEDOYIN, JOHN AMBROSIANO, PETR ANISIMOV, AN-DREAS BÄRTSCHI, WILLIAM CASPER, GOPINATH CHENNUPATI, CARLETON COF-FRIN, HRISTO DJIDJEV, DAVID GUNTER, SATISH KARRA, NATHAN LEMONS, SHIZENGLIN, ALEXANDER MALYZHENKOV, DAVID MASCARENAS, SUSAN MNISZEWSKI, BALUNADIGA, DANIEL O’MALLEY, DIANE OYEN, SCOTT PAKIN, LAKSHMAN PRASAD,RANDY ROBERTS, PHILLIP ROMERO, NANDAKISHORE SANTHI, NIKOLAI SINITSYN,PIETER J. SWART, JAMES G. WENDELBERGER, BORAM YOON, RICHARD ZAMORA,WEI ZHU, STEPHAN EIDENBENZ ∗ , PATRICK J. COLES ∗ , MARC VUFFRAY ∗ , and ANDREYY. LOKHOV ∗ , Los Alamos National Laboratory, Los Alamos, New Mexico 87545, USAAs quantum computers become available to the general public, the need has arisen to train a cohort ofquantum programmers, many of whom have been developing classical computer programs for most oftheir careers. While currently available quantum computers have less than 100 qubits, quantum computinghardware is widely expected to grow in terms of qubit count, quality, and connectivity. This review aimsto explain the principles of quantum programming, which are quite different from classical programming,with straightforward algebra that makes understanding of the underlying fascinating quantum mechanicalprinciples optional. We give an introduction to quantum computing algorithms and their implementation onreal quantum hardware. We survey 20 different quantum algorithms, attempting to describe each in a succinctand self-contained fashion. We show how these algorithms can be implemented on IBM’s quantum computer,and in each case, we discuss the results of the implementation with respect to differences between the simulatorand the actual hardware runs. This article introduces computer scientists, physicists, and engineers to quantumalgorithms and provides a blueprint for their implementations.
ContentsAbstract 1Contents 11 Introduction 31.1 The quantum computing programming model 41.1.1 The qubit 41.1.2 System of qubits 51.1.3 Superposition and entanglement 51.1.4 Inner and outer products 61.1.5 Measurements 71.1.6 Unitary transformations and gates 71.1.7 Observables and expectation values 91.1.8 Quantum circuits 111.1.9 Quantum algorithms 121.2 Implementations on a real quantum computer 121.2.1 The IBM quantum computer 121.2.2 Programming the IBM quantum computer: Qiskit library 141.3 Classes of quantum algorithms 162 Grover’s Algorithm 172.1 Problem definition and background 17 ∗ [email protected]; [email protected]; [email protected]; [email protected]. LA-UR-20-22353 a r X i v : . [ c s . ET ] M a r Abhijith J., et al. ibmqx2 antum Algorithm Implementations for Beginners 3
15 Quantum Support Vector Machine 6616 Quantum Simulation of the Schrödinger Equation 6716.1 Problem definition and background 6716.2 Algorithm description 6816.3 Algorithm implemented on IBM’s 5-qubit computer 6917 Ground State of the Transverse Ising Model 7017.1 Variational quantum eigenvalue solver 7017.2 Simulation and results 7218 Quantum Partition Function 7418.1 Background on the partition function 7418.2 A simple example 7618.3 Calculating the quantum partition function 7718.4 Implementation of a quantum algorithm on the IBM Quantum Experience 7719 Quantum State Preparation 7819.1 Single qubit state preparation 7819.2 Schmidt decomposition 7919.3 Two-qubit state preparation 8119.4 Two-qubit gate preparation 8119.5 Four qubit state preparation 8220 Quantum Tomography 8220.1 Problem definition and background 8220.2 Short survey of existing methods 8420.3 Implementation of the Maximum Likelihood method on 5-qubit IBM QX 8520.3.1 Warm-up: Hadamard gate 8520.3.2 Maximally entangled state for two qubits 8621 Tests of Quantum Error Correction in IBM Q 8721.1 Problem definition and background 8721.2 Test 1: errors in single qubit control 8821.3 Test 2: errors in entangled 3 qubits control 8921.4 Discussion 89Acknowledgments 90References 90
Quantum computing exploits quantum-mechanical effects—in particular superposition, entangle-ment, and quantum tunneling—to more efficiently execute a computation. Compared to traditional,digital computing, quantum computing offers the potential to dramatically reduce both executiontime and energy consumption. These potential advantages, steady advances in nano-manufacturing,and the slow-down of traditional hardware scaling laws (such as Moore’s Law) have led to a substan-tial commercial and national-security interest and investment in quantum computing technologyin the 2010s. Recently, Google announced that it has reached a major milestone known as quan-tum supremacy–the demonstration that a quantum computer can perform a calculation that isintractable on a classical supercomputer [8]. The problem tackled here by the quantum computeris not one with any direct real-world application. Nonetheless, this is a watershed moment forquantum computing and is widely seen as an important step on the road towards building quantum
Abhijith J., et al. computers that will offer practical speedups when solving real-world problems [82]. (See [2] for aprecise technical definition of quantum supremacy.)While the mathematical basis of quantum computing, the programming model, and most quantumalgorithms have been published decades ago (starting in the 1990s), they have been of interest onlyto a small dedicated community. We believe the time has come to make quantum algorithms andtheir implementations accessible to a broad swath of researchers and developers across computerscience, software engineering, and other fields. The quantum programming model is fundamentallydifferent from traditional computer programming. It is also dominated by physics and algebraicnotations that at times present unnecessary entry barriers for mainstream computer scientists andother more mathematically trained scientists.In this review, we provide a self-contained, succinct description of quantum computing and ofthe basic quantum algorithms with a focus on implementation. Since real quantum computers, suchas IBM Q [55], are now available as a cloud service, we present results from simulator and actualhardware experiments for smaller input data sets. Other surveys of quantum algorithms with adifferent target audience and also without actual implementations include [10, 26, 58, 75, 76, 88].Other cloud service based quantum computers are also available from Rigetti and IonQ, but in thisreview we will focus solely on IBM’s quantum computing ecosystem. The code and implementationsaccompanying the paper can be found at https://github.com/lanl/quantum_algorithms.
Here we provide a self-contained description of the quantum computing programming model. Wewill define the common terms and concepts used in quantum algorithms literature. We will notdiscuss how the constructs explained here are related to the foundations of quantum mechanics.Interested readers are encouraged to take a look at Ref. [77] for a more detailed account along thoselines. Readers with a computer science background are referred to Refs. [67, 85, 110], for a morecomprehensive introduction to quantum computing from a computer science perspective.Quantum computing basically deals with the manipulation of quantum systems. The physicaldetails of this is dependent on the quantum computer’s hardware design. Here we will only talkabout the higher level abstractions used in quantum computing: a typical programmer will onlybe exposed to these abstractions. The state of any quantum system is always represented by avector in a complex vector space (usually called a Hilbert space). Quantum algorithms are alwaysexpressible as transformations acting on this vector space. These basic facts follow from the axiomsof quantum mechanics. Now we will explain some of the basic concepts and terminology used inquantum computing.
The qubit (short for ’quantum bit’) is the fundamental information carrying unitused in quantum computers. It can be seen as the quantum mechanical generalization of a bit usedin classical computers. More precisely, a qubit is a two dimensional quantum system. The state of aqubit can be expressed as, | ϕ ⟩ = α | ⟩ + β | ⟩ . (1)Here α and β are complex numbers such that, | α | + | β | = . In the ket-notation or the
Diracnotation , | ⟩ = (cid:18) (cid:19) and | ⟩ = (cid:18) (cid:19) are shorthands for the vectors encoding the two basis states of atwo dimensional vector space. So according to this notation, Eq. (1) expresses the fact that the stateof the qubit is the two dimensional complex vector (cid:18) αβ (cid:19) . Unlike a classical bit the state of a qubitcannot be measured without changing it. Measuring a qubit, whose state given by Eq. (1), will yield antum Algorithm Implementations for Beginners 5 the classical value of either zero ( | ⟩ ) with probability | α | or one ( | ⟩ ) with probability | β | . Qubitimplementations and technologies are a very active area of research that is not the focus of ourreview, an interested reader is referred to [65] for a survey.
The mathematical structure of a qubit generalizes to higher dimensionalquantum systems as well. The state of any quantum system is a normalized vector (a vector of normone) in a complex vector space. The normalization is necessary to ensure that the total probabilityof all the outcomes of a measurement sum to one.A quantum computer contains many number of qubits. So it is necessary to know how toconstruct the combined state of a system of qubits given the states of the individual qubits. Thejoint state of a system of qubits is described using an operation known as the tensor product , ⊗ .Mathematically, taking the tensor product of two states is the same as taking the Kronecker productof their corresponding vectors. Say we have two single qubit states | ϕ ⟩ = (cid:18) αβ (cid:19) and | ϕ ′ ⟩ = (cid:18) α ′ β ′ (cid:19) . Thenthe full state of a system composed of two independent qubits is given by, | ϕ ⟩ ⊗ | ϕ ′ ⟩ = (cid:18) αβ (cid:19) ⊗ (cid:18) α ′ β ′ (cid:19) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) αα ′ α β ′ βα ′ ββ ′ (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) (2)Sometimes the ⊗ symbol is dropped all together while denoting the tensor product to reduce clutter.Instead the states are written inside a single ket. For example, | ϕ ⟩ ⊗ | ϕ ′ ⟩ is shortened to | ϕϕ ′ ⟩ , and | ⟩ ⊗ | ⟩ ⊗ | ⟩ is shortened to | ⟩ . For larger systems the Dirac notation gives a more succinctway to compute the tensor product using the distributive property of the Kronecker product. For asystem of, say, three qubits with each qubit in the state (cid:12)(cid:12) γ j (cid:11) = α j | ⟩ + β j | ⟩ , for j = , ,
3, the jointstate is, | γ γ γ ⟩ = | γ ⟩ ⊗ | γ ⟩ ⊗ | γ ⟩ (3) = α α α | ⟩ + α α β | ⟩ + α β α | ⟩ + α β β | ⟩ + β α α | ⟩ + β α β | ⟩ + β β α | ⟩ + β β β | ⟩ (4)A measurement of all three qubits could result in any of the eight (2 ) possible bit-strings associatedwith the eight basis vectors. One can see from these examples that the dimension of the state spacegrows exponentially in the number of qubits n and that the number of basis vectors is 2 n . Superposition refers to the fact that any linear combinationof two quantum states, once normalized, will also be a valid quantum state. The upshot to this isthat any quantum state can be expressed as a linear combination of a few basis states. For example,we saw in Eq. (1) that any state of a qubit can be expressed as a linear combination of | ⟩ and | ⟩ .Similarly, the state of any n qubit system can be written as a normalized linear combination of the2 n bit-string states (states formed by the tensor products of | ⟩ ’s and | ⟩ ’s). The orthonormal basisformed by the 2 n bit-string states is called the computational basis. Notice that Eq. (3) described a system of three qubits whose complete state was the tensor productof three different single qubit states. But it is possible for three qubits to be in a state that cannotbe written as the tensor product of three single qubit states. An example of such a state is, | ψ ⟩ = √ (| ⟩ + | ⟩) . (5)States of a system of which cannot be expressed as a tensor product of states of its individualsubsystems are called entangled states . For a system of n qubits, this means that an entalged state Abhijith J., et al. cannot be written a tensor product of n single qubit states. The existence of entangled states is aphysical fact that has important consequences for quantum computing, and quantum informationprocessing in general. In fact, without the existence of such states quantum computers would beno more powerful than their classical counterparts [108]. Entanglement makes it possible to createa complete 2 n dimensional complex vector space to do our computations in, using just n physicalqubits. We will now discuss some linear algebraic notions necessary forunderstanding quantum algorithms. First of these is the inner product or overlap between twoquantum states. As we have seen before, quantum states are vectors in complex vectors spaces. Theoverlap between two states is just the inner product between these complex vectors. For example,take two single qubit states, | ϕ ⟩ = α | ⟩ + β | ⟩ and | ψ ⟩ = γ | ⟩ + δ | ⟩ . The overlap between thesestates is denoted in the ket notation as ⟨ ψ | ϕ ⟩ . And this is given by, ⟨ ψ | ϕ ⟩ = γ ∗ α + δ ∗ β , (6)where ∗ denotes the complex conjugate. Notice that, ⟨ ψ | ϕ ⟩ = ⟨ ϕ | ψ ⟩ ∗ . The overlap of two statesis in general a complex number. The overlap of a state with a bit-string state will produce thecorresponding coefficient. For instance from Eq. (1), ⟨ | ϕ ⟩ = α and ⟨ | ϕ ⟩ = β . And from Eq. (3), ⟨ | γ γ γ ⟩ = α α β . Another way to look at overlaps between quantum states is by definingwhat is called a bra state. The states we have seen so far are ket states, like | ϕ ⟩ , which representedcolumn vectors. A bra state corresponding to this ket state, written as ⟨ ϕ | , represents a row vectorwith complex conjugated entries. For instance | ϕ ⟩ = (cid:18) αβ (cid:19) implies that ⟨ ϕ | = (cid:0) α ∗ β ∗ (cid:1) . The overlapof two states is then the matrix product of a row vector with a column vector, yielding a singlenumber. The reader must have already noticed the wordplay here. The overlap, with its closingangled parenthesis, form a ‘bra-ket’!The outer product of two states is an important operation that outputs a matrix given two states.The outer product of the two states we defined above will be denoted by, | ψ ⟩⟨ ϕ | . Mathematicallythe outer product of two states is a matrix obtained by multiplying the column vector of the firststate with the complex conjugated row vector of the second state (notice how the ket is writtenbefore the bra to signify this). For example, | ψ ⟩ ⟨ ϕ | = (cid:18) αβ (cid:19) (cid:0) γ ∗ δ ∗ (cid:1) = (cid:18) αγ ∗ αδ ∗ βγ ∗ βδ ∗ (cid:19) (7)In this notation any matrix can be written as a linear combination of outer products betweenbit-string states. For a 2 × A = (cid:18) A A A A (cid:19) = A | ⟩ ⟨ | + A | ⟩ ⟨ | + A | ⟩ ⟨ | + A | ⟩ ⟨ | . (8)Acting on a state with a matrix then becomes just an exercise in computing overlaps between states.Let us demonstrate this process: A | ϕ ⟩ = A | ⟩ ⟨ | ϕ ⟩ + A | ⟩ ⟨ | ϕ ⟩ + A | ⟩ ⟨ | ϕ ⟩ + A | ⟩ ⟨ | ϕ ⟩ , = ( A α + A β ) | ⟩ + ( A α + A β ) | ⟩ = (cid:18) A α + A βA α + A β (cid:19) . (9)This notation might look tedious at first glance but it makes algebraic manipulations of quantumstates easily understandable. This is especially true when we are dealing with large number ofqubits as otherwise we would have to explicitly write down exponentially large matrices. antum Algorithm Implementations for Beginners 7 The outer product notation for matrices also gives an intuitive input-output relation for them.For instance, the matrix | ⟩ ⟨ | + | ⟩ ⟨ | can be read as "output 0 when given a 1 and output 1 whengiven a 0". Likewise,the matrix, | ⟩ ⟨ | + | ⟩ ⟨ | + | ⟩ ⟨ | + | ⟩ ⟨ | can be interpreted as themapping {"00" –> "00", "01" –> "01", "11" –> "10", "10" –> "11" }. But notice that this picture becomesa bit tedious when the input is in a superposition. In that case the correct output can be computedlike in Eq. (9). Measurement corresponds to transforming the quantum information (storedin a quantum system) into classical information. For example, measuring a qubit typically corre-sponds to reading out a classical bit, i.e., whether the qubit is 0 or 1. A central principle of quantummechanics is that measurement outcomes are probabilistic .Using the aforementioned notation for inner products, for the single qubit state in Eq. (1), theprobability of obtaining | ⟩ after measurement is | ⟨ | ϕ ⟩ | and the probability of obtaining | ⟩ after measurement is | ⟨ | ϕ ⟩ | . So measurement probabilities can be represented as the squaredabsolute values of overlaps. Generalizing this, the probability of getting the bit string | x . . . x n ⟩ after measuring an n qubit state, | ϕ ⟩ , is then | ⟨ x . . . x n | ϕ ⟩ | .Now consider a slightly more complex case of measurement. Suppose we have a three qubitstate, | ψ ⟩ but we only measure the first qubit and leave the other two qubits undisturbed. What isthe probability of observing a | ⟩ in the first qubit? This probability will be given by, (cid:213) ( x x )∈{ , } | ⟨ x x | ϕ ⟩ | . (10)The state of the system after this measurement will be obtained by normalizing the state, (cid:213) ( x x )∈{ , } ⟨ x x | ϕ ⟩ | x x ⟩ . (11)Applying this paradigm to the state in Eq. (5) we see that the probability of getting | ⟩ in the firstqubit will be 0 .
5, and if this result is obtained, the final state of the system would change to | ⟩ . On the other hand, if we were to measure | ⟩ in the first qubit we would end up with a state | ⟩ . Similarly we can compute the effect of subsystem measurements on any n qubit state.In some cases we will need to do measurements on a basis different from the computationalbasis. This can be achieved by doing an appropriate transformation on the qubit register beforemeasurement. Details of how to do this is given in a subsequent section discussing observables andexpectation values.The formalism discussed so far is sufficient to understand all measurement scenarios in this paper.We refer the reader to Ref. [77] for a more detailed and more general treatment of measurement. A qubit or a system of qubits changes its state by goingthrough a series of unitary transformations . A unitary transformation is described by a matrix U with complex entries. The matrix U is called unitary if UU † = U † U = I , (12)where U † is the transposed, complex conjugate of U (called its Hermitian conjugate ) and I is theidentity matrix. A qubit state | ϕ ⟩ = α | ⟩ + β | ⟩ evolves under the action of the 2 × U according to | ϕ ⟩ → U | ϕ ⟩ = (cid:18) U U U U (cid:19) (cid:18) αβ (cid:19) = (cid:18) U α + U βU α + U β (cid:19) . (13) Abhijith J., et al.
Operators acting on different qubits can be combined using the Kronecker product. For example, if U and U are operators acting on two different qubits then the full operator acting on the combinedtwo qubit system will be given by U ⊗ U .For an n qubit system the set of physically allowed transformations, excluding measurements,consists of all 2 n × n unitary matrices. Notice that the size of a general transformation increasesexponentially with the number of qubits. In practice a transformation on n qubits is effected byusing a combination of unitary transformations that act only on one or two qubits at a time. Byanalogy to classical logic gates like NOT and AND, such basic unitary transformations, whichare used to build up more complicated n qubit transformations, are called gates . Gates are unitarytransformations themselves and from Eq. (12) it is clear that unitarity can only be satisfied if thenumber of input qubits is equal to the number of output qubits. Also, for every gate U it is alwayspossible to have another gate U † that undoes the transformation. So unlike classical gates quantumgates have to be reversible. Reversible means that the gate’s inputs can always be reconstructedfrom the gate’s outputs. For instance, a classical NOT gate, which maps 0 to 1 and 1 to 0 is reversiblebecause an output of 1 implies the input was 0 and vice versa. However, a classical AND gate,which returns 1 if and only if both of its inputs are 1, is not reversible. An output of 1 implies thatboth inputs were 1, but an output of 0 provides insufficient information to determine if the inputswere 00, 01, or 10.But this extra restriction of reversibility does not mean that quantum gates are ‘less powerful’than classical gates. Even classical gates can be made reversible with minimal overhead. Reversibilitydoes not restrict their expressive power [87]. Quantum gates can then be seen as a generalizationof classical reversible gates.The most common gates are described in Table 1. The X gate is the quantum version of the NOTgate. The CNOT or “controlled NOT” negates a target bit if and only if the control bit is 1. We willuse the notation CNOT ij for a CNOT gate controlled by qubit i acting on qubit j . The CNOT gatecan be expressed using the outer product notation as,CNOT = | ⟩ ⟨ | ⊗ I + | ⟩ ⟨ | ⊗ X = | ⟩ ⟨ | + | ⟩ ⟨ | + | ⟩ ⟨ | + | ⟩ ⟨ | . (14)The Toffoli gate or “controlled-controlled NOT” or CCNOT, is a three qubit gate that is essentiallythe quantum (reversible) version of the AND gate. It negates a target bit if and only if both controlbits are 1. In the outer product notation,CCNOT = | ⟩ ⟨ | ⊗ X + ( I − | ⟩ ⟨ |) ⊗ I . (15)Another way to look at the CCNOT gate is as a CNOT gate with an additional control qubit,CCNOT = | ⟩ ⟨ | ⊗ I + | ⟩ ⟨ | ⊗ CNOT . (16)In general, one can define controlled versions of any unitary gate U as, CU = | ⟩ ⟨ | ⊗ I + | ⟩ ⟨ | ⊗ U . (17) CU applies U to a set of qubits only if the first qubit (called the control qubit) is | ⟩ .A set of gates that together can execute all possible quantum computations is called a universalgate set . Taken together, the set of all unary (i.e., acting on one qubit) gates and the binary (i.e., actingon two qubits) CNOT gate form a universal gate set. More economically, the set { H , T , CNOT } (Refer Table 1 for definitions of these gates) forms a universal set. Also, the Toffoli gate by itself isuniversal [77]. antum Algorithm Implementations for Beginners 9 One-qubit gates Multi-qubit gates
Hadamard = H = √ (cid:18) − (cid:19) CNOT = CX = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) I = (cid:18) (cid:19) , S = (cid:18) i (cid:19) CZ = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) − (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) T = (cid:18) e iπ / (cid:19) Controlled- U = CU = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) U U U U (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) NOT = X = (cid:18) (cid:19) SWAP = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) Y = (cid:18) − ii (cid:19) , Z = (cid:18) − (cid:19) Toffoli ( CCNOT ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) R ( θ ) = P ( θ ) = (cid:18) e iθ (cid:19) Table 1. Commonly used quantum gates.
We have seen that experiments in quantum mechanicsare probabilistic. Often in experiments we will need to associate a real number with a measurementoutcome. And quantities that we measure in quantum mechanics will always be statistical averagesof these numbers. For instance, suppose we do the following experiment on many copies of thesingle qubit state in Eq. (1): We measure a copy of the state and if we get | ⟩ we record 1 in our labnotebook , otherwise we record −
1. While doing this experiment we can never predict the outcomeof a specific measurement. But we can ask statistical questions like: “What will be the averagevalue of the numbers in the notebook?” From our earlier discussion on measurement we know thatthe probability of measuring | ⟩ is | α | and the probability of measuring | ⟩ is | β | . So the averagevalue of the numbers in the notebook will be, | α | − | β | (18) In quantum formalism, there is neat way to express such experiments and their average outcomes,without all the verbiage, using certain operators. For the experiment described above the associatedoperator would be the Z gate, Z = | ⟩ ⟨ | − | ⟩ ⟨ | = (cid:18) − (cid:19) (19)By associating this operator with the experiment we can write the average outcome of the experi-ment, on | ϕ ⟩ , as the overlap between | ϕ ⟩ and Z | ϕ ⟩ , ⟨ ϕ | Z | ϕ ⟩ = ⟨ ϕ | ⟩ ⟨ | ϕ ⟩ − ⟨ ϕ | ⟩ ⟨ | ϕ ⟩ = | α | − | β | . (20)The operator Z is called the observable associated with this experiment. And the quantity ⟨ ϕ | Z | ϕ ⟩ is called its expectation value . The expectation value is sometimes denoted by ⟨ Z ⟩ , when there is noambiguity about the state on which the experiment is performed.Here we saw an experiment done in the computational basis. But this need not always be thecase. Experiments can be designed by associating real numbers to measurement outcomes in anybasis. What would be the observable for such an experiment? For an experiment that associatesthe real numbers { a i } to a measurement onto a basis set {| Φ i ⟩} , the observable will be, O ≡ (cid:213) i a i | Φ i ⟩ ⟨ Φ i | . (21)This observable will reproduce the correct expectation value for this experiment done on any state | ψ ⟩ , ⟨ ψ | O | ψ ⟩ = (cid:213) i a i ⟨ ψ | Φ i ⟩ ⟨ Φ i | ψ ⟩ = (cid:213) i a i | ⟨ Φ i | ψ ⟩ | . (22)Because the states {| Φ i ⟩} are orthonormal, we can see that O obeys the following eigenvalueequation, O (cid:12)(cid:12) Φ j (cid:11) = (cid:213) i a i | Φ i ⟩ (cid:10) Φ i | Φ j (cid:11) = a j (cid:12)(cid:12) Φ j (cid:11) . (23)So O is an operator that has complete set of orthogonal eigenvectors and real eigenvalues. Suchoperators are called Hermitian operators.
Equivalently, these operators are equal to their Hermitianconjugates ( O = O † ). In quantum mechanics, any Hermitian operator is a valid observable. Theeigenvectors of the operator give the possible outcomes of the experiment and the correspondingeigenvalues are the real numbers associated with that outcome.But can all valid observables be measured in practice? The answer to this depends on the quantumsystem under consideration. In this tutorial, the system under consideration is an IBM quantumprocessor. And in these processors only measurements onto the computational basis are supportednatively. Measurements to other basis states can be performed by applying an appropriate unitarytransformation before measurement. Suppose that the hardware only lets us do measurements ontothe computational basis {| i ⟩} but we want to perform a measurement onto the basis set {| Φ i ⟩} .This problem can be solved if we can implement the following unitary transformation, U = (cid:213) i | i ⟩ ⟨ Φ i | . (24)Now measuring U | ψ ⟩ in the computational basis is the same as measuring | ψ ⟩ in the {| Φ i ⟩} basis.This can be seen by computing the outcome probabilities on U | ψ ⟩ , | ⟨ j | U | ψ ⟩ | = | (cid:213) i ⟨ j | i ⟩ ⟨ Φ i | ψ ⟩ | = | (cid:10) Φ j | ψ (cid:11) | . (25) antum Algorithm Implementations for Beginners 11 So once U is applied, the outcome | j ⟩ becomes equivalent to the outcome (cid:12)(cid:12) Φ j (cid:11) in the originalmeasurement scenario. Now, not all such unitary transformations are easy to implement. So ifa quantum algorithm requires us to perform a measurement onto some complicated set of basisstates, then the cost of implementing the corresponding U has be taken into account. Quantum algorithms are often diagrammatically represented as circuitsin literature. Here we will describe how to construct and read quantum circuits. In the circuitrepresentation, qubits are represented by horizontal lines. Gates are then drawn on the qubits theyact on. This is done in sequence from left to right. The initial state of the qubit is denoted at thebeginning of each of the qubit lines. Notice that when we write down a mathematical expressionfor the circuit, the gates are written down from right to left in the order of their application.These principles are best illustrated by an example. Given in Fig. 1 is a circuit to preparing anentangled two qubit state called a Bell state from | ⟩ . | ⟩ H •| ⟩ Fig. 1. Quantum circuit for preparing a Bell state
The circuit encodes the equation,CNOT ( H ⊗ I ) | ⟩ = √ (| ⟩ + | ⟩) . Let us now carefully go over how the circuit produces the Bell state. We read the circuit from leftto right. The qubits are numerically labelled starting from the top. First the H gate acts on the topmost qubit changing the state of the system to, H ⊗ I | ⟩ = ( H | ⟩) ⊗ ( I | ⟩) = (cid:18) | ⟩ + | ⟩√ (cid:19) ⊗ | ⟩ = √ (| ⟩ + | ⟩) . Then CNOT acts on both of these qubits. The blackened dot on the first qubit implies that thisqubit is the control qubit for the CNOT. The ⊕ symbol on the second qubit implies that this qubit isthe target of the NOT gate (controlled by the state of the first qubit). The action of the CNOT thengives, CNOT (cid:18) √ (| ⟩ + | ⟩) (cid:19) = √ ( CNOT | ⟩ + CNOT | ⟩) = √ (| ⟩ + | ⟩) . The measurement of a qubit is also denoted by a special gate with a meter symbol on it, given in Fig 2.The presence of this gate on a qubit means that the qubit must be measured in the computationalbasis.
Fig. 2. The measurement gate
We have now introduced all the basic elements needed for the discus-sion of practical quantum algorithms. A quantum algorithm consists of three basic steps: • Encoding of the data, which could be classical or quantum, into the state of a set of inputqubits. • A sequence of quantum gates applied to this set of input qubits. • Measurements of one or more of the qubits at the end to obtain a classically interpretableresult.In this review, we will describe the implementation of these three steps for a variety of quantumalgorithms.
In this article, we consider IBM’s publicly available quantumcomputers. In most cases, we specifically consider the ibmqx4 , which is a 5-qubit computer, althoughin some cases we also consider other quantum processors freely accessible through the IBMQuantum Experience platform. These processors can be accessed by visiting the IBM QuantumExperience website (https://quantum-computing.ibm.com/)There are several issues to consider when implementing an algorithm on real quantum computers,for example:(1) What is the available gate set with which the user can state their algorithm?(2) What physical gates are actually implemented?(3) What is the qubit connectivity (i.e., which pairs of qubits can two-qubit gates be applied to)?(4) What are the sources of noise (i.e., errors)?We first discuss the available gate set. In IBM’s graphical interface to the ibmqx4 , the availablegates include: { I , X , Y , Z , H , S , S † , T , T † , U ( λ ) , U ( λ , ϕ ) , U ( λ , ϕ , θ ) , CNOT } . (26)The Graphical User Interface (GUI) also provides other controlled gates and operations like measure-ment and reset. Most of these gates appear in our Table 1. The gates U ( λ ) , U ( λ , ϕ ) , and U ( λ , ϕ , θ ) are continuously parameterized gates, defined as follows: U ( λ ) = (cid:18) e iλ (cid:19) , U ( λ , ϕ ) = √ (cid:18) − e iλ e iϕ e i ( λ + ϕ ) (cid:19) , U ( λ , ϕ , θ ) = (cid:18) cos ( θ / ) − e iλ sin ( θ / ) e iϕ sin ( θ / ) e i ( λ + ϕ ) cos ( θ / ) (cid:19) . (27)Note that U ( λ , ϕ , θ ) is essentially an arbitrary one-qubit gate.The gates listed in Eq. (26) are provided by IBM for the user’s convenience. However these arenot the gates that are physically implemented by their quantum computer. IBM has a compiler thattranslates the gates in (26) into products of gates from a physical gate set. The physical gate setemployed by IBM is essentially composed of three gates [1]: { U ( λ ) , R X ( π / ) , CNOT } . (28)Here, R X ( π / ) is a rotation by angle π / X -axis, corresponding to a matrixsimilar to the Hadamard: R X ( π / ) = √ (cid:18) − i − i (cid:19) . (29)The reason why it could be important to know the physical gate set is that some user-programmedgates may need to be decomposed into multiple physical gates, and hence could lead to a longer antum Algorithm Implementations for Beginners 13
210 34
Fig. 3. The connectivity diagram of ibmqx4 . The circles represent qubits and the arrows represent the abilityto apply a physical CNOT gate between the qubits. physical algorithm. For example, the X gate gets decomposed into three gates: two R X ( π / ) gatessandwiching one U ( λ ) gate.The connectivity of the computer is another important issue. Textbook algorithms are typicallywritten for a fully-connected hardware, which means that one can apply a two-qubit gate to anytwo qubits. In practice, real quantum computers may not have full connectivity. In the ibmqx4 ,which has 5 qubits, there are 6 connections, i.e., there are only 6 pairs of qubits to which a CNOTgate can be applied (Fig.3). In contrast a fully connected 5-qubit system would allow a CNOT to beapplied to 20 different qubit pairs. In this sense, there are 14 “missing connections”. Fortunately,there are ways to effectively generate connections through clever gate sequences. For example, aCNOT gate with qubit j as the control and qubit k as the target can be reversed (such that j is thetarget and k is the control) by applying Hadamard gates on each qubit both before and after theCNOT, i.e., CNOT kj = ( H ⊗ H ) CNOT jk ( H ⊗ H ) . (30)Similarly, there exists a gate sequence to make a CNOT between qubits j and l if one has connectionsbetween j and k , and k and l , as follows:CNOT jl = CNOT kl CNOT jk CNOT kl CNOT jk . (31)Hence, using (30) and (31), one can make up for lack of connectivity at the expense of using extragates.Finally, when implementing a quantum algorithm it is important to consider the sources of noisein the computer. The two main sources of noise are typically gate infidelity and decoherence . Gateinfidelity refers to the fact that the user-specified gates do not precisely correspond to the physicallyimplemented gates. Gate infidelity is usually worse for multi-qubit gates than for one-qubit gates, sotypically one wants to minimize the number of multi-qubit gates in one’s algorithm. Decoherencerefers to the fact that gradually over time the quantum computer loses its “quantumness” andbehaves more like a classical object. After decoherence has fully occurred, the computer canno longer take advantage of quantum effects. This introduces progressively more noise as thequantum algorithm proceeds in time. Ultimately this limits the depth of quantum algorithms thatcan be implemented on quantum computers. It is worth noting that different qubits decohere atdifferent rates, and one can use this information to better design one’s algorithm. The error ratesfor individual qubits in the IBM processors are listed in the IBM Quantum Experience website.In this tutorial, we will show in many cases how infidelity and decoherence affect the algorithmperformance in practice. Fig. 4. The quantum circuit to prepare a Bell state and measure it in the IBM quantum experience GUI
A simple example of programming the IBM quantum computer is given in Fig. 4, which showsthe Bell state preparation circuit Fig.1 compiled using the IBM quantum experience GUI. Extrameasurement operations at the end serve to verify the fidelity of the implementation.
QuantumCircuit with the required number of qubits and classical bits. Thengates and measurements are added to this blank circuit. Gates and measurements are implementedin Qiskit as methods of the
QuantumCircuit class. After the circuit has been designed we need tochoose a backend to run the circuit. This can be either be a simulator called the qasm_simulator or it can be one of IBM’s quantum processors. To use a quantum processor, you will need to loadyour IBM Q account information into Qiskit. Given in Fig. 5 is a simple code to construct the Bellstate. This is the Qiskit version of the circuit in Fig. 1 with measurement added at the end to verifyour results. antum Algorithm Implementations for Beginners 15 import numpy as npfrom qiskit import
QuantumCircuit, execute, Aer print (" \n Total count for 00 and 11 are:",counts)
Fig. 5. Qiskit code to create and measure a Bell state. Source:
In Fig.5 we are running the circuit on the simulator for 1000 independent runs. The final outputwas {'11': 493, '00': 507} . This is what we expect from measuring the Bell state ( | ⟩ + | ⟩√ ), upto statistical fluctuations. While running the same code on the 14 qubit ibmq_16_melbourne processor for 1024 runs gave | ⟩ with probability 0 .
358 and | ⟩ with probability 0 .
54. Theremaining probability was distributed over 01 and 10, which should not be a part of the Bellstate. As we discussed before, this phenomenon is due to errors inherent to the quantum processor.As the backend technology improves we expect to get better results from these trials. Often, we willalso present a circuit using OpenQASM (Open Quantum Assembly Language). OpenQASM providesan intermediate representation of a program in the form of a quantum circuit, that is neither theactual program written by the programmer nor the machine instructions seen by the processor.OpenQASM ‘scores’ we show in this paper will be simple sequence of gates and measurements, withthe corresponding registers that they act on. The syntax of these scores will be self explanatory.
Class Problem/Algorithm Paradigms used Hardware Simulation MatchInverse Function Computation Grover’s Algorithm GO QX4 medBernstein-Vazirani n.a. QX4, QX5 highNumber-theoretic Applications Shor’s Factoring Algorithm QFT QX4 medAlgebraic Applications Linear Systems HHL QX4 lowMatrix Element Group Representations QFT ESSEX lowMatrix Product Verification GO n.a. n.a.Subgroup Isomorphism QFT none n.a.Persistent Homology GO, QFT QX4 med-lowGraph Applications Quantum Random Walk n.a. VIGO med-lowMinimum Spanning Tree GO QX4 med-lowMaximum Flow GO QX4 med-lowApproximate Quantum Algorithms SIM QX4 highLearning Applications Quantum Principal Component Analysis (PCA) QFT QX4 medQuantum Support Vector Machines (SVM) QFT none n.a.Partition Function QFT QX4 med-lowQuantum Simulation Schrödinger Equation Simulation SIM QX4 lowTransverse Ising Model Simulation VQE none n.a.Quantum Utilities State Preparation n.a. QX4 medQuantum Tomography n.a. QX4 medQuantum Error Correction n.a. QX4 med
Table 2. Overview of studied quantum algorithms. Paradigms include Grover Operator (GO), QuantumFourier Transform (QFT), Harrow-Hassidim-Lloyd (HHL), Variational Quantum Eigenvalue solver (VQE),and direct Hamiltonian simulation (SIM). The simulation match column indicates how well the hardwarequantum results matched the simulator results
In this review, we broadly classify quantum algorithms according to their area of application. Wewill discuss quantum algorithms for graph theory, number theory, machine learning and so on. Thecomplete list of algorithms discussed in this paper, classified according to their application areas,can be found in Table 2. The reader is also encouraged to take a look at the excellent QuantumAlgorithm Zoo website [58] for a concise and comprehensive list of quantum algorithms.In classical computing, algorithms are often designed by making use of one or more algorithmicparadigms like dynamic programming or local search, to name a few. Most known quantumalgorithms also use a combination of algorithmic paradigms specific to quantum computing. Theseparadigms are the Quantum Fourier Transform (QFT), the Grover Operator (GO), the Harrow-Hassidim-Lloyd (HHL) method for linear systems, variational quantum eigenvalue solver (VQE),and direct Hamiltonian simulation (SIM). The number of known quantum algorithmic paradigms ismuch smaller compared to the number of known classical paradigms. The constraint of unitarity onquantum operations and the impossibility of non-intrusive measurement make it difficult to designquantum paradigms from existing classical paradigms. But researchers are constantly in searchfor new paradigms and we can expect this list to get longer in the future. Table 2 also containsinformation about the paradigms used by the algorithms in this article.The rest of the paper presents each of the algorithms shown in Table 2, one after the other. Ineach case, we first discuss the goal of the algorithm (the problem it attempts to solve). Then wedescribe the gate sequence required to implement this algorithm. Finally, we show the results fromimplementing this algorithm on IBM’s quantum computer . The code and implementations for most of the algorithms can be found at https://github.com/lanl/quantum_algorithms. antum Algorithm Implementations for Beginners 17
Grover’s algorithm as initially described [52] enables one to find (with probability > /
2) a specificitem within a randomly ordered database of N items using O (√ N ) operations. By contrast, aclassical computer would require O ( N ) operations to achieve this. Therefore, Grover’s algorithmprovides a quadratic speedup over an optimal classical algorithm. It has also been shown [14] thatGrover’s algorithm is optimal in the sense that no quantum Turing machine can do this in less than O (√ N ) operations.While Grover’s algorithm is commonly thought of as being useful for searching a database, thebasic ideas that comprise this algorithm are applicable in a much broader context. This approachcan be used to accelerate search algorithms where one could construct a “quantum oracle” thatdistinguishes the needle from the haystack. The needle and hay need not be part of a database. Forexample, it could be used to search for two integers 1 < a < b such that ab = n for some number n ,resulting in a factoring algorithm. Grover’s search in this case would have worse performance thanShor’s algorithm [93, 94] described below, which is a specialised algorithm to solve the factoringproblem. Implementing the quantum oracle can be reduced to constructing a quantum circuit thatflips an ancillary qubit, q , if a function, f ( x ) , evaluates to 1 for an input x . We use the term ancilla or ancillary qubit to refer to some extra qubits that are used by the algorithm.The function f ( x ) is defined by f ( x ) = (cid:40) x = x ∗ x (cid:44) x ∗ (32)where x = x x . . . x n are binary strings and x ∗ is the specific string that is being sought. It mayseem paradoxical at first that an algorithm for finding x ∗ is needed if such a function can beconstructed. The key here is that f ( x ) need only recognize x ∗ – it is similar to the differencebetween writing down an equation and solving an equation. For example, it is easy to check if theproduct of a and b is equal to n , but harder to factor n . In essence, Grover’s algorithm can invertan arbitrary function with binary outputs, provided we have a quantum oracle that implementsthe function. Grover’s algorithm has been used, with appropriate oracles, to solve problems likefinding triangles in a graph [72], finding cycles [28], and finding maximal cliques [109]. For theanalysis of Grover’s algorithm, the internals of the oracle is typically considered a black-box. Often,the oracle operator for the problem at hand has to be constructed as a quantum circuit. But, keepin mind that an inefficient oracle construction can nullify any practical advantages gained by usingGrover’s search.Here we implement a simple instance of Grover’s algorithm. That is, the quantum oracle weutilize is a very simple one. Let x = x x and we wish to find x ∗ such that x ∗ = x ∗ =
1. Whilefinding such an x ∗ is trivial, we don a veil of ignorance and proceed as if it were not. This essentiallymeans that our function f ( x ) is an AND gate. But AND gate is not reversible and cannot be aquantum gate. However the Toffoli gate, that was introduced in the previous section, is a reversibleversion of the classical AND gate. The Toffoli gate takes three bits as input and outputs three bits.The first two bits are unmodified. The third bit is flipped if the first two bits are 1. The unitarymatrix corresponding to the Toffoli gate can be found in Table 1. In other words, the Toffoli gateimplements our desired quantum oracle where the first two inputs are x and x and the third bit isthe ancillary bit, q . The behavior of the oracle in general is | x ⟩ | q ⟩ → | x ⟩ (cid:12)(cid:12) f ( x ) (cid:201) q (cid:11) , where (cid:201) isthe XOR operation . Here we will only discuss the case where x ∗ is unique. Grover’s algorithm canalso be used to search for multiple items in a database. Fig. 6. A schematic diagram of Grover’s algorithm is shown. Note that in this case, one application of theGrover operator is performed. This is all that is necessary when there are only two bits in x , but the Groveroperator should be applied repeatedly for larger problems. Here we present a brief introduction to Grover’s algorithm. A more detailed account can be foundin Nielsen and Chuang [77]. Let N be the number of items (represented as bit strings) amongstwhich we are performing the search. This number will also be equal to the dimension of the vectorspace we are working with. An operator, called the Grover operator or the diffusion operator, isthe key piece of machinery in Grover’s algorithm. This operator is defined by G = ( | ψ ⟩ ⟨ ψ | − I ) O (33)where | ψ ⟩ = √ N (cid:205) i | i ⟩ is the uniform superposition over all the basis states and O is the oracleoperator (see Fig. 6 for a representation of this operator in the case where x consists of 2 bits). Theaction of ( | ψ ⟩ ⟨ ψ | − I ) on an arbitrary state, given by (cid:205) i a i | i ⟩ , when decomposed over the basisstates is, ( | ψ ⟩ ⟨ ψ | − I ) (cid:213) i a i | i ⟩ = (cid:213) i ( ⟨ a ⟩ − a i ) | i ⟩ (34)where ⟨ a ⟩ = (cid:205) i a i N is the average amplitude in the basis states. From Eq. (34) one can see that theamplitude of each | i ⟩ -state ( a i ) is flipped about the mean amplitude.In order to use the Grover operator to successfully perform a search, the qubit register mustbe appropriately initialized. The initialization is carried out by applying a Hadamard transformto each of the the main qubits ( H ⊗ n ) and applying a Pauli X transform followed by a Hadamardtransform ( HX ) to the ancilla. This leaves the main register in the uniform superposition of allstates, | ψ ⟩ , and the ancilla in the state | ⟩−| ⟩√ . After performing these operations, the system is inthe state | ψ ⟩ | ⟩−| ⟩√ . Using Eq. (34), we can now understand how the Grover operator works. Theaction of the oracle operator on | x ∗ ⟩ | ⟩−| ⟩√ reverses the amplitude of that state O | x ∗ ⟩ | ⟩ − | ⟩√ → | x ∗ ⟩ (cid:12)(cid:12) f ( x ∗ ) (cid:201) (cid:11) − (cid:12)(cid:12) f ( x ∗ ) (cid:201) (cid:11) )√ = | x ∗ ⟩ | ⟩ − | ⟩√ = − | x ∗ ⟩ | ⟩ − | ⟩√ | x ∗ ⟩ isbelow ⟨ a ⟩ (using the notation of Eq. (34)) while all the other states have an amplitude that is slightlyabove ⟨ a ⟩ . The effect of applying 2 | ψ ⟩ ⟨ ψ | − I is then to make | x ∗ ⟩ have an amplitude above themean while all other states have an amplitude below the mean. The desired behavior of the Grover antum Algorithm Implementations for Beginners 19 operator is to increase the amplitude of | x ∗ ⟩ while decreasing the amplitude of the other states. Ifthe Grover operator is applied too many times, this will eventually stop happening. The Groveroperator should be applied exactly (cid:108) π √ N (cid:109) times after which a measurement will reveal x ∗ withprobability close to 1. In the case where x has two bits, a single application of Grover’s operator issufficient to find x ∗ with certainty (in theory). Below is a high level pseudocode for the algorithm. Algorithm 1
Grover’s algorithm
Input: • An Oracle operator effecting the transformation | x ⟩ | q ⟩ → | x ⟩ | q ⊕ f ( x )⟩ . Output: • The unique bit string x ∗ satisfying Eq. (32) Procedure:Step 1.
Perform state initialization | . . . ⟩ → | ψ ⟩ ( | ⟩−| ⟩√ ) Step 2.
Apply Grover operator (cid:108) π √ N (cid:109) times Step 3.
Perform measurement on all qubit except the ancillary qubit.
Fig. 7 shows the circuit that was designed to fit the ibmqx4 quantum computer. The Toffoli gate isnot available directly in ibmqx4 so it has to be constructed from the available set of gates given inEq. 26.The circuit consists of state preparation (first two time slots), a Toffoli gate (the next 13 timeslots), followed by the 2 | ψ ⟩ ⟨ ψ | − I operator (7 time slots), and measurement (the final 2 time slots).We use q [ ] (in the register notation from Fig. 7) as the ancillary qubit, and q [ ] and q [ ] as x and x respectively. Note that the quantum computer imposes constraints on the possible source andtarget of CNOT gates.Using the simulator, this circuit produces the correct answer x = ( , ) every time. We executed1,024 shots using the ibmqx4 and x = ( , ) was obtained 662 times with ( , ) , ( , ) , and ( , ) occurring 119, 101, and 142 times respectively. This indicates that the probability of obtainingthe correct answer is approximately 65%. The deviation between the simulator and the quantumcomputer is due to the inherent errors in ibmqx4 . This deviation will get worse for circuits of largersize.We also ran another test using CNOT gates that did not respect the underlying connectivity ofthe computer. This resulted in a significantly deeper circuit and the results were inferior to theresults with the circuit in Fig. 7.This implementation used a Toffoli gate with a depth of 23 (compared to a depth of 13 here) andobtained the correct answer 48% of the time. Suppose we are given a classical Boolean function, f : { , } n (cid:55)→ { , } . It is guaranteed that thisfunction can always be represented in the form, f s ( x ) = (cid:201) i s i x i ≡ ⟨ s , x ⟩ . Here, s is an unknownbit string, which we shall call a hidden string . Just like in Grover’s algorithm we assume that wehave a quantum oracle that can compute this function.The Bernstein-Vazirani (BV) algorithm then finds the hidden string with just a single applicationof the oracle. The number of times the oracle is applied during an algorithm algorithm is known as Fig. 7. The circuit that was executed on IBM’s 5-qubit quantum computer. The first two time slots correspondto the state preparation. The next 13 time slots implement a Toffoli gate. The next 7 time slots implement the | ψ ⟩ ⟨ ψ | − I operator, and the final two time slots are used for observing x and x . its query complexity . The BV algorithm has a query complexity of one. From our earlier discussionswe saw that Grover’s algorithm has a query complexity of O (√ N ) . In the classical case each call to f s ( x ) produces just 1 bit of information, and since an arbitraryhidden string s has n -bits of information, the classical query complexity is seen to be n . Even withbounded error, there is no way that this classical complexity can be brought down, as can be seenusing slightly more rigorous information-theoretic arguments.The quantum algorithm to solve this problem was developed by Bernstein and Vazirani [15]building upon the earlier work of Deutsch and Jozsa [36]. Their contribution was a quantumalgorithm for the hidden string problem, which has a non-recursive quantum query complexityof just 1. This constitutes a polynomial O( n ) query-complexity separation between classical andquantum computation. They also discovered a less widely known recursive hidden-string queryalgorithm, which shows a O( n log n ) separation between classical and quantum query-complexities.These developments preceded the more famous results of Shor and Grover, and kindled a lot ofearly academic interest in the inherent computational power of quantum computers.One thing to note about the BV algorithm is that the black-box function f s (·) can be very complexto implement using reversible quantum gates. For an n -bit hidden string, the number of simplegates needed to implement f s (·) scales typically as O( n ) [77]. Since the black box is a step in thealgorithm, its serial execution time could in the worst-case even scale exponentially. The realbreakthrough of this quantum algorithm lies in speeding up the query complexity and not theexecution time per se. Let us explore the BV algorithm in more detail. Let U s be the oracle for the function f s ( x ) . It acts inthe usual way and computes the value of the function onto an ancilla qubit, U s | x ⟩ | q ⟩ = | x ⟩ | q ⊕ ⟨ s , x ⟩⟩ (36)Denoting |−⟩ = (| ⟩ − | ⟩)/√
2, we can easily verify from Eq. (35) that, U s | x ⟩ |−⟩ = (− ) ⟨ s , x ⟩ | x ⟩ |−⟩ . (37)Also, note that the n -qubit Hadamard operator, which is just n single qubit H operators appliedin parallel, can be expanded as, H ⊗ n = √ n (cid:213) x , y ∈{ , } n (− ) ⟨ x , y ⟩ | y ⟩ ⟨ x | (38)The reader may verify this identity by applying H ⊗ n to the computational basis states. antum Algorithm Implementations for Beginners 21 Fig. 8. Bernstein-Vazirani hidden string discovery quantum algorithm. The hidden string s is discovered withjust a single query. The measurement result (cid:101) s gives the hidden string. U s and H ⊗ n are the only two operators needed for the BV algorithm. The pseudocode for thealgorithm is given in Algorithm 2. Notice that the initialization part is identical to that of Grover’salgorithm. This kind of initialization is a very common strategy in quantum algorithms. Algorithm 2
Bernstein-Vazirani algorithm
Input: • An oracle operator, U s , effecting the transformation | x ⟩ | q ⟩ → | x ⟩ | q ⊕ ⟨ s , x ⟩⟩ . Output: • The hidden string s . Procedure:Step 1.
Perform state initialization on n + | . . . ⟩ → | ψ ⟩ |−⟩ Step 2.
Apply U s . Step 3.
Apply H ⊗ n to the first n qubits. Step 4.
Measure all qubits except the ancillary qubit.The final measurement will reveal the hidden string, s , with probability 1. Let us now delveinto the algorithm to see how this result is achieved. The entire circuit for the BV algorithm isrepresented in Figure 8. This circuit can be analyzed as follows, | ⟩ n | ⟩ H ⊗( n ) ⊗ H −−−−−−−→ √ n n − (cid:213) x = | x ⟩ ⊗ |−⟩ U s −−→ √ n n − (cid:213) x = (− ) ⟨ s , x ⟩ | x ⟩ ⊗ |−⟩ H ⊗ n −−−→ √ n n − (cid:213) x , y = (− ) ⟨ s , x ⟩⊕⟨ x , y ⟩ | y ⟩ ⊗ |−⟩ ≡ | s ⟩ ⊗ |−⟩ . (39)Here we have crucially used the identity for H ⊗ n given in Eq.(38). From the BV algorithm description in the previous section, we see that in any practical implementa-tion of this algorithm, the main ingredient is the construction of the oracle U s given a binary hidden string s . Let us see how this is done using an example binary hidden string “01”. Equation (40)below shows how the 3-qubit operator maps the 2 = x , x , q ), and the second line is the output binary vector. U = (cid:18)
000 010 100 110 001 011 101 111000 011 100 111 001 010 101 110 (cid:19) (40)This mapping, U : | x ⟩ | q ⟩ (cid:55)→ | x ⟩ |⟨ , x ⟩ ⊕ q ⟩ , is unitary. The next task in implementation is tolower the unitary matrix operator U to primitive gates available in the quantum computer’sarchitecture given in Eq (26). The time cost of applying these gates can be accessed from IBM’spublished calibration models [103] for the primitive hardware gates.In order to decompose arbitrary unitary matrices to the primitive gates, we need to first performa unitary diagonalization of the 2 ( n + ) × ( n + ) matrix using multi-qubit-controlled single-qubitunitary Given’s rotation operations. Such multi-qubit-controlled single-qubit operations can bedecomposed further to primitive gates using standard techniques [77] to the hardware primitivegates. Even after this step we will be left with arbitrary CNOT gates that do not respect the topologyof the underlying quantum processor. Since both ibmqx4 , ibmqx5 computers have restricted CNOTconnectivity between qubits, we will need to decompose the CNOT gates further into availableCNOT gates using the method discussed in the introductory section. As we saw in the Grover’salgorithm section, such decompositions will further degrade the quality of our results. As the overallprimitive gate counts scale as O( n ) for arbitrary n -qubit unitary operators, these decompositionsquickly becomes hard to do by hand. To address this we wrote a piece of software called QuantumNetlist Compiler (QNC) [89] for performing these transformations automatically. QNC can domuch more than convert arbitrary unitary operators to OpenQASM-2.0 circuits—it has specializedroutines implemented to generate circuits to do state-preparations, permutation operators, Graycoding to reduce gate counts, mapping to physical machine-topologies, as wells as gate-mergingoptimizations. Applying QNC tool to the unitary matrix U s gives us a corresponding quantum gatecircuit G s as shown in Figure 8 for a specific bit-string s .QNC generated black-box circuits with following gate-counts for the non-trivial 2-bit hidden-strings: “01”: 36, “11”: 38, “10”: 37, with estimated execution time for critical path ∼ µs on an idealmachine with all-to-all connection topology. For the 5-qubit ibmqx4 machine the correspondinggate-counts where: “01”: 42, “11”: 43, “10”: 41, with estimated execution time for critical path ∼ µs ,and for the 16-qubit ibmqx5 , they were: “01”: 66, “11”: 67, “10”: 67, with estimated execution time forcritical path ∼ µs . In all these cases, QNC used a specialized decomposition of U , considering itspermutation matrix nature, and therefore was able to reduce gate-counts by 5 × over the case whenthis special structure was ignored. Considering that the machines’ observed coherence times are ofthe order of ∼ µs , these QNC optimizations were crucial to the feasibility of the resulting score.The quantum score (circuit) generated by QNC for U for ibmqx4 is shown in Figure 9. A similarlyprepared score for 3-bit hidden-string “111” had a gate-count of 428 in the ibmqx4 architecturewith an estimated execution time of 153 µs which was well above the machines’ coherence times.We tested the QNC generated quantum scores for all non-trivial 1-qubit, 2-bit and 3-bit stringsusing the IBM-Qiskit based local simulator. In all cases, the simulator produced the exact hidden-string as the measurement result, 100% of the trials. We then tested all 1-bit and 2-bit strings onboth the 5-qubit ibmqx4 and the 16-qubit ibmqx5 machines. The results are shown in Figure 10.For 2-bit strings, the worst case noise was observed for the string “01” on ibmqx4 when the qubits q , q , q where used for x , x , y respectively. Since the estimated critical path times exceeded themachines’ coherence times for 3-bit strings, we did not run those scores on the physical machines. These times are estimated using the data available from IBM at the time of writing. These values will change as thehardware improves. antum Algorithm Implementations for Beginners 23
Even for 2-bit strings, the scores were quite long, and the results were quite noisy even with 8192machine-shots.
Fig. 10. Results from running the BV algorithm for shots on -bit hidden-strings “01”, “10” and “11”respectively (left to right) on ibmqx4 . The y-axis here is the probability of obtaining the hidden string, whichtheoretically should be . Solving linear systems is central to a majority of science, engineering, finance and economicsapplications. For example, one comes across such systems while solving differential or partialdifferential equations or while performing regression. The problem of solving a system of linearequations is the following: Given a system A (cid:174) x = (cid:174) b , find (cid:174) x for a given matrix (cid:174) A and vector (cid:174) b . Herewe assume that A is a Hermitian matrix, in that it is self-adjoint. To represent (cid:174) x , (cid:174) b as quantumstates | x ⟩ , | b ⟩ , respectively, one has to rescale them as unit vectors, such that || (cid:174) x || = || (cid:174) b || =
1. Thus,one can pose the problem as finding | x ⟩ such that A | x ⟩ = | b ⟩ , (41)with the solution | x ⟩ being | x ⟩ = A − | b ⟩|| A − | b ⟩ || . (42) The quantum algorithm for the linear system was first proposed by Harrow, Hassidim, and Lloyd(HHL) [53]. The HHL algorithm has been implemented on various quantum computers in [11, 24,111]. The problem of solving for (cid:174) x in the system A (cid:174) x = (cid:174) b is posed as obtaining expectation value ofsome operator M with (cid:174) x , (cid:174) x † M (cid:174) x , instead of directly obtaining the value of (cid:174) x . This is particularlyuseful when solving on a quantum computer, since one usually obtains probabilities with respectto some measurement, typically, these operators are Pauli’s operators X , Y , Z . These probabilitiescan then be translated to expectation values with respect to these operators. Fig. 9. Quantum circuit for BV algorithm with hidden string “01” targeting the ibmqx4 architecture.
The main idea of the algorithm is as follows. Let { (cid:12)(cid:12) u j (cid:11) } and { λ j } be the eigenvectors andeigenvalues of A , respectively, with the eigenvalues rescaled such that 0 < λ j <
1. Then the state | b ⟩ , can be written as a linear combination of the eigenvectors { (cid:12)(cid:12) u j (cid:11) } , | b ⟩ = (cid:205) Nj = β j (cid:12)(cid:12) u j (cid:11) . The goalof the HHL algorithm is to obtain | x ⟩ in the form | x ⟩ = (cid:205) Nj = β j λ j (cid:12)(cid:12) u j (cid:11) . By decomposing A = R † Λ R ,the HHL algorithms in a nutshell involves performing a set of operations that essentially performsthe three steps: R † Λ R | x ⟩ = | b ⟩ Step1 = ⇒ Λ R | x ⟩ = R | b ⟩ Step2 = ⇒ R | x ⟩ = Λ − R | b ⟩ Step3 = ⇒ | x ⟩ = R † Λ − R | b ⟩ (43)This procedure requires us to find the eigenvalues of A . This can be done using a quantumsubroutine called phase estimation.
We will discuss this subroutine in some detail as it is a commoningredient in many quantum algorithms.
Phase estimation is a quantum subroutine that lets us find the eigenvalues of a unitary matrix U given the ability to apply it to a quantum register as a controlled gate. Let | u ⟩ be an eigenvectorof U such that, U | u ⟩ = e πiλ u | u ⟩ . Then the phase estimation subroutine effects the followingtransformation, | ⟩ | u ⟩ −→ (cid:12)(cid:12)(cid:12) ˜ λ u (cid:69) | u ⟩ . (44)Here ˜ λ u is an estimate for λ u . This subroutine makes use of an important transformation calledthe Quantum Fourier Transform (QFT) Quantum Fourier Transform.
The Discrete Fourier Transform (DFT) takes as an input a vector X of size N and outputs vector Y = W X where the
Fourier matrix W is defined by W = √ N . . . ω ω . . . ω N − ω ω . . . ω ( N − ) ... ... ... . . . ... ω N − ω ( N − ) . . . ω ( N − )( N − ) , where the ij -th element of the matrix is W ij = ω ij and ω is a primitive N -th root of one( ω N = O ( N ) operations, but, byusing the special structure of the matrix, the Fast Fourier Transform (FFT) does the multiplicationin only O ( N log N ) time. The algorithm is recursive and is illustrated on Figure 11. The QuantumFourier Transform (QFT) is defined as a transformation between two quantum states that aredetermined using the values of DFT (FFT). If W is a Fourier matrix and X = { x i } and Y = { y i } arevectors such that Y = W X , then the QFT is defined as the transformation Q FT (cid:32) N − (cid:213) k = x k | k ⟩ (cid:33) = N − (cid:213) k = y k | k ⟩ . (45)The implementation of the QFT mimics the stages (recursive calls) of the FFT, but implementseach stage using only n + ω j are done using n controlled phase gates. The circuit for n = antum Algorithm Implementations for Beginners 25 S. Dasgupta, C.H. Papadimitriou,and U.V. Vazirani
Here we have reproduced the diagram (from Section 2.6.4) showing how the classical FFT cir-cuit for M -vectors is composed of two FFT circuits for ( M/ -vectors followed by some simplegates. x x x ω j x y j + N / FFT N / FFT N / ... y j FFT M (input: (cid:11) ; : : : ; (cid:11) M − , output: (cid:12) ; : : : ; (cid:12) M − ) x N − x N − Let’s see how to simulate this on a quantum system. The input is now encoded in the m amplitudes of m = log M qubits. Thus the decomposition of the inputs into evens and odds,as shown in the preceding (cid:2)gure, is clearly determined by one of the qubits(cid:151)the least sig-ni(cid:2)cant qubit. How do we separate the even and odd inputs and apply the recursive circuitsto compute F F T M/ on each half? The answer is remarkable: just apply the quantum circuit QF T M/ to the remaining m (cid:0) qubits. The effect of this is to apply QF T M/ to the superpo-sition of all the m -bit strings of the form x (of which there are M/ ), and separately to thesuperposition of all the m -bit strings of the form x . Thus the two recursive classical circuitscan be emulated by a single quantum circuit(cid:151)an exponential speedup when we unwind therecursion! QFT M/ least signi(cid:2)cant bit m (cid:0) qubits QFT M/ H Let us now consider the gates in the classical FFT circuit after the recursive calls to
F F T M/ : the wires pair up j with M/ j , and ignoring for now the phase that is appliedto the contents of the ( M/ j ) th wire, we must add and subtract these two quantities to ob-tain the j th and the ( M/ j ) th outputs, respectively. How would a quantum circuit achievethe result of these M classical gates? Simple: just perform the Hadamard gate on the (cid:2)rstqubit! Recall from the preceding discussion (Section 10.5.1) that for every possible con(cid:2)gura-tion of the remaining m (cid:0) qubits x , this pairs up the strings x and x . Translating frombinary, this means we are pairing up x and M/ x . Moreover the result of the Hadamard gateis that for each such pair, the amplitudes are replaced by the sum and difference (normalizedby / p ) , respectively. So far the QFT requires almost no gates at all!The phase that must be applied to the ( M/ j ) th wire for each j requires a little morework. Notice that the phase of ω j must be applied only if the (cid:2)rst qubit is . Now if j is ... +- Fig. 11. Fast Fourier Transform circuit, where j denotes a row from the top half of the circuit and ω j denotesthat the corresponding value is multiplied by ω j . The plus and minus symbols indicate that the correspondingvalues have to be added or subtracted, respectively. H P ( π ) P ( π ) P ( π ) P ( π )• H P ( π ) P ( π ) P ( π )• • H P ( π ) P ( π )• • • H P ( π )• • • • H Fig. 12. A Quantum Fourier Transform circuit for five qubits ( n = ). The phase estimation procedure cleverly uses the QFT operator to estimate the eigenphases ofthe operator U . The circuit for performing phase estimation given in Fig. 13. Notice that the QFT isapplied in reverse. | ⟩ H · · · • QF T † . . . | ⟩ H • · · ·| ⟩ H • · · ·| u ⟩ / U U · · · U t Fig. 13. Quantum circuit for phase estimation.
The pseudocode for phase estimation is given in Algorithm 3. Notice that the algorithm alsoworks if the input state is not an eigenstate. The output in this case can be determined by expandingthe input state in terms of the eigenstates and then applying the linearity of quantum operations.
In the code, we have numbered the ancillary qubits from the top and C i U denotes the unitarycontrolled by the i th ancilla qubit acting on the main n qubit register. Algorithm 3
Phase estimation subroutine
Input: • Controlled unitaries C i U • An n qubit input state | ψ ⟩ = (cid:205) u ψ u | u ⟩ , where U | u ⟩ = e πiλ u | u ⟩ . Output: • (cid:205) u ψ u (cid:12)(cid:12)(cid:12) ˜ λ u (cid:69) | u ⟩ Procedure:Step 1.
Take t ancillary qubits initialized to zero and perform H ⊗ t on them to produce theuniform superposition state over them. for ≤ i < t doStep 2. Apply C t − i − U i end forStep 3. Apply
QF T † . Optional
Measure the ancillary qubits to get (cid:12)(cid:12)(cid:12) ˜ λ u (cid:69) | u ⟩ with probability | ψ u | The number of ancillary qubits used in the phase estimation algorithm will determine both itsrun-time and its accuracy. On the accuracy front, the number of ancillary qubits used is equal to thebit precision of ˜ λ u as the answer is stored in this register. The exact complexity of this subroutineis discussed in Ref. [77].Now we can discuss the HHL algorithm which makes use of the phase estimation procedure toperform a matrix inversion. The HHL algorithm requires three sets of qubits: a single ancilla qubit,a register of n qubits used to store the eigenvalues of A in binary format with precision up to n bits, and a memory of O ( log ( N )) that initially stores | b ⟩ and eventually stores | x ⟩ . Start with a state | ⟩ a | ⟩ r | b ⟩ m , where the subscripts a , r , m , denote the sets of ancilla, register and memory qubits,respectively. This subscript notation was used in [111], and we found it to be most useful in keepingthings clear. The HHL algorithm requires us to run the phase estimation procedure on the unitaryoperator e iA . The phases estimated would be approximations to the eigenvalues of A . The problemof applying the unitary operation e iA given the matrix A is called quantum simulation . There aremany algorithms in literature that tackle the problem of quantum simulation [16] [47] and that willnot be our focus in this section. We will explain the steps of the HHL algorithm below assumingthat the quantum simulation part is taken care of. We will also include some mathematical detailsin the pseudocode given in Algorithm 4 .These three steps are equivalent to the three steps shown in Eq. (43). The algorithm is probabilistic,we get | x ⟩ only if the final measurement gives | ⟩ . But this probability can be boosted using atechnique called amplitude amplification [21]. This technique is explained in detail in Section VII. Now we implement the HHL algorithm on a 2 × A = (cid:18) . . . . (cid:19) . Weuse four qubits for solving the system – one ancilla, one memory and two register qubits. For thiscase, the eigenvalues of A are λ = λ = √ (cid:18) − (cid:19) ≡ |−⟩ and antum Algorithm Implementations for Beginners 27 Phase estimation Post-processingQST on the memory qubit
H X XX FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). b FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). x Controlled rotation Inverse phase estimation FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). !( !( XX X H
Expectation values with Pauli X, Y, Zancillaregisterregistermemory
Fig. 14. Schematic of the circuit for the quantum algorithm for solving a 2 × λ j of A into the register in the binary form. Thesecond step involves controlled rotation of the ancilla qubit, so that the inverse of the eigenvalues λ j showup in the state. The third step is the inverse phase estimation to disentangle the system, and restores theregisters to | ⟩ . The memory qubit now stores | x ⟩ , which is then post-processed to get the expectation valueswith respect to the Pauli operators X , Y and Z . Algorithm 4
HHL algorithm
Input: • The state | b ⟩ = (cid:205) j β j (cid:12)(cid:12) u j (cid:11) • The ability to perform controlled operations with unitaries of the form e iAt Output: • The quantum state | x ⟩ such that A (cid:174) x = (cid:174) b . Procedure:Step 1.
Perform quantum phase estimation using the unitary transformation e iA . This mapsthe eigenvalues λ j into the register in the binary form to transform the system, | ⟩ a | ⟩ r | b ⟩ m → N (cid:213) j = β j | ⟩ a (cid:12)(cid:12) λ j (cid:11) r (cid:12)(cid:12) u j (cid:11) m . (46) Step 2.
Rotate the ancilla qubit | ⟩ a to (cid:114) − C λ j | ⟩ a + Cλ j | ⟩ a for each λ j . This is performedthrough controlled rotation on the | ⟩ a ancilla qubit. The system will evolve to N (cid:213) j = β j (cid:32)(cid:115) − C λ j | ⟩ a + Cλ j | ⟩ a (cid:33) (cid:12)(cid:12) λ j (cid:11) r (cid:12)(cid:12) u j (cid:11) m . (47) Step 3.
Perform the reverse of Step 1. This will lead the system to N (cid:213) j = β j (cid:32)(cid:115) − C λ j | ⟩ a + Cλ j | ⟩ a (cid:33) | ⟩ r (cid:12)(cid:12) u j (cid:11) m . (48) Step 4.
Measuring the ancilla qubit will give , | x ⟩ ≈ N (cid:213) j = C (cid:18) β j λ j (cid:19) (cid:12)(cid:12) u j (cid:11) , (49)if the measurement outcome is | ⟩ Fig. 15. Circuit implemented on IBM’s 5-qubit ibmqx4 quantum computer for the case with | b ⟩ set to | ⟩ andwith ⟨ Z ⟩ measurement. After implementing the circuit in Fig. 14 and setting the coupling map of the ibmqx4 architecture, Qiskit-sdk-py re-arranges the qubits to fit the mapping. This circuit represents the outcome ofthe re-arrangement which was implemented on the ibmqx4 quantum computer.Table 3. Comparison between theoretical and simulator values for the expectation values ⟨ X ⟩ , ⟨ Y ⟩ , ⟨ Z ⟩ . Tstands for theoretical and S stands for simulator. | b ⟩ T ⟨ X ⟩ S ⟨ X ⟩ T ⟨ Y ⟩ S ⟨ Y ⟩ T ⟨ Z ⟩ S ⟨ Z ⟩| ⟩ -0.60 -0.60 0.00 -0.027 0.80 0.81 | + ⟩ |−⟩ -1.00 -1.00 0.0060 0.000 -0.02 0.00 √ (cid:18) (cid:19) ≡ | + ⟩ , respectively. For this system, the three steps of the HHL algorithm, can be performedby the operations shown in Fig. 14. For the controlled rotation, we use a controlled U rotationwith θ = π for λ and θ = π / λ . This is done by setting C = λ and ϕ are set to zero in these controlled U rotations. Although the composer on Quantum Experiencedoes not have this gate, in IBM Qiskit-sdk-py, we use cu3 function for this purpose. Three casesare used for b: (cid:18) (cid:19) , √ (cid:18) − (cid:19) and √ (cid:18) (cid:19) . We post selected the states with | ⟩ in the ancilla qubit.The probabilities of these states are normalized such that their sum is one. Measurements withrespect to ⟨ X ⟩ , ⟨ Y ⟩ , ⟨ Z ⟩ can then be performed to obtain the expectation values. QASM code isoutput from Qiskit-sdk-py and then uploaded on to IBM Quantum Experience. Figure 15 showsthe equivalent composer circuit generated from QASM for the measurement in the computationalbasis (Z measurement).To first test our implementation of the algorithm, we ran nine cases on the local simulatorprovided by Qiskit-sdk-py – three b cases and three measurements with respect to the operators X , Y , Z , for each b case. The comparison between the theoretical expectation values ⟨ X ⟩ , ⟨ Y ⟩ , ⟨ Z ⟩ and the simulator values are shown in Table 3. The simulator expectation values and the theoreticalvalues match well. This shows that the implementation of the algorithm gives expected results.Similar expectation values were also seen using the simulator on IBM Quantum Experience insteadof the local simulator. We then ran the circuit on the quantum computer ibmqx4 . Fig. 16 shows acomparison between the simulator results and the results from the ibmqx4 with Z measurement onthe circuit. As can be seen from Fig. 16, the results from the actual run do not give the expectedanswer as seen in the simulator results. We remark that recent modifications to the algorithm [22,101] can in some cases allow for larger scale and more accurate implementations on noisy quantumcomputers. The integer factorization problem asks, given an integer N as an input, to find integers 1 < N , N < N such that N = N N . This problem is hardest when N and N are primes with roughly the antum Algorithm Implementations for Beginners 29 . . . . . . P r o b a b ili t y IBM QX Simulator . . . . . . P r o b a b ili t y ibmqx4 Run Fig. 16. Results of the circuit with Z measurement (computational basis measurement) from the actual runand the simulator on a ibmqx4 . 4096 shots were used for both the cases. same number of bits. If n denotes the number of bits of N , no algorithm with polynomial in n timecomplexity is known. The straightforward algorithm that tries all factors from 2 to √ N takes timepolynomial in N , but exponential in n . The most efficient known classical algorithm has runningtime O (cid:18) exp (cid:18) (cid:113) n ( log n ) (cid:19)(cid:19) [81]. In practice, integers with 1000 or more bits are impossible tofactor using known algorithms and classical hardware. The difficulty of factoring big numbers isthe basis for the security of the RSA cryptosystem [86], one of the most widely used public-keycryptosystems.One of the most celebrated results in quantum computing is the development of a quantumalgorithm for factorization that works in time polynomial in n . This algorithm, due to Peter Shorand known as Shor’s algorithm [93], runs in O ( n log n ) time and uses O ( n log n log log n ) gates.The first experimental implementation of this algorithm on a quantum computer was reported in2001, when the number 15 was factored [106]. The largest integer factored by Shor’s algorithm sofar is 21 [73].In this section we describe Shor’s algorithm and its implementation on ibmqx4 Reducing factorization to period finding.
One way to factor an integer is by using modularexponentiation. Specifically, let an odd integer N = N N be given, where 1 < N , N < N . Pickany integer k < N such that gcd ( k , N ) =
1, where gcd denotes the greatest common divisor. Onecan show that there exists an exponent p > k p ≡ ( mod N ) . Recall that, by definition, x ≡ y ( mod m ) if and only if m divides x − y . Assume that p is the smallest such number. If wefind such p and p is even, then, by the definition of the modulo operation, N divides k p − = ( k p / − )( k p / + ) . But since the difference between n = k p / + n = k p / − n and n have no commonfactor greater than 2. Moreover, both numbers are nonzeros by the minimality of p . Since N = N N was assumed to be odd, then N is a factor of either n or n . Assume N is a factor of n . Since N is also a factor of N , then N divides both n and N and one can find N by computing gcd ( n , N ) .Hence, if one can compute such a p , one can find the factors of N efficiently as gcd can be computedin polynomial time.In order to find p , consider the modular exponentiation sequence A = a , a , . . . , where a i = k i ( mod N ) . Each a i is a number from the finite set { , . . . , N − } , and hence there exists indices q and r such that a q = a r . If q and r are the smallest such indices, one can show that q = A isperiodic with period r . For instance, for N =
15 and k =
7, the modular exponentiation sequence is1 , , , , , , , , , . . . with period 4. Since the period 4 is an even number, we can apply theabove idea to find7 mod 15 ≡ ⇒ − ≡ ⇒ ( − )( + ) mod 15 ≡ ⇒
15 divides 48 · , which can be used to compute the factors of 15 as gcd ( , ) = ( , ) = A is, however, not classically easier than directly searching forfactors of N , since one may need to check as many as √ N different values of A before encounteringa repetition. However, with quantum computing, the period can be found in polynomial time usingthe Quantum Fourier Transform (QFT). The QFT operation was introduced earlier during ourdiscussion of phase estimation.The property of the QFT that is essential for the factorization algorithm is that it can “compute”the period of a periodic input. Specifically, if the input vector X is of length M and period r , where r divides M , and its elements are of the form x i = (cid:40)(cid:112) r / M if i mod r ≡ s s < r , and Q FT (cid:16)(cid:205) Mi = x i | i ⟩ (cid:17) = (cid:205) Mi = y i | i ⟩ , then y i = (cid:40) /√ r if i mod M / r ≡
00 otherwisei.e., the output has nonzero values at multiples of M / r (the values (cid:112) r / M and 1 /√ r are used fornormalization). Then, in order to factor an integer, one can find the period of the correspondingmodular exponentiation sequence using QFT, if one is able to encode its period in the amplitudesof a quantum state (the input to QFT).A period-finding circuit for solving the integer factorization problem is shown in Fig 17 [34].The first QFT on register A produces an equal superposition of the qubits from A , i.e., the resulting Slide 12
U N C L A S S I F I E D
Period-finding algorithm • Given a coprime 𝑘 of 𝑁 , find 𝑝 s.t. 𝑘 : ≡ 1 mod 𝑁 • Period-finding circuit
S. Dasgupta, C.H. Papadimitriou,and U.V. Vazirani
Figure 10.6
Quantum factoring. √ M ! M − a =0 "" (cid:66) , (cid:1) √ M ! M − a =0 "" (cid:66) , (cid:1)(cid:1) (cid:71)(cid:1) (cid:9) (cid:66) (cid:10) f ( i ) = x i mod N QFT M QFT M measure Let n = log N be the number of bits of the input N . The running time of the algorithmis dominated by the N = O ( n ) repetitions of step 3. Since modular exponentiation takes O ( n ) steps (as we saw in Section 1.2.2) and the quantum Fourier transform takes O ( n ) steps,the total running time for the quantum factoring algorithm is O ( n log n ) . 𝑘 " 𝑀/𝑝𝑘 & 𝑀/𝑝 𝑀/𝑝
GCD . . . 𝑚 qub i t s 𝑛 qub i t s r e g i s t e r 𝐴 r e g i s t e r 𝐵 m ea s u r e 𝑘 k 𝑀/𝑝
Fig. 17. Illustration of the period-finding circuit, where m = n and M = m . state is 1 √ M M (cid:213) i = | i , ⟩ . antum Algorithm Implementations for Beginners 31 Next is a modular exponentiation circuit that computes the function f ( i ) = x i ( mod N ) on thesecond register. The resulting state is 1 √ M M (cid:213) i = | i , f ( i )⟩ . Before we apply the next QFT transform, we do a measurement of register B . (By the principle ofdeferred measurement [77] and due to the fact that register A and B don’t interact from that pointon, we don’t have to actually implement the measurement, but it will help to understand the finaloutput.) If the value measured is s , then the resulting state becomes1 (cid:112) M / r M (cid:213) i = f ( i ) = s | i , s ⟩ , where r is the period of f ( i ) . In particular, register A is a superposition with equal non-zeroamplitudes only of | i ⟩ for which f ( i ) = s , i.e., it is a periodic superposition with period r . Given theproperty of QFT, the result of the transformation is the state1 √ r r (cid:213) i = | i ( M / r ) , s ⟩ . Hence, the measurement of register A will output a multiple of M / r . If the simplifying assumptionthat r divides M is not made, then the circuit is the same, but the classical postprocessing is a bitmore involved [77].Period finding can also be viewed as a special case of phase estimation. The reader may referNielsen and Chuang [77] for this perspective on period finding. We implemented the algorithm on ibmqx4 , a 5-qubit quantum processor from the IBM QuantumExperience, in order to factor number 15 with x =
11. The circuit as described on Figure 17requires 12 qubits and 196 gates, too large to be implemented on ibmqx4 . Hence, we used anoptimized/compiled version from [106] that uses 5 qubit and 11 gates (Fig 18). | ⟩ H P ( π ) H •| ⟩ H H • •| ⟩ H • • P ( π ) P ( π )| ⟩| ⟩ Fig. 18. Circuit for Shor’s algorithm for N = and x = . The results from the measurements are shown on Figure 19.The periods found by the simulator are p =
0, which is ignored as a trivial period, and p = M =
8, we can conclude that r divides M / p = / =
2, hence r = ( x r − ) = ( − ) = ( − )( + ) = · . By computing gcd ( , ) = ( , ) =
3, we find the factors of 15.
Fig. 19. Output from the circuit from Figure 18 implemented on the simulator (left) and ibmqx4 (right).
The output from ibmqx4 finds the same periods 0 and 4 with the highest probabilities, butcontains much more noise.
In this section we will discuss another quantum algorithm that makes use of the QFT operation. Inthis section we will also introduce a subroutine called the
Hadamard test , which lets us computematrix elements of unitary operators. But first, we will require some knowledge of group theory tounderstand the problem being tackled here. This section follows the work of Jordan in Ref. [59].A
Group ( G , · ) or ( G ) is a mathematical object defined by its elements ( д , д , . . . ) and an operationbetween elements ( · ), such that these four properties are satisfied.(1) Closure: for any two group elements, the defined group operation produces another element,which belongs to the group (for ∀ д i , д j ∈ G , д i · д j = д k ∈ G ).(2) Associativity: for ∀ д i , д j , д m ∈ G , д i · (cid:0) д j · д m (cid:1) = (cid:0) д i · д j (cid:1) · д m .(3) Identity element: e ∈ G , such that e · д i = д i · e = д i .(4) Inverse element: for ∀ д i ∈ G , there exists д p , such that д i · д p = д p · д i = e . antum Algorithm Implementations for Beginners 33 A group with a finite amount of elements n is called a finite group with order n , while a groupwith an infinite amount of elements is an infinite group. In this section, we will discuss quantumalgorithms to solve certain problems related to finite groups. As before, we will also implementthem on the IBM machines. Some examples of groups are given below. Example 1A . Abelian group A n with n elements: 0 , , . . . , n −
1, and the group operation additionmodulo n : д i · д j = ( i + j ) mod ( n ) . For instance, for n = a = a = a =
2. Then, a · a = ( ) = = a , a · a = ( ) = = a , etc . The identity element is a = a − i = a n − i . This group is called Abelian orcommutative, because in addition to the four group properties, it has a property of commutativity: a i · a j = a j · a i for ∀ a i , a j ∈ A n . Example 1S . Symmetry group S n with n ! group elements, each is a permutation of n objects: [ , .., n ] , [ , .., n ] , . . . , [ n , n − .., , ] . Consequent application of two permutations is a groupoperation. For instance, for group S : ( e , p ) we have two objects a and b . The identity element e isno permutation: ab → ab , while one permutation p is the second group element: ab → ba . Then, p · p = e , and p − = p . Only S and S are Abelian groups. For n ≥ S n are not commutative. Let uswrite elements of group S as a permutation of elements 123 in the next order: [ ] → [ ] , [ ] , [ ] , [ ] , [ ] , [ ] . Then s · s = s , while s · s = s .While group definition is quite simple, it is not straightforward how to operate with groupelements in general, especially when defined operations between them is not trivial and/or thegroup order, n , is large. In this case, it is helpful to apply the representation theory to the group.The idea is simple: if we can map a group of unknown objects with nontrivial operations to thegroup of known objects with some trivial operations, we can gain some information about theunknown group. In general, we introduce a function applied to a group element: ρ ( д i ) , which doesthis mapping between two groups. Such function defines the group representation of G if for ∀ д i , д j ∈ G , ρ ( д i ) ∗ ρ ( д i ) = ρ ( д i · д j ) , where ( ∗ ) can be a different operation from ( · ). Example 2A . Representation of Abelian group A n : a j → ρ ( a j ) = e i π j / N , where the originaloperation ( + mod ( n ) ) is substituted by the new operation of multiplication. Note that the group S can be represented in the same way as A . Example 2S . Representation of group S : s j → ρ ( s j ) =
1, where the original operation is againsubstituted by the new operation of multiplication. Such representation of the group S is trivial,since it does not carry any information about the group, however it satisfies the definition ofthe group representation. Moreover, [1,1, . . . ] is a trivial representation for any group. Anotherrepresentation of group S is, [ , , , − , − , − ] → [ s , s , . . . , s n ] , where we map odd permutationsto − S is not Abelian. One cannot constructa one-dimensional representation for group S which would retains all its properties. The smallestequivalent representation for S is two-dimensional. The multidimensional representations can beeasy understood when represented by matrices.Most useful representations are often ones which map a group to a set of matrices. When ρ ( д ) isa d ρ × d ρ matrix, the representation is referenced as a matrix representation of the order d ρ , while( ∗ ) is the operation of matrix multiplication. All representations of finite group can be expressedas unitary matrices given an appropriate choice of basis. To prove the last fact, we introduce aparticular representation called the regular representation .The regular representation of a group of N elements is a matrix representation of order N .We will explain the construction of the regular representation using the Dirac notation. First, weassociate with each element of the group д i a ket | д i ⟩ . This ket could simply be the basis state | i ⟩ ,since the elements of the group are numbered. This ensures that the kets associated with different group elements are orthonormal by construction, (cid:10) д i | д j (cid:11) = δ ij . This also ensures that the identityoperator can be expressed as (cid:205) Ni = | д i ⟩ ⟨ д i | . The regular representation of д k is then given by, R ( д k ) = N (cid:213) j = (cid:12)(cid:12) д k · д j (cid:11)(cid:10) д j (cid:12)(cid:12) . (50)The matrix elements of this representation are, R ij ( д k ) ≡ (cid:10) д i | R ( д k )| д j (cid:11) = ⟨ д i | д k · д j ⟩ . From thedefining properties of a group it can be easily seen that multiplying every element in the groupby the same element just permutes the elements of the group. This means that R ( д k ) matrices arealways permutation matrices and are hence unitary. We can prove that the regular representationis a representation using simple algebra, R ( д k ) · R ( д m ) = N (cid:213) i = N (cid:213) j = | д k · д i ⟩ ⟨ д i | д m · д j ⟩ (cid:10) д j (cid:12)(cid:12) , = N (cid:213) i = N (cid:213) j = (cid:12)(cid:12) д k · д m · д j (cid:11) ⟨ д i | д m · д j ⟩ (cid:10) д j (cid:12)(cid:12) , = N (cid:213) j = (cid:12)(cid:12) д k · д m · д j (cid:11)(cid:10) д j (cid:12)(cid:12) = R ( д k · д m ) . (51)Here we used orthogonality: ⟨ д i | д m · д j ⟩ = | д i ⟩ = (cid:12)(cid:12) д m · д j (cid:11) and 0 otherwise, whichallowed us to swap these two states. Then, we used the same fact to calculate the sum over i . Belowwe give some explicit examples of regular representations. Example 3A . Regular representation of the Abelian group A , where each matrix element iscalculated using the result derived above R ij ( a k ) = ⟨ a i | a k · a j ⟩ : R ( a ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) , R ( a ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) , R ( a ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) , R ( a ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) . (52)Commutative property is conserved: R ( a i ) · R ( a j ) = R ( a j ) · R ( a i ) . Example 3S . Regular representation of the group S , where we use the same order of permutationsintroduced above ( [ ] → [ ] , [ ] , [ ] , [ ] , [ ] , [ ] ) R ( s ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) , R ( s ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) , R ( s ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) , (53) antum Algorithm Implementations for Beginners 35 R ( s ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) , R ( s ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) , R ( s ) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) . (54)Now we can finally explain the problem of calculating matrix elements of the group representa-tions, which is equivalent to the problem of calculating an expectation value of an operator A inrespect to the state | ψ ⟩ in quantum mechanics: ⟨ A ⟩ = ⟨ ψ | A | ψ ⟩ . Example 4A . Calculating matrix elements of the regular representation of the element a fromthe Abelian group A with respect to the state ψ which is the equal superposition of | a ⟩ and | a ⟩ .In operator form we find: ⟨ ψ | a | ψ ⟩ = ⟨ a | + ⟨ a |√ (cid:32) N − (cid:213) i = | a · a i ⟩⟨ a i | (cid:33) | a ⟩ + | a ⟩√ = ⟨ a | a · a ⟩⟨ a | a ⟩ + ⟨ a | a · a ⟩⟨ a | a ⟩ = . (55)It is quite obvious that if a quantum computer is capable of finding expectation values of aunitary operator, it will be able to solve the problem of finding the matrix elements of the regularrepresentation of a group element. This will consist of, at least, two stages: the first stage is thestate preparation, and the second is applying the unitary operator of the regular representation tothat state. The unitary operator of the regular representation of an element of any group G n can becreated using a combination of only two type of operations: qubit flip ( | ⟩ → | ⟩ ) and qubit swap( (cid:12)(cid:12) q j q i (cid:11) → (cid:12)(cid:12) q i q j (cid:11) ).Up to this point, we have only talked about the regular representation. The regular representationis quite convenient, it is straightforward to find for any group, it carries all the information about thegroup, and a corresponding unitary operator is easy to construct using standard quantum circuits.However, for groups with a large number of elements, it requires matrix multiplication between largematrices. So for many applications, instead of regular representations one is interested in what areknown as irreducible representations , which are matrix representations that cannot be decomposedinto smaller representations. Or in other words, every matrix representation (including the regularrepresentation) can be shown to be equivalent to a direct sum of irreducible representations, up toa change of basis. This lets us reduce the representation theory of finite groups into the study ofirreducible representations. The importance of irreducible representations in group theory cannotbe overstated. The curious reader may refer these notes by Kaski [60].A result from group theory ensures that the direct sum of all irreducible representations (eachhas different dimensions d ρ in general) where each irreducible representation appears exactly d ρ times is a block diagonal N × N matrix (the group has N elements). The Fourier transform pairover this group representation can be introduced by decomposing each irreducible representationover the group elements and vice versa . Moreover, the above defined direct sum of all irreduciblerepresentations can be decomposed as a regular representation conjugated by the direct and inverseFourier transform operators [59]. This result lets us find the the matrix elements of the irreduciblerepresentations given the ability to implement the regular representation. Fig. 20. Schematic diagram for the quantum algorithm
In this section we will describe an algorithm to find the matrix elements of irreducible represen-tations of a group given the ability to apply its regular representations to a quantum register ina controlled fashion. The quantum algorithm calculating matrix elements ⟨ ψ | U | ψ ⟩ of a unitaryoperator U is known as the Hadamard test, which is illustrated on Fig. 20. Algorithm 5
Hadamard test
Input: • The controlled unitary CU . • Input state | ⟩| ψ ⟩ . Output: • An estimate for the real part of ⟨ ψ | U | ψ ⟩ Procedure:Step 1.
Apply H to the ancilla. This produces the state, | ⟩ + | ⟩√ | ψ ⟩ Step 2.
Apply CU controlled on the ancilla. This produces the state, | ⟩ | ψ ⟩ + | ⟩ U | ψ ⟩√ Step 3.
Apply H to the ancilla again. This gives, | ⟩ (| ψ ⟩ + U | ψ ⟩) + | ⟩ (| ψ ⟩ − U | ψ ⟩)√ Step 4.
Measure the ancillary qubit. Repeat to estimate the probability of obtaining | ⟩ and | ⟩ . The ancilla qubit should be prepared as | ⟩− i | ⟩√ to calculate the imaginary parts of the matrix ele-ment. From the pseudocode, we can see that the probability of measuring | ⟩ is P = || | ψ ⟩ + U | ψ ⟩√ || = + Re ⟨ ψ | U | ψ ⟩ . Hence, we find: Re ⟨ ψ | U | ψ ⟩ = P −
1. The reader is encouraged to work out the samesteps for the imaginary part as well. antum Algorithm Implementations for Beginners 37
Fig. 21. Actual circuit implemented on IBM’s 5-qubit computer for calculating matrix elements of the regularrepresentation for the second element of the group S and A in respect to the state | ⟩ on the left and | ⟩ + | ⟩√ on the right. The expected probabilities to find a final state in the ground state are ( + )/ = . and ( + )/ = respectively. The results of the runs on the actual chip (on the top) and the simulator (onthe bottom) are presented on the right side of each circuit. With the Hadamard test algorithm, the problem of calculating matrix elements of an arbitraryunitary operator is reduced to the problem of effectively implementing it as a controlled gate. Forthe regular representation of any group U , where unitary operator is an N x N square matrix withonly one non-zero element equal to 1 in each row, this implementation can be done for any groupas a combination of CNOT and Z gates.At the same time solutions for the direct sum of all irreducible representations U , which canbe decomposed as U ( д ) = F U ( д − ) F − , exists for any group whose Fourier transform over thatgroup can be effectively implemented using quantum circuits. Quantum circuits for the Fouriertransform are already known for the symmetric group S ( n ) [12], the alternating group A n , andsome Lie groups: SU ( n ) , SO ( n ) [9], while solutions for other groups, hopefully, will be found in thefuture. For Abelian groups this Fourier transform implementation can be efficiently done using theQFT circuit that was discussed in the earlier sections. For non-Abelian groups the implementationis trickier and efficient implementations are not universally known. The actual gate sequence that we implemented on IBM’s 5-qubit computer ( ibmq_essex ) and IBM’squantum simulator to find matrix elements of the regular representation of the second element ofthe group S is shown in Fig. 21. The matrix for this representation is simply a X gate. Hence, wehave to use one CNOT gate and two Hadamard gates, plus some gates to prepare state | ψ ⟩ fromthe state | ⟩ . We mapped the ancilla qubit to the actual machine q qubit instead of q , because ofthe machine architecture, where the first qubit can control the zero qubit but not vice versa . Wecould have used the original qubit sequence as in Fig. 20, by realizing the CNOT gate as a swappedCNOT and four Hadamard gates, but this would add more gates to the circuit and potentially morecomputational errors rather than just a virtual swap of the qubits.For the irreducible representation of the same element of the group A , the element is representedby the Z gate. Hence the Hadamard test requires implementing a controlled- Z gate, which is notavailable as an actual gate on the IBM Quantum Experience. However, it can be constructedusing two Hadamard and one CNOT gates as shown in Fig. 22. Notice that the Hadamard gateis actually the Fourier transform operator over group S and A , while the X gate is a regularrepresentation operator, as we mentioned earlier. Hence, such controlled- Z gate representation Fig. 22. Actual circuit implemented on IBM’s 5-qubit computer for calculating matrix elements of the directsum of the irreducible representations for the second element of the group S and A with respect to thestate | ⟩ on the left and | ⟩ on the right. The expected probabilities to find a final state in the ground stateare ( + )/ = and ( − )/ = respectively. The results of the runs on the actual chip (on the top)and the simulator (on the bottom) are presented on the right side of each circuit. is in fact the decomposition of the irreducible representation to the regular representation usingFourier transform over that group. Matrix multiplication is one of the most important linear algebra subroutines. Most scientificcomputing algorithms use matrix multiplication in one form or another. Therefore, the compu-tational complexity of matrix multiplication is a subject of intense study. For two n × n matricesthe computational complexity of the naive matrix multiplication algorithm is O ( n ) A faster algo-rithm for matrix multiplication implies a considerable performance improvement for a variety ofcomputational tasks. Strassen [100] first showed that two n × n matrices can be multiplied in time O ( n + α ) ( α < α ≈ .
376 was found by Coppersmith andWinnograd [32]. Despite that, it remains an open problem to determine the optimal value of α . Theso-called problem of matrix verification is defined as, verifying whether the product of two n × n matrices is equal to a third one. So far the best classical algorithm can do this with high probabilityin time proportional to n [45].Ref. [4] was the first to study matrix verification for quantum computation. The authors use aquantum algorithm based on Grover’s algorithm to verify whether two n × n matrices equal a thirdin time O ( n / ) , thereby improving the optimal classical bound of Ref. [45]. Ref. [23] presents aquantum algorithm that verifies a product of two n × n matrices over any integral domain withbounded error in worst-case time O ( n / ) and expected time O ( n / / min ( w , √ n ) / ) , where w is thenumber of wrong entries. This further improves the time performance O ( n / ) from Ref. [4]. We briefly sketch the quantum algorithm from Ref. [4]. The presentation here follows from Ref. [99].Before we discuss this algorithm we introduce the concept of amplitude amplification.
Many real world algorithms are probabilistic, i.e., independent runs of the algorithm on the sameinput will not necessarily give the same output. This is because the algorithm uses some source ofrandomness during its execution. Most quantum algorithms are probabilistic owing to the inherentrandomness present in quantum mechanics. antum Algorithm Implementations for Beginners 39
Suppose that the job of our probabilistic classical/quantum algorithm is to return one of a specificset of states. Assume that we also have at our disposal an oracle that can identify the members ofthis set from other states. An example of this would be polynomial root finding. The set of states inthis case would correspond to the roots of the polynomial. Our algorithm should return one of theroots of the polynomial and we can verify if an output is a root by plugging it in to the polynomial.Obviously the algorithm is good only if it can return a state that is a member of this set withhigh probability. But how high of a success probability is good enough? For practical reasons wewould like the probability of success to be a constant. That is, it should be a value independent ofthe problem size and other parameters in the problem. Any constant value between 0 and 1 wouldwork here. The value is usually used in literature.But often algorithms won’t succeed with constant probability and their success provability willdiminish with growing input size. In that case, how can we boost the success probability to thedesired level? The classical answer to this question is to repeatedly run the algorithm until wesucceed, i.e., till the algorithm outputs a state from the specific set of states that we want. If thealgorithm initially had a success probability of p , after O ( p ) repetitions we are guaranteed to findthe desired state with constant probability.For quantum algorithms we can do something better. Let U be a quantum algorithm and supposethat we want this algorithm to return a state from the subspace spanned by the orthogonal states, {| u i ⟩} . Let P be the projection operator onto this subspace, P = (cid:205) i | u i ⟩ ⟨ u i | . The oracle we have isthen, O = I − P . This oracle will mark the states in the desired subspace. The success probability ofour algorithm is p = (cid:10) . . . | U † PU | . . . (cid:11) . In this scenario we can use amplitude amplification toboost the success probability to a constant with only O ( √ p ) repetitions. This is a quadratic speedupover the classical strategy.Essentially, amplitude amplification is a generalization of Grover search described in Section II .In Grover search we repeatedly apply the Grover operator, G = ( | ψ ⟩ ⟨ ψ | − I ) O , where | ψ ⟩ is theuniform superposition state. Amplitude amplification uses a more general operator, G U = U ( | ⟩ ⟨ | − I ) U † O . (56)To get the desired result we apply this to the U | . . . ⟩ state O ( √ p ) times. Notice that the originalGrover search is a specific case of amplitude amplification with U = H ⊗ . . . ⊗ H . In that case, theprobability of getting the marked state in | ψ ⟩ is N so we run the algorithm for O (√ N ) steps. Thereader is referred to Ref. [21] for more details on amplitude amplification.The matrix product verification procedure uses amplitude amplification as its outer loop. Thealgorithm first splits the full matrix verification problem into smaller matrix verification problems.Then it uses amplitude amplification to search if one of these verifications fail. Each of these smallerverification steps also use a Grover search to look for disagreements. So the complete algorithmuses one quantum search routine nested inside another quantum search routine. This is a commonstrategy used while designing quantum algorithms to improve query complexity. The full algorithmis sketched below.The number of qubits and the circuit depth required for this algorithm is too large for it to besuccessfully implemented on the IBM machines. But at the heart of this algorithm is the Groversearch procedure, which we have already discussed and implemented in Section II Algorithm 6
Matrix product verification [4] [99]
Input: • n × n matrices A , B , C . Output: • Verifies if AB = C Procedure:Step 1.
Partition B and C into √ n submatrices of size n ×√ n . Call these B i and C i respectively. AB = C if and only if AB i = C i for all i . Step 2.
Use amplitude amplification over i on these steps: Step 2a.
Choose a random vector x of dimension √ n . Step 2b.
Compute y = B i x and z = C i x classically Step 2c.
Verify equation Ay = z by Grover search. Search for a row j such that ( Ay − z ) j (cid:44) The group isomorphism problem, originally identified by Max Dehn in 1911 [35], is a well-knowndecision problem in abstract algebra. Simply stated, it asks whether there exists an isomorphismbetween two finite groups, G and G ′ . Which, according to the standpoint of group theory, meansthat they are equivalent (and need not be distinguished). At the end of Section 5 we saw an exampleof two isomorphic groups, S and A . These two are the same group in terms of how the groupoperation works on the group elements, but are defined in different ways. More precisely, twogroups, ( G , ·) and ( G , ∗) are called isomorphic if there is a bijection, f : G → G , between themsuch that, f ( д · д ) = f ( д ) ∗ f ( д ) . To solve this problem using a quantum algorithm, we assume that each element can be uniquelyidentified by an arbitrary bit-string label. We also assume that a so-called group oracle can be usedto return the product of multiple elements. That is, given an ordered list of group-element labels,the oracle will return the product label. In practice, this means that we must be able to construct aquantum circuit to implement U a : | y ⟩ → | ay ⟩ , for any a ∈ G .In this section, we will focus our attention on the abelian group isomorphism problem, becauseit can be solved using a generalization of Shor’s algorithm [94]. As we saw before, abelian simplymeans that the operation ( · ) used to define the group is commutative, such that a · b = b · a , for a , b ∈ G . Although Shor’s approach is specifically intended to leverage a quantum period-findingalgorithm to reduce the time-complexity of factoring, the procedure effectively solves the groupisomorphism problem over cyclic groups. Using this relationship, Cheung and Mosca [25] havedeveloped a theoretical quantum algorithm to solve the abelian group isomorphism problem bycomputing the decomposition of a given group into a direct product of cyclic subgroups. The procedure presented in Algorithm 7 assumes the fundamental theorem of finite abelian groups,that they can be decomposed as a direct sum of cyclic subgroups of prime power order. Thisdecomposition can then be used to test if an isomorphism exists between two groups.Since the procedure in Algorithm 7 is mostly classical, we shall treat the task of finding thegenerators of the hidden subgroup in
Step 1 as the most critical for us to explore. This task iscommonly referred to as the hidden subgroup problem (HSP). This means that, given a function д that maps a finite group A onto a finite set X , we are asked to find a generating set for the antum Algorithm Implementations for Beginners 41 Algorithm 7
Decompose( a , . . . , a k , q ), of Cheung and Mosca [25] Input: • A generating set { a , . . . , a k } of G . • The maximum order, q , of the generating set. Output: • The set of elements д , . . . , д l from group G , with l ≤ k . Procedure:Step 1.
Define д : Z kq → G by mapping ( x , . . . , x k ) → д ( x ) = a x · · · a x k k .Find generators for the hidden subgroup K of Z kq as defined by function д . Step 2.
Compute a set y , . . . , y l ∈ Z kq / K of generators for Z kq / K . Step 3.
Output the set { д ( y ) , . . . , д ( y l )} .subgroup K . For K to be the so-called hidden subgroup of A , we require that д is both constant anddistinct on the cosets of K . On a quantum computer, this problem can be solved using a number ofoperations that is polynomial in log | A | , in addition to one oracle evaluation of the unitary transform U | a ⟩ | h ⟩ = | a ⟩ | h ⊕ д ( a )⟩ . The general procedure needed to complete Step 1 of algorithm 7 isdescribed in algorithm 8.
Algorithm 8
Solution to the hidden subgroup problem (for finite abelian groups). Based on Ref. [77]
Input: • Two quantum registers. • Elements of the finite abelian group A (or the generating set). • A function д , such that д : A → X , with a ∈ A and h ∈ X . Output: • The generating set for the hidden subgroup K . Procedure:Step 1.
Create initial state.
Step 2.
Create superposition between resisters.
Step 3.
Apply unitary operation ( U ) for function д ( a ) . → (cid:112) | A | (cid:213) a ∈ A | a ⟩ | д ( a )⟩ (57) Step 4.
Apply inverse Fourier transform. → (cid:112) | A | | A |− (cid:213) l = e πila /| A | | ˆ д ( l )⟩ (58) Step 5.
Measure the phase from first register. → l /| A | (59) Step 6.
Sample K from l / | A |.Like the period-finding approach used in quantum factorization in Section V, Algorithm 8is heavily based on the concept of phase estimation. Note that the Fourier transform in Eq. 58represents a ∈ A indexed by l . The key concept of the procedure is that | ˆ д ( l )⟩ has nearly zeroamplitude for all values of l , except those which satisfy Fig. 23. Basic phase-estimation quantum circuit needed to solve the general hidden subgroup problem inalgorithm 8. Here, | u ⟩ is an eigenstate of the unitary operator U . | K | = (cid:213) h ∈ K e − πilh /| A | , (60)and that knowledge of l can be used to determine both the elements and generating set of K .As discussed by Nielsen and Chuang [77], the final step in algorithm 8 can be accomplished byexpressing the phase as → e πila /| A | = M (cid:214) i = e πil i a i / p i . (61)for a i ∈ Z p i , where p i are primes, and Z p i is the group containing integers { , , . . . , p i − } withthe operator being addition modulo p i .The quantum circuit needed to solve the HSP is schematically illustrated in Fig. 23. This simplifiedcircuit includes steps 1-5 of algorithm 8, and makes it clear that all forms of the HSP (order-finding,period-finding, discrete logarithm, etc.) are extensions of quantum phase estimation. Since the generalized group isomorphism problem is somewhat complex, we will focus here on theimplementation of the HSP circuit fragment illustrated in Fig. 23. We also chose a specific instanceof the HSP: the problem of finding the period of a mod n . In Fig. 24, the basic outline of the codeneeded for this specific problem is illustrated using the python-based Qiskit interface.Like most instances of the HSP, one of the most challenging practical tasks of finding the periodof a mod n on a quantum computer is the implementation of the oracle. The details of the oracleare not explicitly shown in the Qiskit snippet, but for the required Ca mod 15 operations, one cansimply used the circuits developed by Markov and Saeedi [87]. The code in Fig. 24 also assumesthat a function q f t _ inv () will return the gates for an inverse quantum Fourier transform, and that aclassical continued fractions algorithm can be used to convert the end result (a phase) to the desiredinteger period.Although the specific procedure outlined in Fig. 24 can be directly implemented using the IBMQiskit interface, the resulting QASM code is not expected to lead to accurate results on the IBMX4(or IBMX5). This is because the generated circuit is long enough for decoherence error and noise toultimately dominate the measured state. In other words, the physical hardware requires further antum Algorithm Implementations for Beginners 43 def findperiod(a, N=15, nqubits1, nqubits2): for j in range(nqubits1): cmod15.h(qr1[j])cmod15.x(qr2[nqubits2-1]) for p in range(nqubits1): for i in range(n_qr1): cmod15.measure(qr1[i], cr1[i]) Fig. 24. Simple implementation of the quantum period-finding algorithm in Qiskit optimization to reduce the number of gates used between the initial state preparation and the finalmeasurement.
Big data analysis often involves large numbers of multidimensional data points. Understandingtheir structure can lead to insights into the processes that generated them. Data clustering isclosely related to spatially connected components. Other features such as holes and voids andtheir higher dimensional analogs that characterize the distributions of data points are useful forunderstanding their structure. Persistent homology connects data points across scales to revealthe most enduring features of datasets. Methods from algebraic topology are employed to buildsimplicial complexes from data points, and the topological features of these simplicial complexesare extracted by linear algebraic techniques. However, such an investigation on a set of n points
Fig. 25. Examples of simplices, simplicial decomposition of a topological space X , relationships among groups C p (chains), Z p (cycles), and B p (boundaries) under the action of boundary homomorphisms ∂ p , and theexample of the torus. leads to storage and computational costs of O ( n ) as there is a combinatorial explosion in thenumber of simplices generated by n points. Thus representational and computational efficiency hasto be greatly enhanced for viability. Quantum algorithms provide such efficiency by superposing2 n simplex states with only n qubits and implementing quantum parallel computations. The studyof such a quantum algorithm, proposed by Lloyd et. al [68] is the focus of this section.Data points P = { p , . . . , p n − } can be envisaged as vertices of a simplicial decomposition of asubset X . An oriented k − simplex σ k = [ p j , . . . , p j k ] , ≤ j < j , . . . , < j k ≤ n − , is the convexhull of k + ϵ of vertex connectivity capture enduring topological featuresis the goal of Persistent Homology [68]. The numbers of various topological features at any scaleare obtained from algebraic structures involving the simplices.Define the k th chain group C k as the set of all formal integer linear combinations of k -simplices: C k = { (cid:205) i a i σ ik | a i ∈ Z } . C k is an abelian group generated by the k -simplices. Further, defineboundary operators ∂ k : C k → C k − between chain groups as group homomorphisms whose actionon a k -simplex σ k = [ p j , . . . , p j k ] is given by ∂ k σ k = (cid:205) ki = (− ) i [ p j , . . . , p j i − , p j i + , . . . , p j k ] (i.e.,the ith vertex is omitted from σ k , 0 ≤ i ≤ k , to get the k + i th boundary ( k − k -chain c ik ∈ C k gives rise to a ( k − ) -chain c ik − ∈ C k − . A chain c ∈ C k such that ∂ k c =
0, where 0 is the null chain, is called a k -cycle. Also, ∂ k ∂ k + ≡
0. That is to say, theboundary of a boundary is the null chain 0, since the boundary of every k + k -cycle. Z k = Ker ( ∂ k ) is the subgroup of C k consisting of all k -cycles, and B k = Imaдe ( ∂ k + ) is the subgroupof C k consisting of boundaries of all ( k + ) -chains in C k + . Clearly, B k ⫅ Z k . The relationshipsbetween chain groups, cycles and boundaries as established by the boundary homomorphisms isillustrated in Fig. 25(c). The k th Betti number β k of a topological space X is defined as the numberof linearly independent k -cycles that are not boundaries of ( k + ) -chains, and characterizes thetopological features at dimension k . For instance, β is the number of connected components of X , β is the number of 1-dimensional holes, β is the number of voids, and so on. The k th HomoloдyGroup of X is defined as the quotient group H k ( X ) = Z k ( X )/ B k ( X ) , whereby β k is the number ofgenerators of H k ( X ) .Equivalently, the k th Betti number β k is the dimension of the kernel of the combinatorialLaplacian operator, ∆ k = ∂ † k ∂ k + ∂ k + ∂ † k + , β k = dim ( Ker ( ∆ k )) . This allows the computation ofBetti numbers by finding the null space of a linear transformation. Lloyd’s quantum algorithm [68]diagonalizes the Laplacian to compute Betti numbers. antum Algorithm Implementations for Beginners 45 Fig. 26. Grover’s Algorithm circuit implemented on the 5 qubit quantum computer showing 3 qubits beingused with the multiple solution version of Grover’s Algorithm. U3 gates are used to input the scaled distancesbetween points.Fig. 27. Quantum Phase Estimation Algorithm circuit implemented on the 5 qubit quantum computer showinghow the quantum density matrix implemented on qubits 0, 1, and 2 would be applied to obtain a classicalmeasurement on qubit 3.
A quantum algorithm for calculating Betti Numbers is presented in [68]. The algorithm usesGrover’s search combined with phase estimation to find the dimension
Ker ( ∆ k ) . Grover’s algorithmis used to prepare a suitable initial state for the phase estimation. We will demonstrate how phaseestimation can be used to estimate the dimension of the kernel of an eigenspace. Suppose that wehave an N × N unitary operator U = e i π H on which we will apply phase estimation. Let (cid:12)(cid:12) u j (cid:11) and e i π λ j be the eigenvectors and eigenvalues of U . Now given a starting state √ N (cid:205) Nj = (cid:12)(cid:12) u j (cid:11) we knowthat the phase estimation subroutine will effect the following transformation,1 √ N N (cid:213) j = (cid:12)(cid:12) u j (cid:11) | ⟩ → √ N N (cid:213) j = (cid:12)(cid:12) u j (cid:11) (cid:12)(cid:12)(cid:12) ˜ λ j (cid:69) , (62)where ˜ λ j are approximations to the original eigenphases. Now consider a measurement on theancillary register that stores these eigenphases. If one of the λ j were zero, we can see that theprobability of measuring | ⟩ on the second register is equal to dim ( Ker ( H )) N . Moreover the probabilityof measuring any (cid:12)(cid:12)(cid:12) ˜ λ j (cid:69) will similarly be related to the dimension of its eigenspace. So by estimatingthese probabilities, we can figure out the dimensions of the eigenspaces. Notice that the performanceand correctness of the procedure will depend on the precision of ˜ λ j . This will in turn depend onthe number of ancillary qubits used in the procedure. For this procedure to work it was crucial that we started with the uniform superposition of all the eigenstates. This is a correct but naiveway to go about the problem especially if the dimension of the null space is exponentially smallcompared to the size of the matrix. But, this technique will work equally well if the input to theprocedure was a classical mixture of some of the eigenstates such that the probability of the nullstates in the said mixture was related to the dimension of the null space. This would let us recoverthe dimension of the null space from the measurement probabilities. The algorithm to find Bettinumbers uses such a generalization of the naive procedure illustrated above.We will roughly sketch the full algorithm without going into the details. We associate with eachsimplex σ k a computational basis state | σ k ⟩ such that the 1s in | σ k ⟩ correspond to the points chosenin σ k . Then the algorithm roughly goes as follows:(1) First we construct a uniform superposition over all the simplex states in a set denoted by S ϵk . The precise definition of the set is not important to us now. The crucial fact is that thereexists an easily computable function that determines the membership of a simplex to this set.This requires an additional input of scaled distance between points. This function can thenbe used as an oracle in Grover search to compute the desired state.(2) Then this state is modified to produce an equiprobable mixture over all the simplicies in S ϵk . This mixture is represented as a quantum density matrix ρ . Readers unfamiliar with theconcept of density matrices should read the section on quantum tomography.(3) Now perform phase estimation on ρ to find the probabilities of an eigenvalue to be multipliedwith the number of simplices to obtain input for the calculation of a Betti numberWorking with only 5 qubits implies that the largest number of points n that could be processedat once is constrained by n ( n − )/ ≤
5. Thus only 3 points at a time could be processed on the 5qubit quantum computer. In the implementation of Grover’s Algorithm is shown in Fig. 26, onlyone iteration of Grover’s algorithm is shown. The output of this part of the algorithm is a quantumdistribution of simplices.Calculating the quantum density matrix could not be accomplished by the IBM machine dueto the lack of Quantum RAM needed for the algorithm. Options considered to circumvent thisproblem included implementing a quantum algorithm for computing the outer product to forman 8x8 quantum density matrix. This was abandoned as the sheer size of quantum algorithmsto implement four qubit addition [107] was well beyond the 5 qubits available on the quantumcomputer. The Quantum Experience message boards’ suggestion to perform Grover’s algorithm64 times and reassemble the output into a density matrix was also not viable due to decoherence.Had a quantum density matrix been produced, phase estimation would have been applied to findthe probabilities of eigenvalues of the boundary operator. This would then be multiplied times thenumber of simplices and used as input to find the Betti Number. The phase estimation quantumcircuit for this purpose is shown in Fig. 27. Hence the main bottleneck here is seen to the thecoherence time of the computer.In order to check the coherence of the quantum 5 qubit computer a study was designed. All fivequbits were flipped in the first timestep and measurements were then taken place approximatelyevery five timesteps throughout the 74 available timesteps in the quantum composer. The quantumalgorithm applied is shown in Fig. 28 showing the use of the Idle gates for 5 timesteps after thequbits are flipped with the X gate.The data was collected for all the timesteps, processed into a form to evaluate the coherencepercentages for all individual qubits and for all qubits combined. The results are depicted in Fig. 29showing the decoherence rates with quantum composer timesteps. The coherence rates heremeasure the ‘quantumness’ of the qubits as detailed in Ref. [105]. Note that although the coherencerates are fairly high for individual qubits, the overall qubit coherence percentages are far less. This antum Algorithm Implementations for Beginners 47
Fig. 28. The quantum algorithm applied to estimate the Decoherence time of the 5 qubit quantum computeras implemented in the Quantum Composer to measure the decoherence after 5 timesteps. Note that thisproduces an optimistic estimate as the "id" quantum gates utilize minimal time whereas other gates, such asCNOT and U3 gates, could use more time.Fig. 29. Timesteps available with the Quantum Composer are shown on the x axis, ranging up to 74. Coherencepercentage is calculated for all individual qubits and is plotted on the y axis. Coherence percentages of all 5qubits combined is also shown on the y axis. Note that the coherence percentage rate falls below 50 percentbetween the 15th and the 20th timesteps. is because a single qubit decohering also decoheres the entire 5 qubit quantum computer. Thisshould be considered to determine how many qubits will actually be usable in an actual machine. Itis also interesting that qubit 3 seems to decohere at a faster rate than the other qubits past timestep15.
10 QUANTUM RANDOM WALKS10.1 Problem definition and background
Quantum algorithms for graph properties using the adjacency matrix (as part of an oracle) havebeen published for minimum spanning tree, shortest path, deciding if a graph is bipartite, detecting cycles, finding subgraphs (such as a triangle), maximal clique, and many more. Each typicallyinvolves the use of Grover’s search [52] with an oracle constructed from the adjacency matrix.But for some problems Grover’s algorithm is insufficient to achieve optimal query complexity. Insuch cases, a quantum random walk can sometimes be useful in reducing the query complexityof an algorithm further. An example of this is the quantum algorithm for element distinctness byAmbainis [5]. Additionally, quantum walk algorithms can also be used to search and find graphproperties [29, 38, 42, 61, 62, 71]. Quantum random walks can be seen as a quantum mechanicalgeneralization of classical random walks. Quantum random walk algorithms come in two forms,discrete time quantum walks and continuous time quantum walks [61]. The discrete form operatesin a step-wise fashion, requiring multiple copies of a set of gates per step. The continuous formuses a transition matrix that is expressed as a Hamiltonian, whose time evolution is then simulated.Quantum random walks can be used to walk a graph [38, 62], search for marked vertices [42], andto solve s-t connectivity [62]. An excellent survey of this approach to quantum search can be foundin Ref. [88].Most quantum algorithms that solve graph problems requires an oracle that knows the propertiesof the underlying graph. A graph properties oracle can be assembled as a circuit based on theadjacency matrix of the graph and linear algebra transformations. For example, a quantum circuitfor finding maximal cliques in a graph with n nodes, requires an oracle workspace of n data qubitsand n ancilla qubits (see [109]). Each oracle call requires execution of 6 n Toffoli gates and 2 n CNOT gates. An oracle such as this can be run on a simulator, but requires too many qubits to runon actual qubit hardware. Quantum algorithms for finding a triangle, quadrilateral, longer cycles,and arbitrary subgraphs [28] typically use the adjacency matrix to create the oracles. Here we willnot get into using quantum random walks to solve such problems. Instead we will demonstratehow to implement a simple quantum random walk on a quantum computer.
Quantum random walks or simply quantum walks are quantum analogues of classical randomwalks and Markov chains. Unlike the continuous time quantum walk, the discrete time quantumwalk algorithm requires the use of one or more coin qubits representing the number of movementchoices from each graph vertex. These extra coin degrees of freedom are necessary to ensureunitarity of the quantum walk. An appropriate unitary transformation on these coin qubits thenacts like the quantum version of a random coin toss, to decide the next vertex for the walker.Intuitively, the quantum walk is very similar to its classical cousin. In a classical walk, the walkerobserves some random process, say a coin toss, and decides on his next step conditioned on theoutput of this random process. So for a classical random walk, the walker is given a probabilityto make a transition. In a quantum walk, on the other hand, the random process is replaced by aquantum process. This quantum process is the application of the coin operator, which is a unitarymatrix. So the next step of the walker is controlled by a complex amplitude rather than a probability.This generalization, from positive numbers to complex numbers, makes quantum walks morepowerful than classical random walks.The full Hilbert space for the discrete quantum walk on a cycle with N = n nodes can then beconstructed as follows. We use an n qubit register to represent the nodes of the graph as bit strings.For the cycle every node has only two neighbours, so the coin space only needs a dimension of 2.Hence, only one extra coin qubit is required. The basis vectors of the coin ( | ⟩ and | ⟩ ) will denotethe right and left neighbours. So a basis state in the full Hilbert space will have the form | k , q ⟩ ,where k is represents a node on the cycle and q is a single bit representing the coin state.The quantum walk is then a product of two operators, the shift operator ( S ) and the coin operator( C ). As we mentioned before the coin operator only acts on the coin qubit. The coin operator can be antum Algorithm Implementations for Beginners 49 in principle any unitary that mixes the coin states, but here we will use the Hadamard coin whichis just the H gate on the coin qubit, C | k , q ⟩ = I ⊗ H | k , q ⟩ = | k , ⟩ + (− ) q | k , ⟩√ . (63)The shift operator acts on both the registers. It moves the walker to the left or right dependingon the coin state and then flips the coin state, S | k , q ⟩ = | k + (− ) q , q ⊕ ⟩ (64)The quantum walk then proceeds by applying these two operators in alternation. A p stepquantum walk is just the operator ( SC ) p . This type of a walk was first introduced in Ref. [92] andis sometimes referred to as a ‘flip-flop’ quantum walk.The definition of these operators can change for different types of quantum walk. The coinoperator can be a Hadamard gate or a sub-circuit that results in mixing the coin states. The shiftoperator can be simple as described above or can be a more complicated circuit that selects thenext vertex in the path based on the state of the coin. A simple pseudo-code for implementing thequantum walk is given in Algorithm 9.
Algorithm 9
Discrete time quantum walk
Input: • Two quantum registers. The coin register and the position register. • Number of steps, T . Output: • State of the quantum walk after T steps. Procedure:Step 1.
Create the initial state. The initial state depends on the application. For instance, inquantum search algorithms, the initial state is the uniform superposition state. for ≤ k < T doStep 2a. Apply the coin operator, C , to the coin register. Step 2b.
Apply the shift operator, S . This shifts the position of the walker controlledon the coin state. end forStep 3. (Optional) Measure the final state. In this section we will implement a simple quantum walk on Qiskit and execute it on both thesimulator and ibmq_vigo , which is a 5 qubit machine available on IBM Q. We will test the quantumwalk on a simple 4 vertex cycle with the vertices labels as given in Fig. 30.
Fig. 30. A graph of 4 nodes in the form of a square is used for the random walk algorithm. The starting vertexis labeled . The next possible vertex choices vary by 1-bit in their labels, and . The quantum walkalgorithm will walk around the graph. The coin operator in Eq. (63) is just the H gate acting on the coin qubit. The shift operator definedin Eq. (64) is more non-trivial. We can implement it by the circuit given in Fig. 31. • • X • •• X • X Fig. 31. Quantum circuit for the shift operation on the vertex cycle. The top qubit is the coin qubit. Running the walk for multiple steps requires us to apply the shift operator circuit many times.So it would be tedious to implement the quantum walk on the IBM Q graphical interface. Insteadwe can use Qiskit to design the shift operator as a user defined gate and then run the walk formultiple steps using a simple for loop. The Qiskit code for this is given in Fig. 32.We ran this Qiskit code for 4 steps of the quantum walk. We chose 4 steps since, a simplecalculation shows that, starting from | ⟩ and applying ( SC ) will concentrate all the probabilityto the state | ⟩ . This is confirmed by running the Qiskit code on the simulator. But running thesame code on ibm_vigo gave | ⟩ with only 21 .
7% probability. The rest of the probability wasdistributed among the other basis states, but | ⟩ was still the state with the largest probability.This poor performance is due to the circuit having large depth. We can expect to get better resultsby running the quantum walk for a single step. After a single step, starting from | ⟩ , the state ofthe system is | ⟩ + | ⟩√ . This is again confirmed by the simulator. Running on ibm_vigo , we got | ⟩ with 33 .
5% probability and | ⟩ with 28 .
5% probability.
11 QUANTUM MINIMAL SPANNING TREE11.1 Problem definition and background
A common problem in network design is to find a minimum spanning tree. Suppose we areresponsible for maintaining a simple network of roads. Unfortunately, each segment needs repairand our budget is limited. What combination of repairs will guarantee the network remainsconnected? Fig 33 shows a model of a simple road network as a graph, together with a minimalspanning tree.Formally, a graph G = ( V , E ) consists of a set V (the nodes) and a set E consisting of pairs ofnodes. A graph is connected if between any two nodes there exists a path. A spanning tree ofa connected graph G = ( V , E ) is the graph T = ( V , E T ) where E T ⊂ E and T contains no cycles antum Algorithm Implementations for Beginners 51 from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import
Aer, executen_steps = 4 for i in range(n_steps):circ.h (q[0]) Fig. 32. Qiskit code to implement the quantum walk on a vertex cycle. (i.e., there is exactly one path between any two vertices). It is not hard to see that a graph T is aspanning tree if and only if T is connected and has n nodes and n − G = ( V , E , w ) where w is a map on the edges w : E → R . A minimal spanning tree of agraph G is then a spanning tree T = ( V , E T ) which minimizes (cid:213) e ∈ E T w ( e ) . (65) Algorithmically, a graph is usually presented in one of two ways: either as a list of edges or as anadjacency matrix. We consider the case where G is presented as a list of edges. A quantum algorithmfor finding a minimal spanning tree of an input graph is given in [39]. This algorithm requiresonly O (√ nm ) queries where n is the number of nodes and m the number of edges in the graph.Classically, the best algorithms run in time O ( m log n ) . In particular, this is the time complexity ofBorůvka’s algorithm [19]. The quantum algorithm combines Borůvka’s algorithm together withthe quantum search algorithm of Grover [52]. (a) The weighted graph model. (b) A minimal spanning tree.Fig. 33. A graph modeling repair costs of a simple transportation network (a) together with (b) its minimalspanning tree (the solid edges). The sum of the weights of the edges in the minimal spanning tree is 21. Fig. 34. The first two steps of Borůvka’s algorithm. Starting with each node as a distinct tree, find the minimalweighed edge between each tree and the rest of the trees. The direction of the solid edges indicates the edgeis the minimal weighted edge for the source node. The components connected by solid edges (disregardingthe directions) will form the trees at the start of the second run of step (2) of Borůvka’s algorithm
Borůvka’s algorithm builds a collection of disjoint trees (i.e., a forest) and successively merges byadding minimal weight edges. The first two steps of the algorithm are shown in Fig 34. Formally,we have(1) Let T be the collection of n disjoint trees, each consisting of exactly one node from the graph G . antum Algorithm Implementations for Beginners 53 (2) Repeat:(a) For each tree T i in T find the minimal weighted edge, e i , of G between T i and the othertrees of T .(b) Merge the trees { T i ∪ { e i }} so that they are disjoint: set this new collection to T .If there are k trees in T at a given iteration of Step (2), then the algorithm performs k searchesfor the respective minimal weighted edges. As the trees are disjoint, we can perform the k searchesin one sweep by inspecting each of the m edges of G once. As there will be at most log n iterationsof Step (2), this results in a running time of O ( m log n ) . The quantum algorithm takes advantage ofthe Grover search algorithm, to speed up the searches in Step (2).In the previous sections we used Grover search to look for a single item in a list of N elements.But the search algorithm will work even if there are M elements in the list that are marked by theoracle. One of these marked elements can then be found using O ( (cid:113) NM ) queries to the oracle.In the algorithm above, we need to find the minimal element of an appropriate list. Clearly thiscan not be implemented directly as an oracle without actually inspecting each of the list elements.Luckily, there is a simple work around given by Durr et al [39] which involves multiple calls to theGrover algorithm as described in Algorithm 10. Algorithm 10
Minima finding algorithm
Input: • A unitary implementation a function F on a list of N elements, U F | x ⟩ | y ⟩ = | x ⟩ | y ⊕ F ( x )⟩ . Output: • | x ∗ ⟩ such that F ( x ∗ ) is the minimum of the function over the list. Procedure:Step 1.
Pick a random j from the list. for ≤ k < T doStep 2a. Do Grover search [20] with the oracle for function f j such that, f j ( i ) = (cid:40) F ( i ) ≤ F ( j ) F ( i ) > F ( j ) Step 2b.
Update j with the result of Grover search. end for A probabilistic analysis shows that T = . √ N + . ( N ) suffices to find the minimal elementwith high probability [40] . The inner loop of the algorithm uses a Grover search routine withpotentially multiple marked items. But the number of marked items is not known beforehand. Thisposes problem as Grover search being a unitary algorithm needs to be stopped exactly at the rightnumber of iterations to give the correct answer. Running the procedure for longer deterioratesthe quality of the answer. If the number of marked items is unknown the stopping criterion of thealgorithm is also unknown. This problem can be rectified using some extra steps by a techniquegiven in Boyer et al [20]. We have to use this modified version of Grover search in the inner loop.We did not implement the full algorithm due to space constraints on the IBM computer. Evento successfully implement a minima finding algorithm, at least 6 qubits would be necessary to compare two 3-bit numbers. Therefore we implemented the minima finding algorithm by hardcoding the oracle for each of eight possible functions f x : { f x ( i ) = F ( i ) ≤ F ( x )} . The results areshown in Figure 35. The QASM code for implementing f ( i ) = F ( i ) ≤ F ( ) required just under100 lines of code (more than 100 individual gates.) The results, even when using the simulatorare not good when k ≥ N / N extra items which will evaluate to 0 under f x , which howeverrequires an extra qubit. x=1 x=2 x=3 x=4 x=5 x=6 x=7 x=8 F r e q u e n c y (a) IBM Q Implementation x=1 x=2 x=3 x=4 x=5 x=6 x=7 x=8 F r e q u e n c y (b) Simulator ImplementationFig. 35. The results of running 1000 trials of the minima finding algorithm on both (a) the ibmqx4 chip and(b) the IBM simulator to find values less than or equal to the input x .
12 QUANTUM MAXIMUM FLOW ANALYSIS12.1 Problem definition and background
Network flow problems play a major role in computational graph theory and operations research(OR). Solving the max-flow problem is the key to solving many important graph problems, such antum Algorithm Implementations for Beginners 55
Fig. 36. A simple directed graph representing flows and capacities. Conventionally, the state of the flowproblem is indicated by the current flow relative to the capacity on any directed link using the notation f/c.Fig. 37. The Ford-Fulkerson solution to the max-flow problem in three steps. Each step represents theapplication of an augmenting path to the previous flow state. as finding a minimum cut set, and finding a maximal graph matching. The Ford-Fulkerson algo-rithm [44] is a landmark method that defines key heuristics for solving the max flow problem. Themost important of these heuristics include the construction of a residual graph, and the notion ofaugmenting paths. For integer-capacity flows, Ford-Fulkerson has complexity O ( f m ) for m edgesand max flow f . The Edmonds-Karp variant has complexity O ( nm ) for n vertices and m edges.The quantum-accelerated classical algorithm discussed here [6] claims complexity O ( n / √ m ) .The best classical implementations of the max-flow solver involve several important improve-ments [41], especially that of using breadth-first search to find the shortest augmenting path oneach iteration. This is equivalent to constructing layered subgraphs for finding augmenting paths.An illustration of the essential method introduced by Ford and Fulkerson can be described usingFigures 36 and 37. At each link in the network, the current flow f and the capacity c are shown.Typically, the state of flow on the graph is designated by f / c , with the residual capacity implicitlygiven by c − f . In Figure 36, the initial flow has been set to zero.The basic steps in the solution to the max-flow problem are illustrated by Figure 37. The algorithmbegins on the left by considering the path [s,v,t]. Since 2 is the maximum capacity allowed alongthat path, all the flows on the path are tacitly set to that value. Implicitly, a reverse flow of -2 isalso assigned to each edge so that the tacit flow may be “undone” if necessary. Next, the middle ofthe figure examines the lower path [s,w,t]. This path is constrained by a maximum capacity onthe edge [s,w] of again 2. Finally, the path [s,v,w,t] is the only remaining path. It can only supportthe residual capacity of 1 on edge [s,v]. We can then read off the maximum flow result at the sinkvertex t since the total flow must end there. The maximum flow is seen to be 5. While this method seems straightforward, without the efficiencies provided by the improvementsof Edmonds and Karp, convergence might be slow for integer flows on large graphs, and may notconverge at all for real-valued flows. The modification of always choosing the shortest next path inthe residual network to augment, is what makes the algorithm practical. To see this, consider whatwould have happened if the path [s,v,w,t] had been chosen first. Since augmenting that path blocksthe remaining paths, flows would have to be reversed before the algorithm could proceed.Choosing the shortest path requires performing a breadth-first search whenever new flow valueshave been assigned to the residual graph. This is equivalent to building a layered set of subgraphs topartition the residual graph. This is the step that leads to the m complexity of Edmonds-Karp, andit is this step that is speeded up in the “quantized” version of the algorithm, leading to a complexityterm of √ m instead of m . The Quantum algorithm described by Ambainis and Spalek is a “quantized” version of the Edmonds-Karp algorithm, that is, the classical algorithm with quantum acceleration. The key quantumcomponent is a generalized version of Grover’s search algorithm that finds k items in an unsortedlist of length L [20]. The algorithm is used in creating a layered subgraph data structure that issubsequently used to find the shortest augmenting path at a given iteration. Like in Section XI, wewill be oblivious to the number of marked items Grover’s algorithm is searching for. So once againwe have to use techniques from Ref.[20] while performing the search.Here we will describe how to build a layered graph partition. In a layered graph partition eachvertex in the graph is assigned to thew i -th layer such that edges of the graph only connect between i -th and ( i + ) -th layers. The key to “quantization” lies in using Grover’s search to build a layeredgraph partition by computing layer numbers for all vertices. The layers are represented by an array L indexing the vertices of the graph, and assigning to each element a subgraph layer number. Thesink vertex at vertex zero is set to zero. The the algorithm proceeds according to the followingpseudo-code described in Algorithm 11. Algorithm 11
Layered graph partitioning
Input: • Adjacency information of the graph (Adjacency matrix, list of edges,etc.) • Source vertex s . Output: • L such that L[ i ] is the layer number of the i -th vertex. Procedure:Step 1.
Set L[ s ] = L[ x ] = ∞ for x (cid:44) Step 2.
Create a one-entry queue W = { s } ( x = ) while W (cid:44) ϕ doStep 3a. Take the first vertex x from W . Step 3b.
Find by Grover search all its neighbors y with L[ y ] = ∞ . Step 3c.
Set L( y ) = L[ x ] +
1, append y into W , and remove x from W end while Notice that the oracle for Grover search required for this algorithm is one that marks all theneighbours of x whose layer number is currently set to ∞ . Grover’s search speeds up the layersassignment of the vertices by quickly finding all the entries in the layer array L that contain thevalue ∞ . In practical terms, ∞ might simply be the largest value reachable in an n-qubit machine. antum Algorithm Implementations for Beginners 57 The generalized Grover search would look for all such values without a priori knowing the numberof such values. The size of a circuit required to do a full layered graph partitioning makes itimpractical to implement it on the IBM machine. But the heart of the algorithm is Grover search,which we have already implemented earlier.
13 QUANTUM APPROXIMATE OPTIMIZATION ALGORITHM13.1 Problem definition and background
Combinatorial optimization problems are pervasive and appear in applications such as hardwareverification, artificial intelligence and compiler design, just to name a few. Some examples ofcombinatorial optimization problems include Knapsack, Traveling Saleman, Vehicle Routing, andGraph Coloring problems. A variety of combinatorial optimization problems including MaxSat,MaxCut, and MaxClique can be characterized by the following generic unconstrained discretemaximization problem, maximize: m (cid:213) α = C α ( z ) z i ∈ { , } ∀ i ∈ { , . . . , n } (66)In this generic formulation, there are n binary decisions variables, z , and m binary functions ofthose variables, C ( z ) , called clauses. The challenge is to find the assignment of z that maximizes thenumber of clauses that can be satisfied. This is the so-called MaxSat problem, which is NP-Hardin general [64], and is an optimization variant of the well-known satisfiability problem, whichis NP-Complete [31]. Hence, solving an instance of Eq. (66) in practice can be computationallychallenging.To provide a concrete example of Eq. (66), let us consider the MaxCut problem. As input, theMaxCut problem takes a graph G = ( V , E ) , which is characterized by a set of nods V and a set ofundirected edges E . The task is to partition the nodes into two sets, such that the number of edgescrossing these sets is maximized. Figure 38 provides an illustrative example, in which a graph withfive nodes and six edges is partitioned into two sets that result in a cut of size five. Fig. 38. An illustration of the MaxCut problem.
In general, the MaxCut problem is characterized by the following unconstrained discrete maximiza-tion problem, maximize: (cid:213) i , j ∈ E ( − σ i σ j ) σ i ∈ {− , } ∀ i ∈ N (67)In this formulation, there is one binary decision variable for each node in the graph, indicatingwhich set it belongs to. The objective function consists of one term for each edge in the graph. This term is 0 if the the nodes of that edge take the same value and 1 otherwise. Consequently,the optimal solution of (67) will be a maximal cut of the graph G . Interestingly, the form ofEq. (67) also highlights that finding a maximal cut of G is equivalent to finding a ground state ofthe antiferromagnet of G in an Ising model interpretation. In either case, it is clear that Eq. (67)conforms to the structure of Eq. (66). Note that the linear transform z = ( σ + )/ σ ∈ {− , } space to the z ∈ { , } space. The Quantum Approximate Optimization Algorithm (QAOA) as proposed in [43] leverages gate-based quantum computing for finding high-quality solutions to combinatorial optimization problemsthat have the form of Eq. (66). To apply this algorithm the user first translates the clause functions C α ( z ) into equivalent quantum clause Hamiltonians C α and then selects a number of rounds r ≥ ≤ β [ k ] ≤ π and 0 ≤ γ [ k ] ≤ π for the k -th round. The pseudocode forQAOA is given in Algorithm 12. Algorithm 12
Quantum approximate optimization algorithm
Input: • Number of rounds of optimization r • Two size r array of angles, γ and β . • Hamiltonians C α corresponding to the clauses of the optimization problem. Output: • An approximation to the solution of problem in Eq. (66).
Procedure:Step 1.
Construct the n -qubit uniform superposition state by applying H ⊗ n to | . . . ⟩ for ≤ k ≤ r doStep 2a. Apply (cid:206) mα = e − iγ [ k ] C α Step 2b.
Apply (cid:206) nj = e − iβ [ k ] X j end forStep 3. We will call the state so constructed | β , γ ⟩ . The expectation value, (cid:205) mα = ⟨ β , γ | C α | β , γ ⟩ , gives an approximate solution to the problem.For an appropriate selection of r , β , γ , this algorithm will give a high-quality solution to Eq. (66).As the number of rounds used increases, the quality of the solution produced by the above algorithmalso increases provided that the angles chosen for the previous rounds are optimal. Conducting anexhaustive search over a fine grid is proposed in [43] for the selection of each round’s optimal β , γ angles. The use of a quantum-variational-eigensolver is also possible [74, 79].The translation of the clauses to Hamiltonians and the determination of the final expectationvalue depends on the specific optimization problem being solved. To provide a concrete exampleof the generic QAOA formulation, let us consider its application to the MaxCut problem give inEq. (67). It is important to note that the MaxCut problem is particularly advantageous for QAOAfor the following reasons: (1) all of the clauses in the objective function have the same structure,hence only one clause Hamiltonian C α needs to be designed; (2) Each clause only involves twodecision variables, which keeps the structure of C α relativity simple. The design of MaxCut clause antum Algorithm Implementations for Beginners 59
210 34 210 34210 34 210 34ibmqx2 Single Edge Triangle Triangle plus Edge
Fig. 39. The CNOT connectivity and error rates of the ibmqx2
Computer (left) followed by the SingleEdge (center left), Triangle (center right) and Four edge (right) graphs considered in the proof-of-conceptexperiments.
Hamiltonian is as follows, C ( i , j ) = ( − σ i σ j ) (68) σ i = − σ i = (cid:18) (cid:19) σ j = −
11 0 σ j = | ⟩ | ⟩ | ⟩ | ⟩ (cid:169)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:172) | ⟩ | ⟩ | ⟩ | ⟩ (70) C i , j = ( I − Z i ⊗ Z j ) (71)Eq. (68) presents the binary function used by each edge in the objective of Eq. (67). Eq. (69) showsthe enumeration of all inputs and outputs of the binary function, and Eq. (70) illustrates how toencode these inputs and outputs into a quantum Hamiltonian. Finally, the quantum Hamiltonian inEq. (70) can be compactly written as in Eq. (71).These clause Hamiltonians can then be used in the QAOA algorithm. Notice that the clauseHamiltonians here are all combinations of Z gates. This makes finding the final expectation valuevery simple. For each run of the algorithm, one only needs to measure the final state in thecomputational basis. This measurement will give a bit string that corresponds to an assignment tothe classical σ i variables. The output of the algorithm is then found by estimating the expectationvalue of (cid:205) i , j ∈ E ( − σ i σ j ) over independent runs of the algorithm. ibmqx2 This section investigates the implementation of the QAOA MaxCut algorithm on the ibmqx2 quantum computer (Figure 39). The first challenge is to transform the QAOA algorithm from itsmathematical form into a sequence of operations that are available in the IBM Quantum Experienceplatform. For the sake of convenience we will mention here the gates we will use in the ensuing discussion, U ( λ ) = (cid:18) e iλ (cid:19) , U ( θ , ϕ , λ ) = (cid:18) cos ( θ / ) − e iλ sin ( θ / ) e iϕ sin ( θ / ) e i ( λ + ϕ ) cos ( θ / ) (cid:19) , CNOT = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) . The inner loop of the algorithm first requires the application of the γ angle with the clauseHamiltonians. For the MaxCut Hamiltonian, this can be expanded as follows, e − i γ [ k ] ( I − Z a ⊗ Z b ) = e − iγ [ k ] (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) = (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) e − iγ [ k ] e − iγ [ k ]
00 0 0 1 (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) (72)After some derivation, it is observed that this gate can be implemented as a combination of twoCNOT gates and one U (− γ ) gate, as indicated in Figure 40. It is also interesting to note the alternateimplementation of this gate in [30], which leverages a different variety of gate operations [96]. U1 (-gamma) Fig. 40. An IBM Quantum Experience score illustrating an implementation of the MaxCut edge gate (72) . The next term in the loop is the application of the β angle, which is expanded as follows, e − iβ [ k ] X = e − iβ [ k ] (cid:32) (cid:33) = (cid:18) cos ( β [ k ]) − i sin ( β [ k ]) i sin ( β [ k ]) cos ( β [ k ]) (cid:19) (73)Careful inspection of the IBM Quantum Experience gates reveals that this operation is implementedby U ( β k , − π / , π / ) . So we need to apply this gate to every qubit in the register.Putting all of these components together, Figure 41 presents an IBM Quantum Experience circuitfor implementing QAOA for MaxCut on the “Triangle plus Edge” graph from Figure 39 using thefollowing parameters, r = γ = . · π = . .., β = . · π = . .., γ = . · π = . .., β = . · π = . ... HHHH U1 (-0.62...) U1 (-0.62...) U1 (-0.62...) U1 (-0.62...) U3 (0.942...) U3 (0.942...) U3 (0.942...) U3 (0.942...) U1 (-1.25...) U1 (-1.25...) U1 (-1.25...) U1 (-1.25...) U3 (0.314...) U3 (0.314...) U3 (0.314...) U3 (0.314...) q[0]q[1]q[2]q[3]q[4]c5 Fig. 41. An IBM Quantum Experience circuit for QAOA MaxCut with two rounds on a “Triangle plus Edge”graph. antum Algorithm Implementations for Beginners 61
With a basic implementation of QAOA for MaxCut in qiskit, a preliminary proof-of-concept studyis conducted to investigate the effectiveness of QAOA for finding high-quality cuts in the a) SingleEdge, b) Triangle and c) Triangle plus Edge graphs presented in Figure 39. This study comparesthree types of MaxCut computations: (1)
Random assigns each node in the graph to one of thetwo sets uniformly at random; (2)
Simulation executes the IBM Quantum Experience circuit viasimulation on a classical computer; (3)
Hardware executes the IBM Quantum Experience circuiton the ibmqx2 hardware. The simulation computation serves to demonstrate the mathematicalcorrectness of the proposed QAOA circuit. The hardware computation demonstrates the viabilityof the circuit in a deployment scenario where environmental noise, intrinsic bias, and decoherencecan have a significant impact on the results. The random computation serves to demonstrate thatthe hardware results are better than what one would expect by chance from pure noise. For eachcomputation we give the expectation/mean of the returned solutions and the probability to samplethe maximum cut. All of these computations are stochastic, therefore event probabilities on IBMQuantum Experience are computed based on 4096 independent runs of each computation.a) The first experiment considers the Single Edge graph from Figure 39 (center left) and imple-ments a 1-round QAOA with the parameters r = γ = . · π , β = . · π . The results are summarized in Table 4. The simulation results indicate that the proposed score ismathematically sound and the hardware results indicate similar performance to the simulation,with a few additional errors. The random results indicate that both the simulation and hardwareperform significantly better than random chance.
Table 4. MaxCut QAOA with one round on a Single Edge.
Random Simulation HardwareExpected Size of a sampled cut 0.500 1.000 0.950Probability of sampling a maximum cut 0.500 1.000 0.950b) The second experiment considers the Triangle graph from Figure 39 (center right) withparameters r = γ = . · π , β = . · π . The results are summarized in Table 5. The simulation results indicate that the proposed circuitis mathematically sound. Even though the QAOA circuit for a Triangle is longer than the QAOAcircuit for a Single Edge, the Hardware performance is better, most likely to the more favourabledistribution of the cuts, also notable in Random.
Table 5. MaxCut QAOA with one round on a Triangle.
Random Simulation HardwareExpected Size of a sampled cut 1.500 1.999 1.904Probability of sampling a maximum cut 0.750 1.000 0.952c) The third experiment considers the Triangle plus Edge graph from Figure 39 (right). We runQAOA both in a 1-round and a 2-round scenario, implemented with the following parameters, found through numerical grid searches with a resolution of π / π /
20, respectively(2-round): r = γ = . · π , β = . · π . r = γ = . · π , β = . · π , γ = . · π , β = . · π . The results are summarized in Table 6, the 2-round circuit is shown in Figure 41. Simulation andHardware outperform Random both on 1-round and 2-round QAOA. However, the gains madeby Simulation in 2-round over 1-round QAOA almost vanish on the Hardware. This degradationin performance is likely due to the double length in the circuit, making the experiment moresusceptible to gate errors, environmental noise and qubit decoherence.
Table 6. MaxCut QAOA with several rounds on a Triangle plus Edge graph.
14 QUANTUM PRINCIPAL COMPONENT ANALYSIS14.1 Problem definition and background
In data analysis, it is common to have many features, some of which are redundant or correlated.As an example, consider housing prices, which are a function of many features of the house, suchas the number of bedrooms, number of bathrooms, square footage, lot size, date of construction,and the location of the house. Often, one is interested in reducing the number of features to the few,most important features. Here, by important, we mean features that capture the largest variance inthe data. For example, if one is only considering houses on one particular street, then the locationmay not be important, while the square footage may capture a large variance.Determining which features capture the largest variance is the goal of Principal ComponentAnaylsis (PCA) [78]. Mathematically, PCA involves taking the raw data (e.g., the feature vectors forvarious houses) and computing the covariance matrix, Σ . For example, for two features, X and X ,the covariance is given by Σ = (cid:18) E ( X ∗ X ) E ( X ∗ X ) E ( X ∗ X ) E ( X ∗ X ) (cid:19) , (74)where E ( A ) is the expectation value of A , and we have assumed that E ( X ) = E ( X ) = . Next, onediagonalizes Σ such that the eigenvalues e ≥ e ≥ e ≥ · · · are listed in decreasing order. Again,for the two-feature case, this becomes Σ = (cid:18) e e (cid:19) . (75)Once Σ is in this form, one can choose to keep the features with n -largest eigenvalues and discardthe other features. Here, n is a free parameter that depends on how much one wants to reduce thedimensionality. Naturally, if there are only two features, one would consider n =
1, i.e., the singlefeature that captures the largest variance. antum Algorithm Implementations for Beginners 63 X = number of bedrooms = { , , , , , , , , , , , , , , } X = square footage = { , , , , , , , , , , , , , , } . (76)Henceforth, for scaling purposes, we will divide the square footage by 1000 and subtract off themean of both features. Classically, we compute the covariance matrix and its eigenvalues to be thefollowing: Σ = (cid:18) . . . . (cid:19) , e = . , e = . . (77)We now discuss the quantum algorithm for doing the above calculation, i.e., for finding theeigenvalues of Σ . Before we discuss the algorithm we will provide a quick introduction to the concept of a densitymatrix.
Density matrices are used to represent probabilistic mixtures of quantum states. Supposethat there is a quantum system whose state is not known, rather we know that it can be in one of M states, | ψ i ⟩ , each occurring with probability p i . The state of this system is then represented by adensity matrix ρ , defined as ρ = M (cid:213) i = p i | ψ i ⟩ ⟨ ψ i | . (78)If the state of a system is known (with probability 1) to be | ψ ⟩ , then the density matrix would justbe | ψ ⟩ ⟨ ψ | and the system is said to be in a pure state . Otherwise, the system is said to be in a mixedstate . So the density matrix can be seen as a generalization of the usual state representation withthe extra ability to represent a probabilistic mixture of quantum states. From the definition of thedensity matrix it can be seen that it is a positive semi-definite matrix with unit trace. In fact, anymatrix that satisfies these two properties can be interpreted as a density matrix. More details onthe definition and interpretation of density matrices are given in the quantum tomography section(Section 20).Density matrices are clearly more expressive than state vectors as state vectors can only representpure states. But, even a system in a mixed state can be seen as a part of a larger system that is ina pure state. This process of converting a mixed state into a pure state of an enlarged system iscalled purification. A mixed state of an n qubit system can be purified by adding n more qubitsand working with the 2 n qubit system. Once purified, the joint system of 2 n qubits will be in apure state while the first n qubits will still be in the original mixed state. We will not discuss thetransformations required to purify a state. Interested readers are referred to Ref. [77] for a completediscussion.The quantum algorithm for performing PCA presented in Ref. [70] uses the density matrixrepresentation. The algorithm discussed there has four main steps: (1) encode Σ in a quantumdensity matrix ρ (exploiting the fact that Σ is a positive semi-definite matrix), (2) prepare manycopies of ρ , (3) perform the exponential SWAP operation on each copy and a target system, and (4)perform quantum phase estimation to determine the eigenvalues. For an implementation of thisquantum PCA algorithm on a noisy simulator, we refer the reader to Ref. [66], which also gives ashort-depth compilation of the exponential SWAP operation. StatePreparation FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing
Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing
Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). U prep U prep Classical Pre-processingData FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing
Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ).2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing
Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing
Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). U prep PurityCalculation FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing
Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). 2 FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing
Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). H HSWAP
ClassicalPost-processing FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing P { e , e }| i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing P { e , e }| i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). Fig. 42. Schematic diagram for the quantum algorithm for PCA, in the special case of only two features. Thefirst step is classical pre-processing: transforming the raw data into a covariance matrix Σ , then normalizingto compute ρ = Σ / Tr ( Σ ) , then purifying ρ to a two-qubit pure state | ψ ⟩ , and finally determining the unitary U prep needed to prepare | ψ ⟩ . The second step is to prepare two copies of | ψ ⟩ by implementing U prep on aquantum computer. The third step is purity calculation, which is the bulk of the quantum algorithm. Thisinvolves doing a Hadamard on an ancilla, which then is used to implement a controlled-SWAP gate on twoqubits (from different copies of | ψ ⟩ ), and then another Hadamard on the ancilla. Finally measuring ⟨ Z ⟩ on theancilla gives the purity P = Tr ( ρ ) . The last step is to classically compute the eigenvalues using Eqs. (79) - (80) . However, given the constraint of only 5 qubits on IBM’s computer, preparing many copies of ρ is not possible. Hence, we consider a simpler algorithm as follows. In the special case where thereare only two features, Σ and ρ are 2 × ρ can be purified to a purestate | ψ ⟩ on two qubits. Suppose one prepares two copies of | ψ ⟩ , which uses a total of 4 qubits,then the fifth qubit (on IBM’s computer) can be used as an ancilla to implement an algorithm thatdetermines the purity P : = Tr ( ρ ) of ρ . This algorithm was discussed, e.g., in Ref. [57]. It is thenstraightforward to calculate the eigenvalues of Σ from P , as follows: e = Tr ( Σ ) ∗ ( + (cid:112) − ( − P ))/ e = Tr ( Σ ) ∗ ( − (cid:112) − ( − P ))/ . (80)We remark that recently (after completion of this review article), a simpler algorithm for computingpurity P was given in Ref. [27]. While the results presented in what follows use the approach inRef. [57], the approach in Ref. [27] could lead to more accurate results.As depicted in Fig. 42, this simple algorithm is schematically divided up into four steps: (1) classicalpre-processing, (2) state preparation, (3) quantifying the purity, and (4) classical post-processing.In the first step, the classical computer converts the raw data vectors into a covariance matrix Σ , then normalizes this matrix to form ρ = Σ / Tr ( Σ ) , then purifies it to make a pure state | ψ ⟩ , andfinally computes the unitary U prep needed to prepare | ψ ⟩ from a pair of qubits each initially in the | ⟩ state. antum Algorithm Implementations for Beginners 65 In the second step, the quantum computer actually prepares the state | ψ ⟩ , or in fact, two copiesof | ψ ⟩ , using U prep , which can be decomposed as follows: U prep = ( U A ⊗ U B ) CNOT AB ( U ′ A ⊗ B ) . (81)Note that U prep acts on two qubits, denoted A and B , and CNOT AB is a CNOT gate with A thecontrol qubit and B the target. The single qubit unitaries U A , U B , and U ′ A can be written in IBM’sstandard form: (cid:18) cos ( θ / ) − e iλ sin ( θ / ) e iϕ sin ( θ / ) e iλ + ϕ cos ( θ / ) (cid:19) , (82)where the parameters θ , λ , and ϕ were calculated in the previous (classical pre-processing) step.The third step is purity calculation, which makes up the bulk of the quantum algorithm. Asshown in Fig. 42, first one does a Hadamard on an ancilla. Let us denote the ancilla as C , while theother four qubits are denoted A , B , A ′ , and B ′ . During the state preparation step, qubits A and B were prepared in state | ψ ⟩ with the state of A being ρ . Likewise we have the state of A ′ to be ρ .Next, qubit C is used to control a controlled-SWAP gate, where the targets of the controlled-SWAPare qubits A and A ′ . Then, another Hadamard is performed on C . Finally, C is measured in the Z basis. One can show that the final expectation value of Z on qubit C is precisely the purity of ρ , i.e., ⟨ Z ⟩ C = p − p = Tr ( ρ ) = P , (83)where p ( p ) is the probability for the zero (one) outcome on C .The fourth step is classical post-processing, where one converts P into the eigenvalues of Σ usingEqs. (79) and (80). The actual gate sequence that we implemented on IBM’s 5-qubit computer is shown in Fig. 43. Thisinvolved a total of 16 CNOT gates. The decomposition of controlled-SWAP into one- and two-qubitgates is done first by relating it to the Toffoli gate:controlled-SWAP
CAB = ( C ⊗ CNOT BA ) Toffoli
CAB ( C ⊗ CNOT BA ) (84)and then decomposing the Toffoli gate, as in Ref. [91].We note that the limited connectivity of IBM’s computer played a signficant role in determiningthe algorithm. For example, we needed to implement a CNOT from q[1] to q[2], which required acircuit that reverses the direction of the CNOT from q[2] to q[1]. Also, we needed a CNOT fromq[3] to q[1], which required a circuit involving a total of four CNOTs (from q[3] to q[2] and fromq[2] to q[1]).Our results are as follows. For the example given in Eq. (76), IBM’s 5-qubit simulator with 40960trials gave: e = . , e = . . (85)A comparison with Eq. (77) shows that IBM’s simulator essentially gave the correct answer. On theother hand, IBM’s 5-qubit quantum computer with 40960 trials gave: e = . + . i , e = . − . i (IBM’s Quantum Computer) . (86)This is a non-sensical result, since the eigenvalues of a covariance matrix must be (non-negative)real numbers. So, unfortunately IBM’s quantum computer did not give the correct answer for thisproblem. Fig. 43. Actual circuit for quantum PCA implemented on IBM’s 5-qubit simulator and quantum computer.The first three time slots in the score correspond to the state preparation step of the algorithm, and thesubsequent time slots correspond to the purity calculation step. Due to connectivity reasons, we chose qubitq[3] as the ancilla and qubits q[1] and q[2] as the targets of the controlled-SWAP operation. We decomposedthe controlled-SWAP operation into CNOT gates by first relating it to the Toffoli gate via Eq. (84) , and thendecomposing the Toffoli gate into CNOT gates [91].
15 QUANTUM SUPPORT VECTOR MACHINE
Support Vector Machines (SVM) are a class of supervised machine learning algorithms for binaryclassifications. Consider M data points of {((cid:174) x j , y j ) : j = , , . . . , M } . Here (cid:174) x j is a N -dimensionalvector in data feature space, and y j is the label of the data, which is + −
1. SVM finds thehyperplane (cid:174) w · (cid:174) x + b = (cid:174) w · (cid:174) x j + b ≥ y j = + (cid:174) w · (cid:174) x j + b ≤ − y j = −
1, and that is maximally separated from the nearest datapoints on each category. Least Squares SVM (LS-SVM) is a version of SVM [102]. It approximatesthe hyperplane finding procedure of SVM by solving the following linear equation: (cid:20) (cid:174) T (cid:174) K + γ − (cid:21) (cid:20) b (cid:174) α (cid:21) = (cid:20) (cid:174) y (cid:21) . (87)Here K is called the kernel matrix of dimension M × M , γ is a tuning parameter, and (cid:174) α forms thenormal vector (cid:174) w where (cid:174) w = (cid:205) Mj = α j (cid:174) x j . Various definitions for the kernel matrix are available, butthe quantum SVM [84] uses linear kernel: K ij = (cid:174) x i · (cid:174) x j . Classically, the complexity of the LS-SVMis O (cid:0) M ( M + N ) (cid:1) .The quantum version of SVM performs the LS-SVM algorithm using quantum computers [84].It calculates the kernel matrix using the quantum algorithm for inner product [69] on quantumrandom access memory [50], solves the linear equation using a quantum algorithm for solvinglinear equations [50], and performs the classification of a query data using the trained qubits witha quantum algorithm [84]. The overall complexity of the quantum SVM is O (cid:0) log N M (cid:1) .The algorithm is summarized below: antum Algorithm Implementations for Beginners 67
Algorithm 13
Quantum SVM [84]
Input: • Training data set {((cid:174) x j , y j ) : j = , , . . . , M } . • A query data (cid:174) x . Output: • Classification of (cid:174) x : + − Procedure:Step 1.
Calculate kernel matrix K ij = (cid:174) x i · (cid:174) x j using quantum inner product algorithm [69]. Step 2.
Solve linear equation Eq. (87) and find | b , (cid:174) α ⟩ using a quantum algorithm for solvinglinear equations [50] (training step). Step 3.
Perform classification of the query data (cid:174) x against the training results | b , (cid:174) α ⟩ using aquantum algorithm [84].The inner product calculation to compute the kernel matrix cannot be done reliably in thecurrently available quantum processors. The other important part of the algorithm, which is linearsystem solving, can be quantized and has been dealt with in Section IV.
16 QUANTUM SIMULATION OF THE SCHRÖDINGER EQUATION16.1 Problem definition and background
The Schrödinger’s equation describes the evolution of a wave function ψ ( x , t ) for a given Hamil-tonian ˆ H of a quantum system: i ℏ ∂∂ t ψ ( x , t ) = ˆ Hψ ( x , t ) = (cid:34) ℏ ˆ k m + V ( ˆ x ) (cid:35) ψ ( x , t ) , (88)where the second equality illustrates the Hamiltonian of a particle of mass m in a potential V ( x ) .Simulating this equation starting with a known wave function ψ ( x , ) provides knowledge about thewave function at a given time t f and allows determination of observation outcomes. For example, (cid:12)(cid:12) ψ ( x , t f ) (cid:12)(cid:12) is the probability of finding a quantum particle at a position x at time t f .Solving the Schrödinger’s equation numerically is a common approach since analytical solutionsare only known for a handful of systems. On a classical computer, the numerical algorithm startsby defining a wave function on a discrete grid ψ ( x i , ) with a large number of points i ∈ [ , N ] . Theform of the Hamiltonian, Eq. (88), allows one to split the system’s evolution on a single time step ∆ t in two steps, which are easy to perform: ψ ( x i , t n + ) = e − iV ( x i ) ∆ t QFT † e − ik ∆ t QFT ψ ( x i , t n ) , (89)where we have assumed that ℏ = m = . And QFT and
QFT † are the quantum Fourier transformand its inverse. The quantum state evolution thus consists of alternating application of the phaseshift operators in the coordinate and momentum representations. These two representation arelinked together by the Fourier Transformation as in the following example of a free space evolutionof a quantum particle: ψ ( x i , t f ) = QFT † e − ik t f QFT ψ ( x i , ) , (90)where V ( x ) = t f . Finding a propermeasurement on a quantum simulator that reveals information about the quantum system will however be left out of the discussion. (cid:12)(cid:12) ψ ( x , t f ) (cid:12)(cid:12) will be the only information we will be interestedin finding out. A quantum algorithm that performs a quantum simulation of one dimensional quantum systemswas presented in [13]. The procedure is outlined in Algorithm 14.
Algorithm 14
Quantum simulation of Schrödinger equation [98], [13]
Input: • Initial wave function • Time step size, ∆ t , and the number of time steps, T . • The ability to apply phase shifts in the computational basis. • The potential function V . Output: • Final wave function at time t f = T δt when evolved using the Schrödinger equation withthe potential V . Procedure:Step 1.
Encode the wave function on a N-point grid in a quantum state of n = log ( N ) qubits. The value of this discretized wavefunction on a grid point is equal to the value of theoriginal wave function at the same point. The constant of proportionality must then be calculatedby renormalizing the discretized wavefunction. for ≤ j ≤ T doStep 2a. Apply the Quantum Fourier Transform (QFT) to go to the momentumrepresentation.
Step 2b.
Apply a diagonal phase shift of the form | x ⟩ → e − ix ∆ t | x ⟩ in the computa-tional basis. Step 2c.
Apply the inverse Quantum Fourier Transform to come back to the positionrepresentation.
Step 2d.
Apply a phase shift of the form | x ⟩ → e − iV ( x ) ∆ t | x ⟩ . end forStep 3. Measure the state in the computational basis.Figure 44 shows the following stages of the algorithm. The implementation of QFT was discussedin Section IV. Implementing phase shifts corresponding to arbitrary functions can be done using aseries of controlled Z gates or CNOT gates [13]. Repeating the final measurement step over manyindependent runs will let us estimate the probabilities | ψ ( x , t f )| . We will now consider a 2-qubitexample of the quantum simulation algorithm in the case of a free particle, V ( x ) = Π -function (a rectangular wave), which has { , , , } representa-tion on a 2 n -point grid for n = | , ⟩ + | , ⟩ , which can be prepared by constructing the Bell state (see Fig. 1) and applying the X gate to the first qubit.We define the 2-qubit QFT as QFT = SWAP H C (cid:2) P (cid:0) π (cid:1)(cid:3) H , where C P is a phase operatorcontrolled from the second qubit. This transformation applies phase shifts to the probabilityamplitudes of the qubit states similar to the ones applied by the classical FFT to the function values.Hence, the resulting momentum representation is identical to the classical one in a sense that it isnot centered around k =
0, which can be easily remedied by a single X gate. antum Algorithm Implementations for Beginners 69 Classical Pre-processing !", |% & (()⟩( + , , ∈ [0, 0]% + = %(( + )3 {5} , 7 = log ; +>?@ % + + 5 !A BCDB
StatePreparation ? ; E F G ! A B C D B FinalState < % H I = = + > ? @ J + + ΔH step( H I /ΔH times) ? ; E F G M N O P Q R Δ H S ; M T N O P Q R Δ H U ( Fig. 44. The quantum simulation of the Schrödinger’s equation. The first stage is a classical pre-processingthat encodes the wave function to available qubits and derives a state preparation operator that takesan all-zero state of a quantum computer to a desired state. The second stage prepares an initial state byimplementing the state preparation operator ˆ U prep on a quantum computer. The third stage is an iterativeupdate looped over ∆ t steps based on the operator splitting method. | ⟩ P ( ϕ )| ⟩ H X • X H P ( π ) P ( ϕ ) • • P ( π ) H | ⟩ • H X P ( ϕ ) • • X H • Fig. 45. The quantum circuit implementation of a 2-qubit algorithm that solves the Schrödinger’s equationon a quantum computer. The initial state preparation is followed by the Quantum Fourier Transform andcentering of the momentum representation. The single qubit phase shift transformations are followed bythe two-qubit phase shift transformation that uses an ancillary qubit q[0]. The inverse Quantum FourierTransform preceded by removing the centering operation completes the circuit and returns the wave functionto the coordinate representation.
The momentum encoding adopted in this discussion is k = − (cid:113) ϕ ∆ t (cid:0) + (cid:205) nk = n − k Z k (cid:1) , where ϕ is a characteristic phase shift experienced by the state on a time step ∆ t . In this representation − ik ∆ t phase shift contains one and two qubit contributions that commute with each other and canbe individually implemented. The one qubit phase shift gate has a straightforward implementationbut the two qubit phase shift gate requires an ancillary qubit according to Ref. [77], which resultsin a three qubit implementation on a quantum computer. This implementation is captured in Fig 45where removing the centering of the momentum representation and the inverse QFT have beenadded in order to return to the coordinate representation. The implementation in Fig. 46 takes into account the topology of the chip and the availability ofthe gates such as U U
2. Finally, it performs a consolidation of the single qubit gates in orderto reduce the number of physical operations on the qubits.
Fig. 46. The quantum circuit implementation of a 2-qubit algorithm that solves the Schrödinger’s equationon the ibmqx4 quantum computer.
The circuit in Fig. 46 was run on the ibmqx4 quantum chip, where the maximum number ofexecutions in a single run is 2 . The probabilities of observing qubit states in the computationalbasis was measured for ϕ = ϕ = π / ϕ = π , ϕ = π / ϕ = π . We expect that as ϕ increasesfrom 0 to π the wave function evolves from a Π -function to a uniform function to a functionpeaked at the ends of the interval. The consecutive increase returns the wave function back to the Π -function.We started with the ϕ = ϕ = π / .
25 with theobserved values of {0.295, 0.257, 0.232, 0.216}. This surprise was however short lived as the ϕ = π case has reverted back large errors for observed probabilities: {0.479, 0.078, 0.107, 0.335}. The finaltwo case had the following observed probabilities {0.333, 0.248, 0.220, 0.199} and {0.163, 0.419, 0.350,0.068} respectively.
17 GROUND STATE OF THE TRANSVERSE ISING MODEL
In this section the ground state of the transverse Ising model is calculated using the variationalquantum eigenvalue solver, and the result is compared to the exact results. This is a hybrid methodthat uses alternating rounds of classical and quantum computing.In the previous section we saw how to simulate the evolution of a single quantum particle. Butoften, real world phenomena are dependent on the interactions between many different quantumsystems. The study of many-body Hamiltonians that model physical systems is the central themeof condensed matter physics (CMP).Many-body Hamiltonians are inherently hard to study on classical computers as the dimensionof the Hilbert space grows exponentially with the number of particles in the system. But using aquantum computer we can study these many-body systems with less overhead as the number ofqubits required only grows polynomialy.
A central task in CMP is finding the ground state (lowest energy eigenstate) of a given Hamiltonian, H , H | Ψ ⟩ = E д | Ψ ⟩ . (91)Studying the ground state gives us information about the low temperature properties of thesystem. Once we know | Ψ ⟩ , we can deduce the physical properties from the wave function. Inthis section, we will describe how to use IBM Q to find the ground state energy of the transverseIsing model. We will not be using the ibmqx4 in this section. This is because the algorithm weuse will require many rounds of optimization. Each round requires us to run a circuit on thequantum computer followed by a classical optimization step on a local machine. This process can antum Algorithm Implementations for Beginners 71 Fig. 47. Schematic view of the implementation of the variational quantum eigenvalue solver using a hybridclassical and quantum circuit. The figure is adopted from Ref. [79]. be automated easily using Qiskit. But the long queuing times in IBM Q makes repeated runs on thequantum processor impractical.To find the eigenvalue of a Hamiltonian, we could use the quantum phase estimation algorithmthat was discussed in Section IV. To do this we need the ability to perform controlled operationswith the unitary U = exp (− i H δt / ℏ ) , where δt is the time step. Then, by preparing different initialstates | ψ i ⟩ and repeating the phase estimation many times one can obtain, in principle, the wholespectrum of the eigenvalues and the corresponding eigenwave functions. For a general Hamiltonian,however, the implementation of a controlled U may be not straightforward. For realistic problems,the quantum phase estimation circuits have large depth. This requires qubits with long coherencetimes, which are not available at the time of writing. For CMP problems, we are mainly interestedin the lowest eigenvalue for most cases.To overcome these limitations, we use the recently developed variational quantum eigenvaluesolver (VQES) [74, 79]. The basic idea is to take the advantages of both quantum and classicalcomputers, as shown in Fig. 47. It allocates the classically easy tasks to classical computers and theother tasks to quantum computers. The algorithm is summarized as follows:(1) Prepare a variational state | ψ ( θ i )⟩ with parameters θ i . For an efficient algorithm, the numberof variational parameters should grow linearly with the system size.(2) Calculate the expectation value of the Hamiltonian using a quantum computer, E = ⟨ ψ |H | ψ ⟩/⟨ ψ | ψ ⟩ .(3) Use classical nonlinear optimizer algorithms to find new optimal θ i . In this report, we will usethe relaxation method τ ∂ t θ i = − ∂ E / ∂ θ i , where τ is a parameter to control the relaxationrate.(4) Iterate this procedure until convergence.VQES has the following advantage: For most CMP problems, where the interaction is local, wecan split the Hamiltonian into a summation over many terms. This means that we can parallelizethe algorithm to speed up the computation. The quantum expectation calculations for one termin the Hamiltonian are relatively simple, thus no long coherence times are not required. On the ℎ 𝑔 Quantum phase transition
Ferromagnetic phase Paramagentic phase
Fig. 48. Schematic view of the quantum phases described by the transverse Ising model. The arrows representthe spin configuration in the ordered and disordered phases. other hand, VQES also has limitations. Because of its variational nature, the trial wave functionneeds to be prepared carefully. This usually requires physical insights into the problem. The groundstate eigenvalue and eigenwave function are biased by the choice of the trial wave functions. Inaddition, VQES requires communications between classical and quantum computers, which couldbe a bottleneck for the performance.
We use VQES to find the ground state of the transverse Ising model (TIM) defined by H = − (cid:213) i σ zi σ zi + − h (cid:213) i σ xi , (92)where σ z , σ x are Pauli matrices and h is the external magnetic field. Let us first review briefly thephysical properties of this Hamiltonian. This Hamiltonian is invariant under the global rotation ofspin along the x axis by π , R x H R † x = H , where R x ( π ) is the rotation operator R x σ x R † x = σ x , R x σ z R † x = − σ z . (93)The TIM has two phases: When the transverse field h is small, the spins are ordered ferromagneticallyand the rotational symmetry associated with R x is broken. In the ordered phase, the quantumexpectation value ⟨ σ z ⟩ (cid:44)
0. As h is increased, there is a quantum phase transition from the orderedphase to the disordered phase where ⟨ σ z ⟩ =
0, as the rotational symmetry is restored. The phasediagram is shown schematically in Fig. 48.Using the phase diagram as a guide, first we propose a product state as a trial wave function.The wave function can be written as | ψ i ( θ i )⟩ = (cid:214) i U ( θ i )| i ⟩ . (94)Here U ( θ i ) is the unitary operation which describes the spin rotation along the y axis by an angle θ i , U ( θ i ) = (cid:18) cos ( θ i / ) − sin ( θ i / ) sin ( θ i / ) cos ( θ i / ) (cid:19) , where θ i are the variational parameters. Here we have used the Bloch sphere representation for aqubit state. For the TIM, we calculate the expectation value of E J , i = −⟨ ψ | σ zi σ zi + | ψ ⟩ , E Z , i = −⟨ ψ | σ xi | ψ ⟩ . (95)The quantum circuit to perform the preparation of the state and calculation of the expectationsvalue are shown in Fig. 49(a) andFig. 49(b) . We have E J , i = −[ P ( q i = ) − P ( q i = )][ P ( q i + = ) − P ( q i + = )] , (96) E Z , i = −[ P ( q i = ) − P ( q i = )] , (97) antum Algorithm Implementations for Beginners 73 (a) (b)(c)Fig. 49. Quantum circuits to prepare the trial wave-functions. The single qubit unitaries in the text can beimplemented using available gates in IBM Q. The first two circuits prepare unentangled trial states. Circuit (a)can be used to measure ⟨ ψ | σ z σ z | ψ ⟩ . Circuit (b) can be used to measure the ⟨ ψ | σ x | ψ ⟩ . Circuit (c) preparesthe entangled trial state. where P ( q i = , ) is the measured probability for the qubit q i in the | ⟩ or | ⟩ state. As we mentionedbefore, the communication bottleneck prevented us from implementing this on ibmqx4 . We ran thecode using the quantum simulator in Qiskit. The comparison of the results obtained from quantumsimulation and analytical results are shown in Fig. 50. Our trial wave function works very wellin the ordered phase, but the simulation results deviate from the exact solution in the quantumphase transition region. This discrepancy is caused by the fact that we have neglected the quantumentanglement in our trial wave function.In a second set of experiments, we use a trial wave function that includes quantum entanglement.Because of the symmetry, | Ψ i ( θ i )⟩ and R x ( π )| Ψ i ( θ i )⟩ are two degenerate wave functions withthe same energy. The trial wave function can be written as a linear superposition of these twodegenerate wave functions | ψ i ( θ i )⟩ = α | Ψ i ( θ i )⟩ + βR x ( π )| Ψ i ( θ i )⟩ . (98)The first step is to prepare | ψ i ( θ i )⟩ using quantum circuit. To prepare an arbitrary state in a quantumcircuit is not trivial as it requires of the order of 2 n CNOT gates, where n is the number of qubits [80].The state in Eq. (98) can be prepared easily using the circuit in Fig. 49(c). Here we consider 4 spins.The first U ( θ , ϕ ) operation transforms the state into | ⟩ → e iϕ sin ( θ / )| ⟩ + cos ( θ / )| ⟩ . The first CNOT transforms the state into e iϕ sin ( θ / )| ⟩ + cos ( θ / )| ⟩ . The second CNOT transforms the state into e iϕ sin ( θ / )| ⟩ + cos ( θ / )| ⟩ . ��� ��� ��� ��� ��� ��� ��� - ��� - ��� - ��� - ��� - ��� � � ���������� �� ��������� �������������� �� ��������� ��� ��� ��� ��� ��� ��� ��������������������� � � � ���������� �� ��������� �������������� �� ������������� ���� (a)(b) 𝐸 / 𝑁 Fig. 50. Comparison of the ground state energy (a) and average magnetization (b) M x = ⟨ ψ | (cid:205) i σ xi | ψ ⟩/ N obtained by using the trial wave functions in Eq. (94) and the exact results. Here we have used the periodicboundary condition. The simulations are run both on the quantum simulator (black symbols) and classicalcomputers (red symbols). The mean-field results (blue line) are also displayed for comparison. The third CNOT transforms the state into e iϕ sin ( θ / )| ⟩ + cos ( θ / )| ⟩ . Finally we apply U ( θ i ) rotation and we obtain the desired state in Eq. (98). Here U ( θ , ϕ ) = (cid:18) cos ( θ i / ) − sin ( θ i / ) e iϕ sin ( θ i / ) e iϕ cos ( θ i / ) (cid:19) . We then use VQES to find the ground state energy. As can be seen in Fig. 51, the new trialfunction nearly reproduces the exact results in the whole magnetic field region and improves uponthe product state trial function.
18 QUANTUM PARTITION FUNCTION18.1 Background on the partition function
Calculation or approximation of the partition function is a sub-step of inference problems in Markovnetworks [63]. Even for small networks, this calculation becomes intractable. Therefore an efficient antum Algorithm Implementations for Beginners 75 ���� ����� ����� ���� ������������������� ������� ������������ ��� ��� ��� ��� ��� ��� ��� - ��� - ��� - ��� - ��� - ��� - ������ � � / � N=4
Fig. 51. (color online) Comparison of the ground state energy obtained by using the trial wave functions inEqs. (94) and (98) and the exact result. Here we have used the periodic boundary condition. The number ofspins is 4. quantum algorithm for the partition function would make many problems in graphical modelinference and learning tractable and scalable; the same holds for other problems in computationalphysics [7, 46, 48, 49].The partition function is of particular interest for calculating probabilities from graphical modelssuch as Markov random fields [63]. For this article, we consider the graphical model form known asthe Potts model. Let Γ = ( E , V ) be a weighted graph with edge set E and vertex set V and n = | V | .In the q -state Potts model, each vertex can be in any of q discrete states. The Potts model is ageneralization of the classical Ising model. In the classical Ising model q =
2, whereas in the Pottsmodel q ≥
2. The edge connecting vertices i and j has a weight J ij which is also known as theinteraction strength between corresponding states. The Potts model Hamiltonian for a particularstate configuration σ = ( σ , . . . , σ n ) is H ( σ ) = − (cid:213) i ∼ j J ij δ σ i , σ j , (99)where i ∼ j indicates that there exists an edge between vertices i and j ; and where δ σ i , σ j = σ i = σ j and 0 otherwise.The probability of any particular configuration being realized in the Potts model at a giventemperature, T , is given by the Gibbs distribution: P ( σ ) = Z e − βH ( σ ) , (100)where β = /( k B T ) is the inverse temperature in energy units and k B is the Boltzmann constant.The normalization factor, Z , is also known as the partition function : Z = (cid:213) { σ } e − βH ( σ ) , (101) a bc (a) Graphwith threevertices andthree edges. abc − H ( σ ) J ab + J bc + J ac J ab J ac J bc J bc J ac J ab J ab + J bc + J ac (b)Fig. 52. (a) Simple example with (b) the enumeration of state configurations and the value of the Hamiltonianfor a fully-connected 3-vertex Ising model ( q = Potts model)
Irreducible cyclic code via Shor’s FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). U prep Classical preprocessing State preparation and quantum Fourier transform
QFT
Classical post-processing Gauss elimination [n,k] code [n,k] code
Shor’s alg Quit, if not ICCC { } FIG. 1:
This algorithm was discussed in Ref. XXX Need citation XX. It is then straightforward to calculate the eigenvaluesof ⌃ from P , as follows: e = Tr(⌃) ⇤ (1 + p P )) / (6) e = Tr(⌃) ⇤ (1 p P )) / . (7)As depicted in Fig. ?? , this simple algorithm is schematically divided up into four steps: classical pre-processing,state preparation, quantifying the purity, and classical post-processing. Classical Pre-processingState preparationQuantifying the purityClassical Post-processing | i Data vectors ! ⌃ ! ⇢ ! | i vector Algorithm implemented on IBM’s 5-qubit computer
Classical Post-processing
Conclusions
The advantage of RB it that it is insensitive to state-preparation and measurement errors (SPAM), and that it canbe implemented more efficiently on logical qubits than process tomography.The RB protocol goes as follows.1. Randomly choose a set of m elements from G , denoted G = { G , ..., G m } .2. Prepare qudit in state | i .3. Act on the qudit with unitary G j +1 G † j for j = 0 , .., m , with G = G m +1 = Q = { Q , Q } , where we typically take Q = | ih | .5. Repeat steps 2-4 many times into order to estimate p G := Pr( Q ) , the probability of obtaining outcome Q .6. Repeat steps 1-5 many times into order to estimate h p G i , the expectation value of p G (averaged over all G ). U prep Repeat for each { }{ A i } Z Fig. 53. Overview of the quantum partition function algorithm. where { σ } means the full set of all possible state configurations. There are q n possible stateconfigurations, and so this is a sum over a large number of items and is generally intractable aswell as difficult to approximate. The calculation of the partition function is We give a small example with a graph of n = V = { a , b , c } , with edges between all pairs of verticesfor three total edges, pictured in Figure 52a, and we use q = q n configurations into the partition functiongiven in Eq. (101) to get the normalization constant: Z = e β ( J ab + J bc + J ac ) + e β J ab + e β J bc + e β J ac . (102)Letting J ij = i ∼ j , gives: Z = e β + e β . (103) antum Algorithm Implementations for Beginners 77 Fig. 54. Circuit for preparing the first two qubits and quantum Fourier transform on 2 qubits.
An efficient quantum algorithm for the partition function is given by [49] for Potts models whosegraph, Γ , has a topology such that it can be represented with an irreducible cyclic cocycle code(ICCC). This stipulation is non-intuitive and it takes a quantum algorithm to efficiently determine ifa given graph meets this requirement. From the graph, Γ , calculate a cyclic code C ( Γ ) that representsthe generating structure of the graph by using Gaussian elimination on the incidence matrix of thegraph, and then use Shor’s algorithm to determine the irreducible set of code words χ . If the code isnot irreducible, then we will not be able to efficiently calculate the partition function for this graph.Assuming that the given graph is ICCC, the first step in the partition function algorithm isto calculate the Gauss sum of G F qk = (cid:112) q k e iγ , where γ is a function of χ . The difficult part is tocalculate γ , which can be done efficiently using the quantum Fourier transform (QFT). Using theset of values, { γ } for all of the words, { χ } in the code; we calculate the weight spectrum { A i } ofthe code representing Γ . From this weights spectrum, the partition function Z can be efficientlycalculated using classical computing. We implemented one step of the full partition function algorithm using the IBM Quantum Experience.The implemented algorithm is the 2-qubit quantum Fourier transform (QFT2), as the first stepin actual calculation of the partition function. The input to this step is the irreducible cocycliccode. The irreducible cyclic code for the example problem of a 3-vertex Ising model is [ , − ] with n = | V | = k = | E | − c ( Γ ) =
2, where c ( Γ ) is the number of connected components in the graph Γ . This small example does meet the ICCC requirement (as checked through classical calculation), sowe will continue with the calculation of the partition function of the example without implementingthe quantum algorithm for checking this requirement. In the fully-connected 3-vertex Ising modelexample given, the input to QFT2 is q [ ] = | + ⟩ = | ⟩ + | ⟩√ and q [ ] = |−⟩ = | ⟩−| ⟩√ . In the samplescore shown in Fig. 54, these qubits are prepared before the barrier. The QFT2 algorithm, as givenby the Qiskit Tutorial provided by IBM[3], is the rest of the code. The output bits should be read inreverse order. Some gates could be added at the end of the QFT2 algorithm to read the gates in thesame order as the input.The result from simulating 1000 shots gives P ( γ = ) = .
47 and P ( γ = ) = .
53. The resultsfrom running on the actual hardware are, P ( γ = ) = . P ( γ = ) = . P ( γ = ) = . P ( γ = ) = . than the maximum number (as given in [49]) of distinct values of gamma remain. These gammasare then plugged into the calculation of the weight spectrum and the partition function.
19 QUANTUM STATE PREPARATION
The problem of preparing an n -qubit state consists first of finding the unitary transformation thattakes the N -dimensional vector (1,0,. . . 0) to the desired state ( α , . . . , α N ), where N = n , and thenrendering the unitary transformation into a sequence of gates. As discussed before, a single qubit quantum state | ψ ⟩ is represented as a superposition of | ⟩ and | ⟩ states | ψ ⟩ = α | ⟩ + β | ⟩ , where | α | + | β | =
1. The sizes | α | and | β | represent the probabilityof | ψ ⟩ being | ⟩ or | ⟩ . Up to a non-observable global phase, we may assume that α is real, so that | ψ ⟩ = cos θ | ⟩ + e iϕ sin θ | ⟩ for some angles θ , ϕ . In this way, we can represent the state as a pointon the unit sphere with θ the co-latitude and ϕ the longitude. This is the well-known Bloch sphererepresentation . In this way, the problem of 1-qubit state preparation consists simply of finding theunitary transformation that takes the North pole to ( α , β ). In practice, this amounts to finding asequence of available gates on actual hardware that will leave the qubit in the desired state, to aspecified desired accuracy.To prepare a specified state | ψ ⟩ , we must find a 2 × U taking the vector | ⟩ to | ψ ⟩ . An obvious simple choice for U is U = (cid:18) cos θ − sin θe − iϕ sin θe iϕ cos θ (cid:19) This gate is directly available in IBM Q and is implemented in a composite fashion on ibmqx4 atthe hardware level. If our goal is to initialize a base state with the fewest possible standard gates,this may not be the best choice. Instead, it makes sense to consider a more general possible unitaryoperator whose first column is our desired base state, and then determine the requisite number ofstandard gates to obtain it.Any 2 × U = e iα R z ( β ) R y ( γ ) R z ( δ ) where here R z ( β ) = diag ( e iβ / , e − iβ / ) and R y ( γ ) is related to R z ( γ ) by R y ( γ ) = SHR z ( γ ) HSZ . Therotation matrices R y ( γ ) and R z ( β ) correspond to the associated rotations of the unit sphere underthe Bloch representation. In this way, the above decomposition is a reiteration of the standardEuler angle decomposition of elements of SO ( ) . Thus the problem of approximating an arbitraryquantum state is reduced to the problem of finding good approximations of R z ( γ ) for various valuesof γ .There has been a great deal of work done on finding efficient algorithms for approximatingelements R z ( γ ) using universal gates to a specified accuracy. However, these algorithms tend tofocus on the asymptotic efficiency: specifying approximations with the desired accuracy which arethe generically optimal in the limit of small errors. From a practical point of view, this is an issueon current hardware, since representations tend to involve hundreds of standard gates, far outsidethe realm of what may be considered practical. For this reason, it makes sense to ask the questionof how accurately one may initialize an arbitrary qubit with a specified number of gates.We empirically observe that the maximum possible chordal distance from a point on the Blochsphere to the set of exact states decreases exponentially with the number of gates. With 30 gates,every point is within a distance of 0 .
024 of a desired gate. Thus, to within an accuracy of about antum Algorithm Implementations for Beginners 79
Fig. 55. Possible exact state initializations using , , and gates. With gates, every point on the sphereis within a distance of approximately . of an exactly obtainable state. With gates, every point is within . The initialization of qubit states using more than one qubit is aided by the so-called Schmidtdecomposition, which we now introduce. Specifically, the Schmidt decomposition allows one toinitialize a 2 n -qubit state by initializing a single n -qubit state, along with two specific n -qubit gates,combined together with n CNOT gates.Mathematically, an arbitrary 2 n -qubit state | ψ ⟩ may be represented as a superposition | ψ ⟩ = (cid:213) i ,..., i n ∈{ , } (cid:213) j ,..., j n ∈{ , } a i ,..., i n , j ,..., j n | i i . . . i n j j . . . j n ⟩ . In a Schmidt decomposition, we obtain such a state by strategically choosing two orthonormalbases (cid:12)(cid:12) ξ j (cid:11) , (cid:12)(cid:12) φ j (cid:11) for j = , . . . , n of the Hilbert space of n -qubit states and then writing | ψ ⟩ as theproduct | ψ ⟩ = n (cid:213) i = λ i | ξ i ⟩ | φ i ⟩ , for some well-chosen λ i ’s.The bases (cid:12)(cid:12) ξ j (cid:11) and (cid:12)(cid:12) φ j (cid:11) may be represented in terms of two unitary matrices U , V ∈ U ( n ) , whilethe λ i ’s may be represented in terms of a single n -qubit state. We represent this latter state as B | . . . ⟩ for some B ∈ U ( n ) . Then from a quantum computing perspective, the product in theSchmidt decomposition may be accomplished by a quantum circuit combining U , V , and B with n CNOT gates as shown below for n = C ji denote the CNOT operator with control j and target i . Algebraically, the above circuitmay be written as a unitary operator T ∈ U ( n ) of the form T = ( U ⊗ V )( C n + ⊗ C n + ⊗ · · · ⊗ C n n )( B ⊗ I ) . We will use | e ⟩ , . . . , | e n ⟩ to denote the standard computational basis for the space of n -qubitstates, in the usual order. We view each of the elements e j as a vector in { , } n . In this notation,the formation of CNOT gates above acts on simple tensors by sending C n + ⊗ C n + ⊗ · · · ⊗ C n n : | e i ⟩ (cid:12)(cid:12) e j (cid:11) (cid:55)→ | e i ⟩ (cid:12)(cid:12) e i + e j (cid:11) , e i , e j ∈ { , } n , B • U • • • • • V Fig. 56. Schmidt decomposition. where addition in the above is performed modulo 2. Therefore the action of the operator T associatedto the above circuit on the basis vector | . . . ⟩ is T | . . . ⟩ = ( U ⊗ V )( C n + ⊗ C n + ⊗ · · · ⊗ C n n )( B ⊗ I ) | . . . ⟩ = ( U ⊗ V )( C n + ⊗ C n + ⊗ · · · ⊗ C n n ) n (cid:213) i = b i | e i ⟩ | e ⟩ = ( U ⊗ V ) n (cid:213) i = b i | e i ⟩ | e i ⟩ = n (cid:213) i = b i ( U | e i ⟩)( V | e i ⟩) = | ψ ⟩ . Thus we see that the above circuit performs precisely the sum desired from the Schmidt decompo-sition.To get the precise values of U , V , and B , we write | ψ ⟩ = (cid:205) n i , j = a ij | e i ⟩ (cid:12)(cid:12) e j (cid:11) for some constants a ij ∈ C and define A to be the 2 n × n matrix whose entries are the a ij ’s. Then comparing this toour previous expression for | ψ ⟩ , we see n (cid:213) i , j = a ij | e i ⟩ (cid:12)(cid:12) e j (cid:11) = n (cid:213) k = b k ( U | e k ⟩)( V | e k ⟩) . Multiplying on the left by ⟨ e i | (cid:10) e j (cid:12)(cid:12) this tells us a ij = n (cid:213) k = b k u ik v jk , where here u ik = ⟨ e i | U | e k ⟩ and v jk = (cid:10) e j (cid:12)(cid:12) V | e k ⟩ are the i , k ’th and j , k ’th entries of U and V ,respectively. Encoding this in matrix form, this tells us V diag ( b i , . . . , b in ) U T = A . Then to calculate the value of U , V and the b i ’s, we use the fact that V is unitary to calculate: A † A = U T † diag (| b i | , . . . , | b in | ) U T . Thus if we let | λ | , . . . , | λ n | be the eigenvalues of A † A , and let U to be a unitary matrix satisfying U T A † AU T † = diag (| λ | , . . . , | λ N | ) , antum Algorithm Implementations for Beginners 81 let b i = λ i for i = , . . . , n and let V = AU T † diag ( λ , . . . , λ n ) − . The matrix U is unitary, and one easily checks that V is therefore also unitary. Moreover (cid:205) i | b i | = Tr ( A † A ) = (cid:205) i | a ij | =
1, and so the b i ’s are representative of an n -qubit state and can be taken asthe first column of B . Readers familiar with singular value decompositions (SVD) will recognizethat the Schmidt decomposition of a bipartite state is essentially the SVD of the coefficient matrix A associated with the state. The λ i coefficients being the singular values of A . An arbitrary two-qubit state | ψ ⟩ is a linear combination of the four base states | ⟩ , | ⟩ , | ⟩ , | ⟩ such that the square sum of the magnitudes of the coefficients is 1. In terms of a quantum circuit,this is the simplest case of the circuit defined above in the Schmidt decomposition, and may beaccomplished with three 1-qubit gates and exactly 1 CNOT gate, as featured in Fig. 57. B • UV Fig. 57. Circuit for two qubit-state preparation. The choice of U , V , and B are covered comprehensively in theSchmidt decomposition description. In order to initialize a four-qubit state, we require the initialization of arbitrary two-qubit gates. Atwo-qubit gate may be represented as an element U of SU ( ) . As it happens, any element of U ( ) may be obtained by means of precisely 3 CNOT gates, combined with 7 1-qubit gates arranged in acircuit of the form given in Fig. 58. C R • AD • R R • B Fig. 58. Circuit implementation of an arbitrary two qubit gate.
The proof of this is nontrivial and relies on a characterization of the image of SU ( ) ⊗ in SU ( ) using the Makhlin invariants. We do not aim to reproduce the proof here. Instead, we merely aim toprovide a recipe by which one may successfully obtain any element of SU ( ) via the above circuitand an appropriate choice of the one-qubit gates.Let U ∈ SU ( ) be the element we wish to obtain. To choose A , B , C , D and the R i ’s, let C ij denotethe CNOT gate with control on qubit i and target qubit j and define α , β , δ by α = x + y , β = x + z , δ = y + z e ix , e iy , e iz the eigenvalues of the operator U ( Y ⊗ Y ) U T ( Y ⊗ Y ) . Then set R = R z ( δ ) , R = R y ( β ) , R = R y ( α ) , E = C ( S z ⊗ S x ) B • U • C R • A V • D • R R • B C S • A D • S S • B Fig. 59. Circuit for four qubit-state preparation. The four phases of the circuit are indicated in dashed boxes. and also V = e iπ / ( Z ⊗ I ) C ( I ⊗ R ) C ( R ⊗ R ) C ( I ⊗ S † z ) . Define (cid:101) U , (cid:101) V by (cid:101) U = E † U E and (cid:101) V = E † V E . Let (cid:101) A , (cid:101) B be the real, unitary matrices diagonalizing theeigenvectors of (cid:101) U (cid:101) U T and V (cid:101) V T , respectively. Set X = (cid:101) A T (cid:101) B and Y = V † (cid:101) B T (cid:101) AU . Then EX E † and EY E † are in SU ( ) ⊗ and we choose A , B , C , D such that ( AS † Z ) ⊗ ( Be iπ / ) = EX E † and C ⊗ ( S z D ) = EY E † . By virtue of this construction, the above circuit is algebraically identical to U . From the above results that any two-qubit state requires 1 CNOT gate, any two-qubit operatorrequires three CNOT gates, and the Schmidt decomposition, we see that we should be able to writea circuit initializating any four-qubit state with only 9 CNOT gates in total, along with 17 one-qubitgates. This represents the second most simple case of the Schmidt decomposition, which we writein combinantion with our generic expression for 2-qubit gates as shown in Fig. 59. The above circuitnaturally breaks down into four distinct stages, as shown by the separate groups surrounded bydashed lines. During the first stage, we initialize the first two qubits to a specific state relating to aSchmidt decomposition of the full 4 qubit state. Stage two consists of two CNOT gates relating thefirst and last qubits. Stages three and four are generic circuits representing the unitary operatorsassociated to the orthonormal bases in the Schmidt decomposition.The results of this circuit implemented on a quantum processor are given in Fig. 60. While theresults when implemented on a simulator are given in Fig. 61.
20 QUANTUM TOMOGRAPHY20.1 Problem definition and background
Quantum state estimation, or tomography, deals with the reconstruction of the state of a quantumsystem from measurements of several preparations of this state. In the context of quantum comput-ing, imagine that we start with the state | ⟩ , and apply some quantum algorithm (represented bya unitary matrix U ) to the initial state, thus obtaining a state | ψ ⟩ . We can measure this state in thecomputational z basis, or apply some rotation (represented by V ) in order to perform measurementsin a different basis. Quantum state tomography aims to answer the following question: is it possi-ble to reconstruct the state | ψ ⟩ from a certain number of such measurements? Hence, quantumtomography is not a quantum algorithm per se , but it is an important procedure for certifying theperformance of quantum algorithms and assessing the quality of the results that can be corruptedby decoherence, environmental noise, and biases, inevitably present in analogue machines, etc. antum Algorithm Implementations for Beginners 83 Fig. 60. Verification of qubit state preparation on ibmqx2 which is a qubit machine. The last qubit is notused in the circuit. The above histogram shows that, the state prepared in ibmqx2 has nonzero overlaps withbasis states that are orthogonal to the target state to be prepared.Fig. 61. Verification of the quantum circuit for four qubit-state preparation. The differences in the exactand the simulator results are due to statistical fluctuations arising from the probabilistic nature of quantummeasurement. They will become closer to each other when the number of samples are increased. Moreover similar procedures can be used for certifying the initial state, as well as for measuringthe fidelity of gates.A unique identification of state requires a sufficient number of tomographically complete measure-ments, meaning that the algorithm should be run several times. Unfortunately, because of the noise,it is impossible to obtain the exact same state | ψ ⟩ every time; instead, one should see a mixtureof different states: | ψ ⟩ , | ψ ⟩ , . . . , | ψ k ⟩ . In general, there does not exist a single | ψ ⟩ describing thismixture. Therefore, we need a to use the density matrix representation of quantum states. Webriefly discussed this representation in the context of quantum principal component analysis inSection XIV.Let us denote p i the probability of occurrence of the state | ψ i ⟩ . The density matrix of this ensembleis given by, ρ = (cid:213) i p i | ψ i ⟩⟨ ψ i | . (104) Using this more general definition of the state, the expected value of an observable A is given by ⟨ A ⟩ = (cid:205) i p i Tr ⟨ ψ i | A | ψ i ⟩ = Tr ( Aρ ) . The density matrix has the following properties: • Tr ρ =
1, i.e., probabilities sum to one; • ρ = ρ † , and ρ ≽
0, i.e., all eigenvalues are either positive or zero.In a popular setting for quantum tomography [77], the set of measurement operators P i are takenas projectors that form several Postive Operator-Valued Measures (POVM), i.e., they satisfy (cid:205) i P i = I .For single qubits, examples of such projectors in the computational basis are given by P = | ⟩⟨ | and P = | ⟩⟨ | , and in the x -basis by P ± = √ (| ⟩ ± | ⟩) ⊗ √ (⟨ | ± ⟨ |) . Assume that the set ofprojectors that we take represents a quorum , i.e., it provides sufficient information to identify thestate of the system in the limit of a large number of observations, and that for each subset forminga POVM, m measurements are collected. Given the occurrences m i for each projector P i , we candefine the associated empirical frequency as ω i = m i / m . Then the quantum tomography problemcan be stated as follows: reconstruct ρ from the set of couples of projectors and measurementfrequencies { P i , ω i } . In other words, we would like to “match” Tr ( P i ρ ) and ω i . The next sectionpresents a short overview of most popular general methods for the quantum state estimation. Most popular methods for quantum tomography in the general case include:(1)
Linear inversion.
In this method, we simply aim at inverting the system of equationsTr ( P i ρ ) = ω i . Although being fast, for a finite number of measurements thus obtainedestimation (cid:98) ρ does not necessarily satisfy (cid:98) ρ ≽ Linear regression.
This method corrects for the disadvantages of the linear inversion bysolving a constrained quadratic optimization problem [83]: (cid:98) ρ = argmin ρ (cid:213) i [ Tr ( P i ρ ) − ω i ] s.t. Tr ρ = ρ ≽ . The advantage of this method is that data does not need to be stored, but only the currentestimation can be updated in the streaming fashion. However, this objective function implicitlyassumes that the residuals are Gaussian-distributed, which does not necessarily hold inpractice for a finite number of measurements.(3)
Maximum likelihood.
In this by far most popular algorithm for quantum state estimation,one aims at maximizing the log-probability of observations [54, 56]: (cid:98) ρ = argmax ρ (cid:213) i ω i ln Tr ( P i ρ ) s.t. Tr ρ = ρ ≽ . This is a convex problem that outputs a positive semidefinite (PSD) solution (cid:98) ρ ≽
0. However,it is often stated that the maximum likelihood (ML) method is slow, and several recent papersattempted to develop faster methods of gradient descent with projection to the space of PSDmatrices, see e.g. [90]. Among other common criticisms of this method one can name the factthat ML might yield rank-deficient solutions, which results in an infinite conditional entropythat is often used as a metric of success of the reconstruction.(4)
Bayesian methods.
This is a slightly more general approach compared to the ML methodwhich includes some prior [18], or corrections to the basic ML objective, see e.g., the so-calledHedged ML [17]. However, it is not always clear how to choose these priors in practice.Markov Chain Monte Carlo Methods that are used for general priors are known to be slow.Let us mention that there exist other state reconstruction methods that attempt to explore aparticular known structure of the density matrix, such as compressed-sensing methods [51] in the antum Algorithm Implementations for Beginners 85
Fig. 62. Left: measurements of the single qubit state after the application of the Hadamard gate, in z , y and x basis. Right: experimental setup for testing the effects of decoherence. case of low-rank solutions, and matrix product states [33] or neural networks based approaches [104]for pure states with limited entanglement, etc . One of the points we can conclude from this sectionis that the ultimately best general method for the quantum state tomography is not yet known.However, it seems that maximum likelihood is still the most widely discussed method in theliterature; in what follows, we implement and test ML approach to quantum tomography on theIBM quantum computer. We present an efficient implementation of the ML method using a fast gradient descent with anoptimal 2-norm projection [97] to the space of PSD matrices. In what follows, we apply quantumtomography to study the performance of the IBM Q.
Let us start with a simple one-qubit case of the Hadamard gate, seeFig. 62, Left. This gate transforms the initial qubit state | ⟩ as follows: H : | ⟩ → | + ⟩ x = √ (| ⟩ + | ⟩) ,so that the density matrix should be close to ρ = | + ⟩ x ⟨ + | x . In the limit of a large number ofmeasurements, we expect to see the following frequencies in the z , y , and x basis (all vectorexpressions are given in the computational basis): (cid:20) (cid:21) → , (cid:20) (cid:21) → , √ (cid:20) i (cid:21) → , √ (cid:20) − i (cid:21) → , √ (cid:20) (cid:21) → , √ (cid:20) − (cid:21) → . We learn the estimated density matrix (cid:98) ρ from measurements in each basis using the maximumlikelihood method, and look at the decomposition: (cid:98) ρ = λ | ψ ⟩⟨ ψ | + λ | ψ ⟩⟨ ψ | , which would allow us to see what eigenstates contribute to the density matrix, and what is theirweight. Indeed, in the case of ideal observations we should get λ =
1, with | ψ ⟩ = (cid:104) √ √ (cid:105) T , and λ = | ψ ⟩ = (cid:104) √ − √ (cid:105) T , corresponding to the original pure state associated with | + ⟩ x .Instead, we obtain the following results for the eigenvalues and associated eigenvectors after8152 measurements (the maximum number in one run on IBM QX) in each basis ( z , y , x ) : λ = . → (cid:20) . − . i . (cid:21) , λ = . → (cid:20) . − . i − . (cid:21) , i.e., in 96% of cases we observe the state close to | + ⟩ x , and the rest corresponds to the state whichis close to |−⟩ x . Note that the quantum simulator indicates that this amount of measurements issufficient to estimate matrix elements of the density matrix with an error below 10 − in the idealnoiseless case. In order to check the effect of decoherence, we apply a number of identity matrices(Fig. 62, Right) which forces an additional waiting on the system, and hence promotes decoherence Fig. 63. Left: example of a measurement of the two-qubit maximally entangled state created with thecombination of H , X and CNOT gates in the yz basis. Right: experimental setup for testing the effects ofdecoherence. of the state. When applying 18 identity matrices, we obtain the following decomposition for (cid:98) ρλ = . → (cid:20) . − . i . (cid:21) , λ = . → (cid:20) . − . i − . (cid:21) , while application of 36 identity matrices results in λ = . → (cid:20) . − . i . (cid:21) , λ = . → (cid:20) . − . i − . (cid:21) . The effect of decoherence is visible in both more frequent occurrence of the state that is close to |−⟩ x , but also in the degradation of the eigenstates. Let us now study the two-qubits maximallyentangled state, which is an important part of all quantum algorithms achieving quantum speed-upover their classical counterparts. The state √ (| ⟩ + | ⟩) we are interested in is produced by thecombination of H , X and CNOT gates as shown in Fig. 63, Left. We follow the same procedure asin the case of the Hadamard gate, described above, and first estimate the density matrix (cid:98) ρ using8152 measurements for each of the zz , yy , xx , zx and yz basis, and then decompose it as (cid:98) ρ = (cid:205) i = λ i | ψ i ⟩⟨ ψ i | . Once again, ideally we should get λ = | ψ ⟩ = (cid:104) √ √ (cid:105) T .Instead, the analysis of the leading eigenvalues indicates that the eigenstate which is close (althoughsignificantly distorted) to the theoretical “ground truth” | ψ ⟩ above occurs in the mixture only withprobability 0 . λ = . → − . − . i . . − . − . i , λ = . → . . + . i − . − . i . − . i . Our test of decoherence implemented using 18 identity matrices (see Figure 63, Right) shows thatthe probability of the “original” entangled state decreases to 0 . λ = . → − . − . i . . − . − . i , λ = . → . − . − . i . + . i . + . i . Interestingly enough, the second most probable eigenstate changes to the one that is close to | ⟩ .This might serve as an indication of the presence of biases in the machine. antum Algorithm Implementations for Beginners 87 The application of the quantum tomography state reconstruction to simple states in the IBMQX revealed an important level of noise and decoherence present in the machine. It would beinteresting to check if the states can be protected by using the error correction schemes, which isthe subject of the next section.
21 TESTS OF QUANTUM ERROR CORRECTION IN IBM Q
In this section, we study whether quantum error correction (QEC) can improve computationaccuracy in ibmqx4 . The practical answer to this question seems to be “No”. Although some errorcorrection effects are observed in ibmqx4 , improvements are not exponential and get completelyspoiled by errors induced by extra gates and qubits needed for the error correction protocols.
As we have seen throughout this review, the quality of computation on actual quantum processorsis degraded by errors in the system. This is because currently available chips are not fault tolerant . Itis widely believed that once the inherent error rates of a quantum processor is sufficiently lowered,fault tolerant quantum computation will be possible using quantum error correction (QEC). Thecurrent error rates of the IBM Q machines are not small enough to allow fault tolerant computation.We refer the reader to a survey and introduction on QEC [37], while at the same time offering analternative point of view that we support with a few experiments on the IBM chip. The centralidea of QEC is to use entanglement to encode quantum superposition in a manner which is robustto errors. The exact encoding depends upon the kind of errors we want to protect against. In thissection we will look at a simple encoding that will protect against bit flip errors. Here we encode asingle qubit state, | ψ ⟩ = C | ⟩ + C | ⟩ , (105)using an entangled state, such as | ψ ⟩ = C | ⟩ ⊗ n q + C | ⟩ ⊗ n q , (106)where n q is the number of qubits representing a single qubit in calculations.The assumption is that small probability errors will likely lead to unwanted flips of only onequbit (in case when n q > highly correlated dynamics of all entangledqubits. We point out that errors introduced by such gates have essentially different nature fromrandom uncorrelated qubit flips. Hence, gate-induced errors may not be treatable by standard errorcorrection strategies when transitions are made between arbitrary unknown quantum state.To explore this point, imagine that we apply a gate that rotates a qubit by an angle π /
2. Itswitches superposition states | ψ ± ⟩ = (| ⟩ ± | ⟩)/√ | ⟩ or | ⟩ in the measurementbasis. Let the initial state be | ψ + ⟩ but we do not know this before the final measurement. Initially,we know only that initial state can be either | ψ + ⟩ or | ψ − ⟩ . To find what it is, we rotate qubit to themeasurement basis. The gate is not perfect, so the final state after the gate application is | u ⟩ = cos ( δϕ )| ⟩ + sin ( δϕ )| ⟩ , (107) Fig. 64. Quantum circuit that creates the state | + ⟩ = (| ⟩ + | ⟩)/√ then applies 16 T-gates that are equivalentto the identity operation, and then applies the gate that transforms the entangled state into the trivial state | ⟩ . with some error angle δϕ ≪
1. Measurement of this state would produce the wrong answer 1 withprobability P ≈ ( δϕ ) . (108)The value 1 − P is called the fidelity of the gate. In IBM chip it is declared to be 0.99 at the timeof writing, which is not much. It means that after about 30 gates we should loose control. Errorcorrection strategies can increase the number of allowed gates by an order of magnitude even atsuch a fidelity if we encode one qubit in three.In order to reduce this error, we can attempt to work with the 3-qubit version of the states inEq. (106). For example, let us consider the desired gate that transfers states |±⟩ = (| ⟩ ± | ⟩)/√ , (109)into states | ⟩ and | ⟩ in the measurement basis, respectively. This gate is protected in thesense that a single unwanted random qubit flip leads to final states that are easily corrected bymajority voting.However, this is not enough because now we have to apply the gate that makes a rotation by π / | u ⟩ = cos ( δϕ )| ⟩ + sin ( δϕ )| ⟩ , (110)i.e., this particular error cannot be treated with majority voting using our scheme because it flipsall three qubits. On the other hand, this is precisely the type of errors that is most important whenwe have to apply many quantum gates because basic gate errors are mismatches between desiredand received qubit rotation angles irrespectively of how the qubits are encoded. With nine qubits,we could protect the sign in Eq. 110 but this was beyond our hardware capabilities.Based on these thoughts, traditional QEC may not succeed in achieving exponential suppressionof errors related to non-perfect quantum gate fidelity. The latter is the main source of decoherencein quantum computing that involves many quantum gates. As error correction is often called theonly and first application that matters before quantum computing becomes viable at large scale,this problem must be studied seriously and expeditiously. In the following subsection we report onour experimental studies of this problem with IBM’s 5-qubit chip. First, let us perform trivial operation shown in Fig. 64: we create a superposition of two qubit states | + ⟩ = (| ⟩ + | ⟩)/√ , (111) antum Algorithm Implementations for Beginners 89 Fig. 65. Quantum circuit that creates state |−⟩ = (| ⟩ − | ⟩)/√ then applies 16 T-gates that are equivalentto the identity operation, and then applies the gate that transforms the entangled GHZ state back into thetrivial state | ⟩ . Measurements that return 1 for only one of the three qubits are interpreted as the | ⟩ state at the end, while outcomes with two or three units are interpreted as the final state | ⟩ . then apply many gates that altogether do nothing, i.e., they just bring the qubit back to thesuperposition state (111). We need those gates just to accumulate some error while the qubit’s stateis not trivial in the measurement basis. Finally, we apply the gate that transforms its state back to | ⟩ .Repeated experiments with measurements then produced wrong answer 13 times from 1000samples. Thus, we estimate the error of the whole protocol, which did not use QEC, as P = . , or 1.6%. This is consistent and even better than declared 1% single gate fidelity because we appliedtotally 18 gates. Next, we consider the circuit in Fig. 65 that initially creates the GHZ state |−⟩ = (| ⟩ − | ⟩)/√ T -gates that lead to the same GHZ state. Then we applythe sub-circuit that brings the whole state back to | ⟩ .Our goal is to quantify the precision of identifying the final result with the state | ⟩ . If a singleerror bit flip happens, we can interpret results | ⟩ , | ⟩ and | ⟩ as | ⟩ using majority voting.If needed, we can then apply a proper pulse to correct for this. So, in such cases we can consider theerror treatable. If the total sum of probabilities of the final state | ⟩ and final states with a singlebit flipped is larger than P from the previous single-qubit test, then we say that the quantum errorcorrection works, otherwise, it doesn’t. Our experiments showed that probabilities of events thatlead to wrong final interpretation are as follows: P = . , P = . , P = . , P = . . Thus, the probability to get the wrong interpretation of the result as the final state | ⟩ of theencoded qubit is P = P + P + P + P = . , while the probability to get any error 1 − P = . Comparing results of the tests without and with QEC, we find that the implementation of a simpleversion of QEC does not improve the probability to interpret the final outcome correctly. Theerror probability of calculations without QEC gives a smaller probability of wrong interpretation, P = . P = . P = .
02 is close to the probability of a single bit flip event P = . | ⟩ in 84% ofsimulations. If the remaining errors were produced by uncorrelated bit flips, we would see outcomeswith more than one wrong bit flip with total probability less than 1% but we found that such eventshave a much larger total probability P = . | ⟩ with 4.7% precision, versus the initially 16%in the wrong state. So, at least some part of the errors can be treated. However, an efficient errorcorrection must show exponential suppression of errors, which was not observed in this test.Summarizing, this brief test shows no improvements that would be required for efficient quantumerror correction. The need to use more quantum gates and qubits to correct errors only leads toa larger probability of wrong interpretation of the final state. This problem will likely becomeincreasingly much more important because without quantum error correction the whole ideaof conventional quantum computing is not practically useful. Fortunately, IBM’s quantum chipscan be used for experimental studies of this problem. We also would like to note that quantumcomputers can provide computational advantages beyond standard quantum algorithms and usingonly classical error correction [95]. So, they must be developed even if problems with quantumerror correction prove detrimental for conventional quantum computing schemes at achievablehardware quality. ACKNOWLEDGMENTS
We would like to acknowledge the help from numerous readers who pointed out errors and misprintsin the earlier version of the manuscript. The code and implementations accompanying the papercan be found at https://github.com/lanl/quantum_algorithms.
REFERENCES [1] ibmq-device-information. https://github.com/Qiskit/ibmq-device-information/tree/master/backends/tenerife/V1.Accessed: 14-12-2019.[2] Scott Aaronson and Lijie Chen. Complexity-theoretic foundations of quantum supremacy experiments. In RyanO’Donnell, editor, , volume 79 of
LIPIcs , pages 22:1–22:67. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2017.[3] Héctor Abraham, Ismail Yunus Akhalwaya, Gadi Aleksandrowicz ...., and yotamvakninibm. Qiskit: An open-sourceframework for quantum computing, 2019.[4] A. Ambainis, H. Buhrman, P. Høyer, M. Karpinski, and P. Kurur. Quantum matrix verification. 2002.[5] Andris Ambainis. Quantum walk algorithm for element distinctness.
SIAM Journal on Computing , 37(1):210–239,2007.[6] Andris Ambainis and R. Spalec. Quantum algorithms for matching and network flows. in Lecture Notes in ComputerScience: STACS 2006 , 3884, 2006.[7] Itai Arad and Zeph Landau. Quantum computation and the evaluation of tensor networks.
SIAM Journal on Computing ,39(7):3089–3121, 2010.[8] Frank Arute, Kunal Arya, Ryan Babbush, Dave Bacon, Joseph C Bardin, Rami Barends, Rupak Biswas, Sergio Boixo,Fernando GSL Brandao, David A Buell, et al. Quantum supremacy using a programmable superconducting processor.
Nature , 574(7779):505–510, 2019. antum Algorithm Implementations for Beginners 91 [9] Dave Bacon, Isaac L Chuang, and Aram W Harrow. The quantum schur and clebsch-gordan transforms: I. efficientqudit circuits. pages 1235–1244, 2007.[10] Dave Bacon and Wim Van Dam. Recent progress in quantum algorithms.
Communications of the ACM , 53(2):84–93,2010.[11] Stefanie Barz, Ivan Kassal, Martin Ringbauer, Yannick Ole Lipp, Borivoje Dakić, Alán Aspuru-Guzik, and PhilipWalther. A two-qubit photonic quantum processor and its application to solving systems of linear equations.
Scientificreports , 4, 2014.[12] Robert Beals. Quantum computation of Fourier transforms over symmetric groups .
In Proceedings of STOC , pages48–53, 1997.[13] Giuliano Benenti and Giuliano Strini. Quantum simulation of the single-particle Schrödinger equation.
AmericanJournal of Physics , 76(7):657–662, 2008.[14] Charles H Bennett, Ethan Bernstein, Gilles Brassard, and Umesh Vazirani. Strengths and weaknesses of quantumcomputing.
SIAM journal on Computing , 26(5):1510–1523, 1997.[15] E. Bernstein and U. Vazirani. Quantum complexity theory. In
Proc. of the Twenty-Fifth Annual ACM Symposium onTheory of Computing (STOC ’93) , pages 11–20, 1993. DOI:10.1145/167088.167097.[16] Dominic W Berry, Graeme Ahokas, Richard Cleve, and Barry C Sanders. Efficient quantum algorithms for simulatingsparse hamiltonians.
Communications in Mathematical Physics , 270(2):359–371, 2007.[17] Robin Blume-Kohout. Hedged maximum likelihood quantum state estimation.
Physical review letters , 105(20):200504,2010.[18] Robin Blume-Kohout. Optimal, reliable estimation of quantum states.
New Journal of Physics , 12(4):043034, 2010.[19] Otakar Borůvka. O jistém problému minimálním.
Práce Mor. Přírodově d. spol. v Brnř (Acta Societ. Scient. Natur.Moravicae) , 3:37–58, 1926.[20] Michel Boyer, Gilles Brassard, Peter Høyer, and Alain Tapp. Tight bounds on quantum searching.
Fortschritte derPhysik: Progress of Physics , 46(4-5):493–505, 1998.[21] G. Brassard et al. Quantum amplitude amplification and estimation.
Quantum Computation and Quantum Information ,9, 2002.[22] Carlos Bravo-Prieto, Ryan LaRose, Marco Cerezo, Yigit Subasi, Lukasz Cincio, and Patrick J Coles. Variational quantumlinear solver: A hybrid algorithm for linear systems. arXiv preprint arXiv:1909.05820 , 2019.[23] H. Buhrman and R. Spalek. Quantum verification of matrix products.
Proceedings of the seventeenth annual ACM-SIAMsymposium on Discrete algorithm , pages 880–889, 2006.[24] X.-D. Cai, C. Weedbrook, Z.-E. Su, M.-C. Chen, M. Gu, M.-J. Zhu, L. Li, N.-L. Liu, C.-Y. Lu, and J.-W. Pan. ExperimentalQuantum Computing to Solve Systems of Linear Equations.
Physical Review Letters , 110(23):230501, June 2013.[25] Kevin K. H. Cheung and Michele Mosca. Decomposing finite abelian groups.
Quantum Info. Comput. , 1(3):26–32,October 2001.[26] Andrew M Childs and Wim Van Dam. Quantum algorithms for algebraic problems.
Reviews of Modern Physics , 82(1):1,2010.[27] Lukasz Cincio, Yiğit Subaşı, Andrew T Sornborger, and Patrick J Coles. Learning the quantum algorithm for stateoverlap.
New Journal of Physics , 20(11):113022, 2018.[28] Jill Cirasella. Classical and quantum algorithms for finding cycles.
MSc Thesis , pages 1–58, 2006.[29] C. Codsil and H. Zhan. Discrete-time quantum walks and graph structures. pages 1–37, 2011.[30] Rigetti Computing. Quantum approximate optimization algorithm. Published online at https://github.com/rigetticomputing/grove, 2017. Accessed: 12/01/2017.[31] Stephen A. Cook. The complexity of theorem-proving procedures. In
Proceedings of the Third Annual ACM Symposiumon Theory of Computing , STOC ’71, pages 151–158, New York, NY, USA, 1971. ACM.[32] D. Coppersmith and S. Winograd. Matrix multiplication via arithmetic progressions.
Journal of symbolic computation ,(9):251–280, 1990.[33] Marcus Cramer, Martin B Plenio, Steven T Flammia, Rolando Somma, David Gross, Stephen D Bartlett, OlivierLandon-Cardinal, David Poulin, and Yi-Kai Liu. Efficient quantum state tomography.
Nature communications , 1:149,2010.[34] Sanjoy Dasgupta, Christos H. Papadimitriou, and Umesh Vazirani.
Algorithms . McGraw-Hill, Inc., New York, NY,USA, 2008.[35] M. Dehn. Über unendliche diskontinuierliche gruppen.
Mathematische Annalen , 71(1):116–144, Mar 1911.[36] D. Deutsch and R. Jozsa. Rapid solutions of problems by quantum computation. In
Proc. of the Royal Society of LondonA , pages 439–553, 1992.[37] Simon J Devitt, William J Munro, and Kae Nemoto. Quantum error correction for beginners.
Reports on Progress inPhysics , 76(7):076001, 2013. [38] B. L. Douglas and J. B. Wang. Efficient quantum circuit implementation of quantum walks.
Physical Review A ,79(5):052335, 2009.[39] Christoph Dürr, Mark Heiligman, Peter Høyer, and Mehdi Mhalla. Quantum query complexity of some graphproblems.
SIAM Journal on Computing , 35(6):1310–1328, 2006.[40] Christoph Durr and Peter Hoyer. A quantum algorithm for finding the minimum. arXiv preprint quant-ph/9607014 ,1996.[41] Jack Edmonds and Richard M. Karp. Theoretical improvements in algorithmic efficiency for network flow problems.
Journal of the ACM , 19 (2):248–264, 1972.[42] Nayak F. Magniez A, J. Roland, and M. Santha. Search via quantum walk.
SIAM Journal on Computing , 40(1):142–164,2011.[43] Edward Farhi, Jeffrey Goldstone, and Sam Gutmann. A quantum approximate optimization algorithm, 2014.[44] L. R. Ford and D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics , 8:399–404, 1956.[45] R. Freivalds. Fast probabilistic algorithms.
In Proc. of 8th Symp. on Math. Foundations of Computer Science , pages57–69, 1979.[46] Silvano Garnerone, Annalisa Marzuoli, and Mario Rasetti. Efficient quantum processing of 3-manifold topologicalinvariants. arXiv preprint quant-ph/0703037 , 2007.[47] Iulia M Georgescu, Sahel Ashhab, and Franco Nori. Quantum simulation.
Reviews of Modern Physics , 86(1):153, 2014.[48] Joseph Geraci. A new connection between quantum circuits, graphs and the ising partition function.
QuantumInformation Processing , 7(5):227–242, 2008.[49] Joseph Geraci and Daniel A Lidar. On the exact evaluation of certain instances of the Potts partition function byquantum computers.
Communications in Mathematical Physics , 279(3):735–768, 2008.[50] Vittorio Giovannetti, Seth Lloyd, and Lorenzo Maccone. Quantum random access memory. 100:160501, 04, 2008.[51] David Gross, Yi-Kai Liu, Steven T Flammia, Stephen Becker, and Jens Eisert. Quantum state tomography viacompressed sensing.
Physical review letters , 105(15):150401, 2010.[52] Lov K Grover. A fast quantum mechanical algorithm for database search. In
Proceedings of the twenty-eighth annualACM symposium on Theory of computing , pages 212–219. ACM, 1996.[53] Aram W Harrow, Avinatan Hassidim, and Seth Lloyd. Quantum algorithm for linear systems of equations.
Physicalreview letters , 103(15):150502, 2009.[54] Zdenek Hradil. Quantum-state estimation.
Physical Review A , 55(3):R1561, 1997.[55] IBM Corporation. IBM Quantum Experience. Published online at https://quantumexperience.ng.bluemix.net, 2016.Accessed: 12/01/2017.[56] Daniel F. V. James, Paul G. Kwiat, William J. Munro, and Andrew G. White. Measurement of qubits.
Phys. Rev. A ,64:052312, 2001.[57] Sonika Johri, Damian S Steiger, and Matthias Troyer. Entanglement spectroscopy on a quantum computer.
PhysicalReview B , 96(19):195136, 2017.[58] Stephan Jordan. Quantum Algorithm Zoo. Published online at https://math.nist.gov/quantum/zoo/, 2011. Accessed:3/18/2018.[59] Stephen P. Jordan. Fast quantum algorithms for approximating some irreducible representations of groups . pages1–21, 2009.[60] Petteri Kaski. Eigenvectors and spectra of cayley graphs, 2002.[61] J. Kempe. Quantum random walks - an introductory overview.
Contemporary Physics , 44(4):307–327, 2003.[62] V. Kendon. Where to quantum walk. pages 1–13, 2011.[63] Daphne Koller and Nir Friedman.
Probabilistic graphical models: principles and techniques . Adaptive Computationand Machine Learning. MIT Press, 2009.[64] M W Krentel. The complexity of optimization problems. In
Proceedings of the Eighteenth Annual ACM Symposium onTheory of Computing , STOC ’86, pages 69–76, New York, NY, USA, 1986. ACM.[65] Thaddeus D Ladd, Fedor Jelezko, Raymond Laflamme, Yasunobu Nakamura, Christopher Monroe, and Jeremy LloydO’Brien. Quantum computers.
Nature , 464(7285):45, 2010.[66] R. LaRose, A. Tikku, É. O’Neel-Judy, L. Cincio, and P. J. Coles. Variational quantum state diagonalization. npj QuantumInformation , 5(1):57, 2019.[67] R. J. Lipton and K. W. Regan. Quantum algorithms via linear algebra. 2014.[68] Seth Lloyd, Silvano Garnerone, and Paolo Zanardi. Quantum algorithms for topological and geometric analysis ofdata.
Nature Communications , 2015.[69] Seth Lloyd, Masoud Mohseni, and Patrick Rebentrost. Quantum algorithms for supervised and unsupervised machinelearning. arXiv preprint arXiv:1307.0411 , 2013.[70] Seth Lloyd, Masoud Mohseni, and Patrick Rebentrost. Quantum principal component analysis.
Nature Physics ,10(9):631–633, 2014. antum Algorithm Implementations for Beginners 93 [71] Neil B Lovett, Sally Cooper, Matthew Everitt, Matthew Trevers, and Viv Kendon. Universal quantum computationusing the discrete-time quantum walk.
Physical Review A , 81(4):042330, 2010.[72] Frederic Magniez, Miklos Santha, and Mario Szegedy. Quantum algorithms for the triangle problem.
SIAM J. Comput. ,pages 413–424, 2007.[73] Enrique Martin-Lopez, Anthony Laing, Thomas Lawson, Roberto Alvarez, Xiao-Qi Zhou, and Jeremy L O’brien.Experimental realization of shor’s quantum factoring algorithm using qubit recycling.
Nature photonics , 6(11):773–776,2012.[74] Jarrod R McClean, Jonathan Romero, Ryan Babbush, and Alán Aspuru-Guzik. The theory of variational hybridquantum-classical algorithms.
New Journal of Physics , 18(2):023023, 2016.[75] Ashley Montanaro. Quantum algorithms: an overview. npj Quantum Information , 2:15023, 2016.[76] Michele Mosca. Quantum algorithms. In
Computational Complexity , pages 2303–2333. Springer, 2012.[77] Michael A. Nielsen and Isaac L. Chuang.
Quantum Computation and Quantum Information . Cambridge UniversityPress, Cambridge, United Kingdom, 2016. 10th Anniversary Edition.[78] Karl Pearson. On lines and planes of closest fit to systems of points in space.
Philosophical Magazine Series 6 ,2(11):559–572, 1901.[79] Alberto Peruzzo, Jarrod McClean, Peter Shadbolt, Man-Hong Yung, Xiao-Qi Zhou, Peter J. Love, Alán Aspuru-Guzik,and Jeremy L. O’Brien. A variational eigenvalue solver on a photonic quantum processor.
Nature Communications ,5:ncomms5213, July 2014.[80] Martin Plesch and Časlav Brukner. Quantum-state preparation with universal gate decompositions.
Phys. Rev. A ,83:032302, 2011.[81] Carl Pomerance. A tale of two sieves.
Notices Amer. Math. Soc , 43:1473–1485, 1996.[82] John Preskill. Quantum computing and the entanglement frontier.
Rapporteur talk at the 25th Solvay Conference onPhysics, 19-22 October 2011 .[83] Bo Qi, Zhibo Hou, Li Li, Daoyi Dong, Guoyong Xiang, and Guangcan Guo. Quantum state tomography via linearregression estimation.
Scientific reports , 3, 2013.[84] Patrick Rebentrost, Masoud Mohseni, and Seth Lloyd. Quantum support vector machine for big data classification.
Physical review letters , 113(13):130503, 2014.[85] E. Riefful and W. Polak. Quantum computing: A gentle introduction. 2011.[86] R. L. Rivest, A. Shamir, and L. Adleman. A method for obtaining digital signatures and public-key cryptosystems.
Commun. ACM , 21(2):120–126, February 1978.[87] Mehdi Saeedi and Igor L Markov. Synthesis and optimization of reversible circuits - a survey.
ACM ComputingSurveys (CSUR) , 45(2):21, 2013.[88] Miklos Santha. Quantum walk based search algorithms. In
International Conference on Theory and Applications ofModels of Computation , pages 31–46. Springer, 2008.[89] N. Santhi. Quantum Netlist Compiler (QNC) software repository, November 2017. Applied for LANL LACCauthorization for unlimited open-source release, December 2017.[90] Jiangwei Shang, Zhengyun Zhang, and Hui Khoon Ng. Superfast maximum-likelihood reconstruction for quantumtomography.
Physical Review A , 95(6):062336, 2017.[91] Vivek V. Shende and Igor L. Markov. On the CNOT-cost of TOFFOLI gates.
Quant. Inf. Comp. , 9(5-6):461–486, 2009.[92] Neil Shenvi, Julia Kempe, and K Birgitta Whaley. Quantum random-walk search algorithm.
Physical Review A ,67(5):052307, 2003.[93] Peter W Shor. Algorithms for quantum computation: Discrete logarithms and factoring. In
Foundations of ComputerScience, 1994 Proceedings., 35th Annual Symposium on , pages 124–134. IEEE, 1994.[94] Peter W. Shor. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer.
SIAM Journal on Computing , 26(5):1484–1509, 1997.[95] Nikolai A Sinitsyn. Computing with a single qubit faster than the computation quantum speed limit.
Physics LettersA , 382(7):477–481, 2018.[96] Robert S. Smith, Michael J. Curtis, and William J. Zeng. A practical quantum instruction set architecture, 2016.[97] John A Smolin, Jay M Gambetta, and Graeme Smith. Efficient method for computing the maximum-likelihoodquantum state from measurements with additive gaussian noise.
Physical review letters , 108(7):070502, 2012.[98] Rolando D Somma. Quantum simulations of one dimensional quantum systems.
Quantum Information & Computation ,16(13-14):1125–1168, 2016.[99] Robert Spalek et al.
Quantum algorithms, lower bounds, and time-space tradeoffs . ILLC,Amsterdam, 2006.[100] V. Strassen. Gaussian elimination is not optimal.
Numerische Mathematik , (13):354–356, 1969.[101] Yiğit Subaşı, Rolando D Somma, and Davide Orsucci. Quantum algorithms for systems of linear equations inspiredby adiabatic quantum computing.
Physical review letters , 122(6):060504, 2019. [102] J. A. K. Suykens and J. Vandewalle. Least squares support vector machine classifiers.
Neural Process. Lett. , 9(3):293–300,June 1999.[103] IBM QX Team. IBM Q experience backend information. http://github.com/QISKit/ibmqx-backend-information, 2017.Last accessed: 12 December, 2017.[104] Giacomo Torlai, Guglielmo Mazzola, Juan Carrasquilla, Matthias Troyer, Roger Melko, and Giuseppe Carleo. Neural-network quantum state tomography.
Nature Physics , 14(5):447, 2018.[105] Jaw-Shen Tsai. Toward a superconducting quantum computer.
Proceedings of the Japan Academy, Series B , 86(4):275–292, 2010.[106] L. M. K. Vandersypen, M. Steffen, G. Breyta, C. S. Yannoni, M. H. Sherwood, and I. L. Chuang. Experimental realizationof Shor’s quantum factoring algorithm using nuclear magnetic resonance.
Nature , 414:883–887, December 2001.[107] George F Viamontes, Igor L Markov, and John P Hayes. Graph-based simulation of quantum computation in thedensity matrix representation.
Quantum Information and Computation II , 5436:285–296, 2004.[108] Guifré Vidal. Efficient classical simulation of slightly entangled quantum computations.
Physical review letters ,91(14):147902, 2003.[109] Chu Ryang Wie. A quantum circuit to construct all maximal cliques using Grover’s search algorithm. pages 1–13,2017.[110] N. S. Yonofsky and M. A. Mannucci. Quantum computing for computer scientists. 2008.[111] Yarui Zheng, Chao Song, Ming-Cheng Chen, Benxiang Xia, Wuxin Liu, Qiujiang Guo, Libo Zhang, Da Xu, Hui Deng,Keqiang Huang, et al. Solving systems of linear equations with a superconducting quantum processor.