10
Simulated Quantum Annealer Department of CIS - Senior Design 2013-2014 * Danica Bassman [email protected] University of Pennsylvania Philadelphia, PA ABSTRACT Quantum computing requires qubits, which obey the laws of quantum mechanics and therefore behave very differently from classical bits. This difference can allow quantum com- puters to achieve massive levels of parallelism impossible on a classical computer. As a result, certain problems that are in NP but highly parallelizable can be solved by quantum com- puters in polynomial time. Quantum computers have the capacity to drastically change the computing world, but they are complex and difficult to implement; to study them, we often look to simulators that can bypass many of the road- blocks inhibiting our path to a true quantum computer. A simulated quantum annealer takes advantage of the adiabatic theorem to solve problems by transitioning from a simple to complex quantum state while maintaining minimal energy. We simulate these quantum states, energies, and transitions on classical machines by mathematical abstractions for proof of concept and to circumvent the complications of physical implementation. To do this, we solve 3SAT on a classical machine simulating how it would be solved by quantum an- nealing. 1. INTRODUCTION At the heart of quantum computing is the quantum bit, or qubit. In mathematical terms, a qubit is a complex- valued 2-dimensional unit vector. This vector represents a 2-dimensional wave function, spinor, that gives the proba- bilities that a given electron has a given spin state [9]. For our purposes, however, we can think of it simply as a 2- dimensional unit vector that describes the probability that the value of the bit is a 1 and the probability that the bit is 0. It is important to note that the qubit does not have to be either 1 or 0, but can be in a superposition of both simultaneously. This means that it has given probability of collapsing into 0 and probability of collapsing into 1, but be- fore measurement, it hovers in superposition in both states [9]. At some point, however, we must actually extract the data from the qubit, which means we must measure a 1 or 0. The state of superposition ends when we take a measure- ment of the qubit, and the qubit collapses into either state (1 or 0), and holds this value with 100 percent certainty. Figure 1 [3] shows the vector representation for a qubit, highlighting the wider range of values a qubit can take on as opposed to a classical bit. Another key quantum mechanical property relevant to quantum computing that is a direct result of superpo- * Advisor: Max Mintz ([email protected]). Figure 1: Classical Bit vs. Qubit sition is entanglement. Instead of looking at one qubit in isolation, let us consider two qubits. These qubits can be such that if one’s spin is upward, the other’s must be down- ward, and vice versa. These two qubits are said to be en- tangled because each qubit’s state is directly correlated to the other’s [9]. Note that this is feasible when the values of the qubits are known, but as we discussed earlier, until we measure the qubits, we do not know their values. Let qubit A be 1 or 0 with certain probabilities and be entangled with qubit B. We will not know the value of A until we measure it, but the moment we do measure A, and say that we dis- cover its value is 1, we instantly know that B must be 0. This correlation occurs even when A and B are on opposite ends of the universe. This relationship is puzzling, and one for which there is still no clear explanation [9]. Neverthe- less, it is generally accepted that this relationship exists, and therefore we can utilize it in our computations with qubits. Many qubits can be entangled at a given time, which means that if we act upon a single qubit, we are also acting on all qubits that are entangled with it. This gives us a level of parallelism unfathomable on classical computers. Now that we see the benefits that using qubits as hard- ware can provide, we must examine the new opportunities and challenges that arise when programming for a quan- tum computer. We noted that quantum computing allows us a great level of parallelism heretofore unrealized in clas- sical computing. This parallelism allows a quantum ma- chine to act almost non-deterministically. This gives us the potential to tackle a whole new set of problems efficiently that were impossible before, this set of problems being non- deterministically polynomial, those in NP. Not all problems in NP can instantly be solved in poly- nomial time using a quantum computer. Algorithms exist, such as Shor’s, which tackles prime factorization, but we

Simulated Quantum Annealer - Penn Engineering

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Simulated Quantum Annealer

Department of CIS - Senior Design 2013-2014∗

Danica [email protected] of Pennsylvania

Philadelphia, PA

ABSTRACTQuantum computing requires qubits, which obey the lawsof quantum mechanics and therefore behave very differentlyfrom classical bits. This difference can allow quantum com-puters to achieve massive levels of parallelism impossible ona classical computer. As a result, certain problems that arein NP but highly parallelizable can be solved by quantum com-puters in polynomial time. Quantum computers have thecapacity to drastically change the computing world, but theyare complex and difficult to implement; to study them, weoften look to simulators that can bypass many of the road-blocks inhibiting our path to a true quantum computer. Asimulated quantum annealer takes advantage of the adiabatictheorem to solve problems by transitioning from a simple tocomplex quantum state while maintaining minimal energy.We simulate these quantum states, energies, and transitionson classical machines by mathematical abstractions for proofof concept and to circumvent the complications of physicalimplementation. To do this, we solve 3SAT on a classicalmachine simulating how it would be solved by quantum an-nealing.

1. INTRODUCTIONAt the heart of quantum computing is the quantum bit,

or qubit. In mathematical terms, a qubit is a complex-valued 2-dimensional unit vector. This vector represents a2-dimensional wave function, spinor, that gives the proba-bilities that a given electron has a given spin state [9]. Forour purposes, however, we can think of it simply as a 2-dimensional unit vector that describes the probability thatthe value of the bit is a 1 and the probability that the bitis 0. It is important to note that the qubit does not haveto be either 1 or 0, but can be in a superposition of bothsimultaneously. This means that it has given probability ofcollapsing into 0 and probability of collapsing into 1, but be-fore measurement, it hovers in superposition in both states[9]. At some point, however, we must actually extract thedata from the qubit, which means we must measure a 1 or0. The state of superposition ends when we take a measure-ment of the qubit, and the qubit collapses into either state(1 or 0), and holds this value with 100 percent certainty.Figure 1 [3] shows the vector representation for a qubit,highlighting the wider range of values a qubit can take onas opposed to a classical bit.

Another key quantum mechanical property relevantto quantum computing that is a direct result of superpo-

∗Advisor: Max Mintz ([email protected]).

Figure 1: Classical Bit vs. Qubit

sition is entanglement. Instead of looking at one qubit inisolation, let us consider two qubits. These qubits can besuch that if one’s spin is upward, the other’s must be down-ward, and vice versa. These two qubits are said to be en-tangled because each qubit’s state is directly correlated tothe other’s [9]. Note that this is feasible when the values ofthe qubits are known, but as we discussed earlier, until wemeasure the qubits, we do not know their values. Let qubitA be 1 or 0 with certain probabilities and be entangled withqubit B. We will not know the value of A until we measureit, but the moment we do measure A, and say that we dis-cover its value is 1, we instantly know that B must be 0.This correlation occurs even when A and B are on oppositeends of the universe. This relationship is puzzling, and onefor which there is still no clear explanation [9]. Neverthe-less, it is generally accepted that this relationship exists, andtherefore we can utilize it in our computations with qubits.Many qubits can be entangled at a given time, which meansthat if we act upon a single qubit, we are also acting on allqubits that are entangled with it. This gives us a level ofparallelism unfathomable on classical computers.

Now that we see the benefits that using qubits as hard-ware can provide, we must examine the new opportunitiesand challenges that arise when programming for a quan-tum computer. We noted that quantum computing allowsus a great level of parallelism heretofore unrealized in clas-sical computing. This parallelism allows a quantum ma-chine to act almost non-deterministically. This gives us thepotential to tackle a whole new set of problems efficientlythat were impossible before, this set of problems being non-deterministically polynomial, those in NP.

Not all problems in NP can instantly be solved in poly-nomial time using a quantum computer. Algorithms exist,such as Shor’s, which tackles prime factorization, but we

do not yet have quantum machines powerful enough to runthese on a large enough scale. Still, it is exciting to considerthe possibility of being able to prime factorize in polynomialtime since this would allow us to decode anything encryptedusing the RSA algorithm, the most widely used encryptionalgorithm today.

While the original impetus and biggest implication ofstudying and successfully implementing a quantum com-puter stems from prime factorization, we are still some dis-tance from successfully running Shor’s algorithm on a func-tional and robust quantum machine. Quantum annealingcan only be used for combinatorial optimization problemssuch as exact cover, 3SAT, and the traveling salesman prob-lem. Many of these problems are in NP, which means thereare major implications to being able to solve them in poly-nomial time. Quantum annealing may provide this speedup;however, it is not yet certain because of limitations of phys-ical implementations. A simulated quantum annealer canbypass the obstacles a physical machine faces in the realworld, allowing for proof of concept for quantum annealingin an ideal world. This simulation solves 3SAT on a classicalcomputer by simulating the method of a quantum annealer.

Existing quantum machines are not yet powerful enoughto tackle large scale problems or robust enough to solve awide range of problems. They potentially can solve sometypes of problems in NP, and many studies indicate thatthey can, in fact, solve these problems in polynomial time.Many real-world factors inhibit our ability to run these ma-chines on large scale problems successfully, so constructing asimulator allows us to explore the best possible routes thatmay eventually lead to successful, tangible implementations.

2. RELATED WORK

2.1 True Quantum AnnealersWhen considering quantum computers, the biggest and

most relevant player in the industry is D-Wave. D-Waveproduces and sells the D-Wave Two System, a machine witha 512 qubit processor that appears to be a functional quan-tum computer [2]. This claim, however, is not taken at facevalue by some scientists in the quantum computing field [1].D-Wave is a commercial company and whose best interestis served by presenting the D-Wave Two in the best lightpossible. Furthermore, the field of quantum computing is sonascent, and D-Wave is the only real player, so there are noclear benchmarks on which to judge its success. Academicshave compared results to both classical machines and simu-lated quantum computers. Understanding the theory behindquantum computing, previous simulations, and their stand-ing against classical machines is key to building a quantumcomputer simulator.

D-Wave’s machines work through a method called quan-tum annealing. This sets them apart from past quantumcomputing models because it allows the machines to be moreerror-tolerant [8], a factor we will examine in more detailwhen discussing simulators. Quantum annealing is a typeof adiabatic quantum computation, a method designed byFarhi, Goldstone, and Gutmann in 2000 [6]. McGeoch andWang compared the results of quantum algorithms used tosolve three NP-hard problems run on a special purpose D-Wave Two with 439 qubits and on three software solvers.The results showed that the software was 3600 times slowerthan the D-Wave Two using quantum annealing. McGeoch

and Wang note that this is just one instance and shouldnot be taken as evidence that D-Wave is completely effec-tive in every instance for every problem [8], but nonetheless,these results are heartening to supporters of D-Wave. Forour purposes, however, the efficacy and efficiency of D-Wavemachines is not important; we are more concerned with themethods used by D-Wave, and how we can simulate quan-tum annealing on a classical machine since it appears toprovide significant speedup.

2.2 The Adiabatic TheoremUnderstanding the underpinnings of quantum annealing

requires some physics and mathematics. First, considerSchrodinger’s equation, which describes quantum behaviorand gives solutions that are complex-valued functions ofspace and time: i d

d(t)|ψ(t)〉 = H(t)ψ(t)〉 [8] [6]. The adi-

abatic theorem applies when H(t) is slowly varying. H isthe Hamiltonian, which represents the total energy of thesystem [9]. A Hamiltonian system describes a process thatevolves continually over time, in our case, a process that in-volves n binary-valued particles. So let H(t) = a 2n x 2n

matrix, where the eigenvectors of H(t) correspond to mea-sureable states in the system and each eigenvalue is the cor-responding energy. We are interested in the ground state,the eigenstate with the lowest energy [8].

We want to solve a minimization problem where thelowest energy state described above corresponds to the low-est cost solution. Recall that we are using qubits, so eachis represented by a vector (u, v) such that |u|2 + |v|2 = 1,u = the probability that the qubit = 1, and v = the proba-bility that the qubit = 0. We choose an initial ground stateH(0) such that φ(0) has minimal energy, where φ(t) = theeigenstate with the lowest energy at time t [8]. Next, weset our end point H(1) such that φ(1) = an optimal mini-mization solution. Finally, we need a method for the systemto slowly evolve from H(0) to H(1), which McGeoch andWang describe. The adiabatic theorem, originally presentedby Born and Fock, states that φ(t) will remain constant ifthe changes acting on the system are slow enough and thereis a difference between the eigenvalue of H(t) and the restof the Hamiltonian’s spectrum [6]. This ensures that in theexample above, we end the process with the lowest possibleenergy (the same that we started with), but the system hasevolved to an optimal solution of our minimization problem,so our result is the lowest-costing minimum [8].

Quantum annealing stems form the physical process ofannealing, which invovles the slow cooling of a liquid tofreeze it in an optimal state. Both are products of the adi-abatic theorem. Figure 2 depicts how this occurs in physi-cal annealing, which is analogous to how it works in quan-tum annealing. The image on the left shows a liquid cooledslowly, freezing in its optimal lattice structure. The imageon the right shows what happens if we cool too quickly. Theliquid freezes before it has had time to transform into anoptimal formation. This is analogous to quantum annealingShould the transition of the Hamiltonian occur to quickly,the system will no longer be at minimal energy, but rathera less ideal, higher energy state, like the images in Figure 2.

Quantum annealing is the method that D-Wave’s ma-chine used in McGeoch and Wang’s experiment. We exam-ine how simulated annealing [5] works to better understandthe implementation and how we go about simulating it on

Figure 2: Physical Annealing

our quantum computer simulator. Start with any randomlychosen initial state and store the energy of this state. Theprocess could continue indefinitely, so we must set a timelimit or other bound. For example, if the ideal energy valueis known, it can be compared to our current best solution tothat. Next, pick a random neighbor (neighbor being someother possible state) and compare its energy to the currentstate’s energy. If it is a lower energy, then set the current en-ergy to that of the neighbor. Next, check if this new currentenergy is better than the running best energy, and if it is,set the best to this value as well. As time goes on, we zero incloser and closer on our solution, finding better and betterenergies until finally we end with the optimal solution [5].A graphical representation of this process from D-Wave isshown in Figure 3 [2].

Figure 3: Simulated Annealing Process

2.3 Simulation Under the Quantum Gate ModelQuantum annealing is only one strategy that proves to

be successful in some cases; however, there are other meth-ods that can be employed. These methods are particularlyrelevant for simulations since they cannot always be imple-mented in practice. Instead of annealing, we can look atgate level simulations. First, consider ideal quantum com-puter simulations. These are ideal in the sense that the

qubits perfectly utilize superposition and entanglement [11].There are 1-qubit gates such as Pauli-X, Pauli-Y, and Pauli-Z, which are rotations around the Bloch Sphere (the spherein complex space that depicts possible values for a qubit).The Hadamard gate takes a well defined qubit to a super-position (defined with probabilities). There also exist gatesthat act on two or more qubits to realize interactions be-tween qubits. These include the controlled-NOT (CNOT),which is analogous to an XOR gate in classical computing.DiVincenzo showed that using only these gates, any unitaryoperation can be approximated to any accuracy. [11]

Simulation is based on the assumption that each op-eration is done (1) instantaneously and (2) without error,but this is always the case. In the real world, experimentsare compromised by issues such as imperfect spin rotations,unwanted interactions, and decoherence [11]. Quantum co-herence is the transition from quantum states to classicalstates, which occurs when we make a measurement of a spe-cific qubit. Decoherence occurs when the qubit collapsesfrom superposition into a classical state from external orenvironmental factors, which can result in the loss of infor-mation. To account for these issues, the error model wasdeveloped [11].

To address decoherence Nielsen and Chuang developedthe depolarizing channel [11]. Here, we map general errorsto linear combinations of basic errors such as a bit flip, phaseflip, or both. The channel assumes that each of these errorshas an equal probability of occurring, while also taking intoaccount the possibility of being error-free. We then run theoperation and let the decoherence operation described aboveaffect the qubit at each step. A simulation must only deal inpure states, so we run our algorithm many times, assigningthe results of each run a probability based on the errors wethink might occur [11].

In the field of simulation, work in fault-tolerant ma-chines has led to the accuracy threshold theorem. Devel-oped by Aharonov and Ben-Or, it states that arbitrarily longquantum calculations are possible if the probability of a sin-gle qubit being erroneous is below a given threshold [11].This implies that in theory, large scale quantum comput-ers should be possible, but there are roadblocks to realizingthem.

Real-world implementation of a machine using quantumgates and registers is currently unrealistic because there areso many sources of error that the machine is unlikely to op-erate properly. The factors that cause these imperfections,however, are a result of operating in nature, and we can ig-nore them when working in simulation.

Quantum computation is a rapidly advancing field withno official benchmark industry standards. There is no bestmethod to simulate a quantum computer. Furthermore, wecannot say for certain that a functional quantum computerexists because not all experts agree that D-Wave’s resultsdemonstrate success. Therefore, any attempt to simulate aquantum computer adds something new to the field. Eachmodel, built from a different perspective or with new goals inmind, provides new insight. While we can represent an idealquantum computer with no decoherence in simulation, thisis not necessarily helpful since it cannot be translated to aphysical machine. There exist possibilities for incorporatingthese errors, and methods for correcting and accounting forthem. Instead, we bypass this strategy entirely and chooseto simulate quantum annealing, which allows for more error

within the individual qubits. This is the most reasonablepath to pursue since D-Wave has shown that this strategymight be translated to a real-world machine successfully [8].

3. SYSTEM MODEL

3.1 Case Study: Simulation Under the Quan-tum Gate ModelWhile no physical implementations yet exist under

the quantum gate model, the majority of simulations followthis paradigm. It is an exact analogy between the classicalbit to the qubit, the classical gate to the quantum gate. Byunderstanding this model and studying the tools used tosimulate it on a classical machine, we can apply the sametechniques to simulate a quantum annealer.

3.1.1 Simulated QubitFor annealing, the qubits will comprise the quantum

system and are analogous to the quantum registers. Con-sider implementing a quantum register on a classical ma-chine. These registers are best described in mathematicalterms based on the linear algebra that dictates their be-havior. A single qubit is a two-dimensional unit vector incomplex space, so we can define all aspects of it in linearalgebraic terms. A basis is a set of linearly independent vec-tors that describe a vector space. Any vector in that vectorspace can be written as a linear combination of the basis vec-tors. The coefficients of the basis vectors for a given vectorare called the coordinates. In the case of qubits, the basisis made up of all 2n possible states and the coordinates arethe probabilities that the qubit will collapse into that state.

Examine this mathematical abstraction in more con-crete terms.Consider the two dimensional complex vector(

xy

)where |x2| = the probability that the qubit will collapse into0 and |y2| = the probabilility that the qubit will collapseinto 1. If the qubit is defined as |0〉 or |1〉, it is not insuperposition, i.e., it has a 100 percent chance of collapsinginto 0 (or 1). To represent |0〉 as a two-dimensional vector,then clearly the vector representation =(

10

)This can be expanded for the case where the qubit is insuperposition. The vector must lie in the Bloch sphere,which is to say that it must be of unit length, or its lengthmust be 1. Consider the common case, where the qubit hasequal likelihood of collapsing into either 1 or 0. In the 2-dimensional unit vector above, this means x = y. Usingthis information, we know that the normal two dimensionalvector where x = y must be(

1√2

1√2

)We can infer from these two examples how any other qubitwould be represented: determine the relationship between xand y, and then normalize the vector.

This is for a single qubit in isolation, but the mathe-matical abstraction can be easily explanded to incorporatemany entangled qubits. This expansion is how we simulate

both a register and for a quantum system. A true quantumannealer has a system of qubits that are coupled, which inessence means the same thing as entangled, except that incoupling, spacial locality is necessary for the properties totake effect (entanglement prevails regardless of proximity inspace). Recall that representing n qubits required 2n classi-cal bits. We will now show a mathematical justification forthis that explains how we go about encoding this propertyin simulation.

A vector for a set of entangled qubits exists in 2n di-mensional complex space. To define a vector space, use a setof vectors known as a basis, and the basis for a set of entan-gled qubits corresponded to the possible states into whichthe entangled vectors could collapse. Each qubit can take onthe state |1〉 or |0〉. If there are n qubits, and each can takeon 1 of 2 states, then combinatorically, there are 2n possi-ble states of collapse. Our basis is defined by these possiblestates. Next, the coordinates of any vector with respect tothe basis are the probabilities of the entire system collapsinginto that state. Therefore the representation of some arbi-trary set of entangled qubits is simply a 2n dimensional co-ordinate vector in the computational basis described above,with each coordinate indicating the probabilities of collapseinto that basis vector state.

This follows in mathematical terms, but we must en-code this using classical programming tools. A vector isanalagous to an array. For any n dimensional qubit, simplycreate a 2n array where the ith value indicates the probabil-ity of collapse into state |i〉. The value of the index in binaryis equivalent to the state of collapse, so this maps perfectly.We use this representation for qubits on a classical machinein both simulated quantum annealing and simulated quan-tum computer to represent quantum registers [4].

3.1.2 Simulated Quantum GateIn a classical computing model, we pass the informa-

tion through gates to perform given operations. There aregates that act on a single bit (e.g., the NOT gate) and gatesthat can act on multiple bits, taking multiple bits as input(e.g., AND gate, OR gate, XOR gate). Similarly, there arequantum gates to perform similar operations. For actingupon a single qubit, there are the Pauli X, Pauli Y, andPauli Z gates. These are named for the axes around whichthey rotate the qubit’s vector in the Bloch Sphere. Pauli Xis the quantum equivalent of the classical NOT gate. In ad-dition to these rotations, there is the Hadamard gate, whichessentially takes a qubit that is in a classical state into anequally weighted superposition. More precisely, it takes |0〉to |0〉+|1〉√

2and |1〉 to |0〉−|1〉√

2.

Consider the Hadamard gate. It can be represented insimulation as the Hadamard matrix: H =[

1√2

1√2

1√2− 1√

2

]

In order to perform an operation on a quantum register,which is simply a two dimensional coordinate vector, wesimply perform matrix multiplication. Similar matrix rep-resentations of the Pauli gates exist, and since these are allsimple 2x2 matrices and are operating on single bits, whichare two dimensional vectors, this multiplication can be im-plemented for simulation [4].

As mentioned above, there are also gates that act upon

multiple qubits. One such class of gates are the controlledgates. These are gates that act on 2 or more qubits. Theyare called controlled gates because one of the input qubitsis used as a control, meaning that whether some operationoccurs is dependent on this qubit. As an example, considerthe controlled-NOT gate. Figure 4 shows the physical repre-sentation for the CNOT gate. It takes two qubits as inputs:

Figure 4: Physical CNOT Gate

the control and the target. It performs the NOT operationon the target of the control bit is |1〉, otherwise, it does noth-ing. As with the single bit gates above, these gates can alsobe represented as matrices. The CNOT gate operates ontwo bits, therefore it will be represented as a 22x22, or 4x4matrix. CNOT =

1 0 0 00 1 0 00 0 0 10 0 1 0

Note the 2x2 matrix in the bottom right corner:[

0 11 0

]This is the matrix representation the Pauli-X gate men-tioned above, which is analagous to the NOT gate in clas-sical computing. Based on this pattern, we can generalizethe above template for any controlled-U gate. A controlled-U gate will perform operation U on the target qubit if thecontrol is |1〉, otherwise, it will leave the control and targetunchanged. As above, its matrix representation will be:

1 0 0 00 1 0 00 0 u1 u2

0 0 u3 u4

where [

u1 u2

u3 u4

]is the matrix representation for some single bit gate. As inthe single bit case, we simple multiply this matrix by the4 dimensional coordinate vector of the two input qubits tosimulate data passing from a register through this gate [4].

3.2 Simulated Quantum AnnealingWe can apply the strategy of using mathematical ab-

straction to represent quantum state on a classical machineusing linear algebraic structures. We examined how this isdone in the simulation of the quantum gate model, and willapply these same techniques when implementing the simu-lation. Now we examine at a high level the system designand components needed for quantum annealing. This illu-minates what components are needed to simulate and definelinear algebraic abstractions in the System ImplementationSection.

Quantum annealing is based on the adiabatic theorem,which states that if we slowly change the Hamiltonian, aquantum system remains in the ground state of the instanta-neous Hamiltonian [12]. Apart from why this process works,this theorem also tells us what components we would needto run a true quantum annealer, and therefore the compo-nents we need for a quantum annealer.

The first component is a quantum system. The firststep is to simulate a qubit. A quantum system requires morethan one qubit, specifically a set of entangled qubits. Thisis analagous to a quantum register in the register and gatemodel. We will go into more detail in the System Imple-mentation section, but because qubits are two-dimensionalunit vectors in complex Hilbert space, mapping the physicalqubits to a mathematical abstraction is a fairly simple ap-plication of linear algebra.

Next for annealing, transition from a simple state toa more complex state, and this requires many factors forour model. First, we need a ground state that is relativelysimple. Since the state is a Hermitian matrix, simple heremeans a matrix whose eigenvectors and eigenvalues are easyto calculate [10]. How to find such a matrix will be discussedin more detail in the System Implementation section. In ad-dition to an initial state, we also need an end state that willrepresent the optimal solution to our problem. This means amatrix such that the eigenvector corresponding to minimalenergy maps to the optimal solution. This further requiresthat we define an energy function such that minimal energymaps to optimality. This too will be discussed in more de-latil in the System Implementation section.

Finally, define a transition function–this defines howwe move from one state to the next. The challenge hereis twofold: how is this function defined, and how do wesimulate this physical shift happening. The function defini-tion is dependent on the problem, so for implementation, wewill discuss examples and methods for determining a properfunction based on the problem. We will also examine howthis transition occurs in a simulated (nonquantum) annealerto enlighten how one could approach this transition in aquantum simulation.

In summary, the basic process of quantum annealing inlayman’s terms is:

1. Choose a simple Hamiltonian with easily calculatedground state and minimal energy.

2. Define a complex Hamiltonian whose ground state willencode the solution.

3. Define a slow-moving transition function between thetwo such that quantum state maintains minimal en-ergy.

4. When minimal gap is reached between complex Hamil-tonian and current state (or enough time has passed),calculate ground state for current state, which willhave minimal energy according the adiabatic theorem.

Figure 5: Block-Flow Diagram

The process is outlined in Figure 5. According tothe adiabatic theorem, the system will have transitioned toa more complex state, but will have maintained its mini-mal energy. The eigenvectors in this state correspondingto eigenvalues for minimal energy is the optimal solution.We can identify the factors needed in our system model tobe a Hamiltonian, its simple initial state, its complex finalstate, definition for its minimal energy, and its slowly mov-ing transformation function. In addition to implementingthese components using classical tools in isolation, which isa challenge, we must also encode methods for their relation-ships and interactions with each other.

4. SYSTEM IMPLEMENTATIONQuantum annealing can only be used for combinato-

rial optimization problems, such as exact cover, 3SAT, andthe traveling salesman problem. We define Hamiltonians forquantum annealing on a problem by problem basis. 3SATlends itself to annealing because we can intuitively definesimple and complex Hamiltonians such that the ground stateof the complex Hamiltonian is equivalent to solving 3SAT.We implement a method for solving 3SAT, simulating howa quantum annealer would solve the problem on a classicalmachine. We do so using Java and the Jama library for thelinear algebraic structures. As described in the System De-sign Section, we first define mathematical abstractions forquantum state and components, then discuss how these willbe implemented in a classical program.

4.1 Mathematical AbstractionWe consider the 3SAT problem, a Boolean satisfia-

bility problem with the restriction that each clause has 3elements. A clause is simply 3 Boolean variables strung to-gether with OR statements. Start at the lowest level, defin-ing hC(ziC , zjC , zkC) = 0 if the Boolean variables(ziC , zjC , zkC) satisfy clause C, otherwise it equals 1. Wdetermine whether an expression, comprised of clauses, issatisfied by some Boolean variables (z1, z2, ..., zn), thereforethe total energy of the system will be defined as the sum ofthe energy of all clauses in the expression, i.e.,h(z1, z2, ..., zn) = ΣChC [10].

With an energy function now defined, we define theHamiltonian matrix of the transformation. In doing this,we also define our final state Hp and our initial state Hb.

Recall that an n qubit state |ψ > is a 2n dimensional vector.That means that the Hamiltonian matrix of transformationmust take 2n dimensional input. Generate this by takingthe tensor product of the states of the Boolean variables,i.e., |z1〉〈z1|⊗ |z2〉〈z2|⊗ ...⊗|zn〉〈zn|. This will be 2n dimen-sional because zi is Boolean. Results of H must also be 2n

dimensional, but the values we want are the scalar values 1or 0 calculated with the function h defined above. To movethese values into 2n space, multiply them using the tensorproduct |z1〉 ⊗ |z2〉 ⊗ ... ⊗ |zn〉. This will give an energyvalue for each clause HP,C equivalent to hc, but in differentdimensional space. Therefore, we perform the same summa-tion over all clauses to get the total energy of the system,Hp. Note that HP will be equal to 0 if and only if all clausesare satisfied; otherwise, it will equal the number of clausesthat are not satisfied. Therefore, not only is energy minimalat our solution, but energy level is directly tied and propor-tional to how close our possible solution is [10].

ThisHP represents the final, complex Hamiltonian struc-ture in which we wish to end. The process of quantum an-nealing requires us to start at a simple Hamiltonian andtransition slowly to a more complex one, maintaining min-imal energy along the way. HP is the complex end statewhose eigenvector corresponding to the eigenvalue of mini-mal energy is the optimal result, so we define HB to be asimple start state. Simple in this context means that theeigenvectors and eigenvalues are easy to calculate. Theseare easy to find when H is in a state such that all Booleanvariables are in a quantum superposition where collapse intoeither 1 or 0 is equally likely. When defined this way, theeigenvectors are 1

2(|0〉+ |1〉) and 1

2(|0〉 − |1〉) [10].

These definitions for hC , HP , and HB were defined byMax Mintz in his class notes for CIS398 [10], and largely in-form this implementation of simulated quantum annealing.This is highly informative in terms of implementation. Itserves as a template for other Hamiltonians since most com-binatorial optimization problems are Boolean satisfiabilityproblems. It also acts as a guide to implementation since3SAT is NP complete, and therefore many problems in NPcan be reduced to it.

The final aspect of implementation will be performingthe transformation from the initial state to the end state, orHB to HP in terms of the variables above. Quantum anneal-ing is in essence a glorified guess and check methodology, soat a very basic level, we are essentially picking slight varia-tions on the structure of H and deciding if it is better thanour current structure. Of course in practice, it is much morecomplex than this. In terms of simulation, there are twoaspects to consider: (1) how is this transformation defined;how would it operate, regardless of what it is running insimulation or a true quantum annealer. This should be welldefined and essentially the same in both cases; and (2) howto map a transformation of a quantum system state onto asimulation by a classical machine.

First, consider how this transformation is defined. Tothink about how this transformation process occurs, we cananalyze the basic framework of the algorithm in a simulated(non quantum) annealer. A quantum annealer (and there-fore our simulator) should have the same functionality. Thegeneral algorithm for transitioning between states is definedas follows: select a neighbor that can be found by making asmall modification to the current state; decide whether thissolution is closer to the optimal solution than the current; if

so, then move to this neighbor, else remain at current state;increment timer. Iterate through this process until we haveeither reached our time limit or found a good enough solu-tion; here, good enough means the gap between the energylevel of what we know our optimal solution to be and thecurrent energy level is sufficiently small [7].

This is the process for simulated annealing, and it isessentially the same for quantum annealing. The only dif-ference is in the area from which the system is selectingneighbors. In quantum annealing the radius of this neigh-borhood changes dynamically, while in simulated annealing,the size of the neighborhood is set at the beginning andremains the same throughout the process.

4.2 Physical Implementation

4.2.1 Input ParametersWe have implemented a program that will solve the

3SAT problem using the quantum annealing paradigm, sim-ulating quantum state on a classical machine using linearalgebraic abstractions. The method has 3 paramaters:

1. Time: the purpose of this paramater is twofold. First,since annealing is essentially a guess and check method,we need a parameter to ensure that our program willeventually terminate. In a true quantum annealer,this can arise from issues of decoherence discussed inthe Related Work Section or from simply making badguesses. The longer the simulation runs, the odds offinding a state with minimal gap increases, but it is notguaranteed. This time check ensures that the programdoes indeed terminate, and that it finishes efficiently.Second, we noted earlier that quantum annealing is amethod that can only be used to solve combinatorialopitimization problems. For some of these problems,however, it is possible that no optimal solution exists–in the case of 3SAT, this means that there is no as-signment of variables such that the entire expression issatisfied. In this case, the program would run forever.The simulation program deals with this issue in thesame way that a true quantum annealer would. Theprogram will run to the time limit, at which point itwill return its current state. It also prints a messageexplaining that this is not a solution, but its best guess,i.e., the lowest possible energy state it could reach. Itnotes that it still could not reach minimal energy (inthe case of the definitions for 3SAT described above,it should have reached energy = 0), but got as close asis possible given the unsatisfiable expression.

2. Variable Number: in the 3SAT problem definition, weare allowed to have repeating variables in differentclauses or even in the same clauses. The simulationimplementation, however, iterates over variables, notclauses, therefore we must know this information be-fore hand.

3. Clauses: this contains the list of clauses in the ex-pression we are trying to satisfy. This contains infor-mation on the variables in each clause and whetherthe clause is negated or not. The simulation imple-mentation also must iterate over clauses and uses thenumber of clauses to define energy (and more impor-tantly, when energy is minimal), but we can extract

that information by simply measuing the size of thislist.

4.2.2 Method ImplementationThe simulation starts with each variable zi in equal

superposition of 1 and 0. This is simulated by equally weightedunit vectors as described above. We then iterate throughvariables, systematically collapsing the simulated qubits outof superposition in classical states in order to transition toa more complex state of lower energy. We loop over all ziuntil either we have reached a state such that all clausesare satisfied (i.e., of minimal energy, as described above), oruntil time T has elapsed.

For each zi, we measure the number of clauses thatwould be satisfied if zi = 0 and if zi = 1. We check bothsince the qubit is in an equally weighted superposition, socollapse in either state is equally likely. We compare thisto the number of clauses satisfied in the current assignmentstructure for all z’s. In the beginning, this means before zi’scollapse; as the algorithm progresses, this means with eachzi set to either 0 or 1 or still in superposition. According toour definition above for the complex Hamiltonian, energy isequivalent to clauses satisfied. If setting zi to 0 or 1 resultsin a lower energy (i.e., more clauses satisfied) than the cur-rent state, then we set our current state include that newassignment for zi that resulted in minimal energy. This con-stitutes the small change to a neighboring state, or the slowtransition function.

Most 3SAT problems contain clauses with multiple vari-ables and duplicated varaibles across clauses. This meansthat when all other variables are in superposition, settinga single zi to either 0 or 1 will not result in a lower en-ergy. Therefore we will run infinitely, or until time T haspassed, keeping all variables in superposition. To ensurethat progress is made, we add a second check. If setting zito 0 or 1 did not decrease the overall energy of the expres-sion, we randomly set zi to 0, 1, or zi, i.e., keep it with itsoriginal value. If zi was in superposition, this ensures thatif it is collapsed into a classical value, it still maintains isproperty of being equally weighted and being measured as0 or 1 with equal likelihood. To ensure that the changesare occurring slowly enough, we also potentially leave zi un-changed. All three of these random assignments have equallikelihood of occurring. This guarantees that the neighbor-ing quantum states we transition to are not too far from thecurrent state.

We iterate through this process until we reach a quan-tum state whose energy is 0. This is equivalent to an assign-ment for all variables such that every clause in the expres-sion evaluates to true. As discussed, this assignment is notalways possible, so the iteration will also terminate whenthe input time has elapsed. The simulation of the randomcollapse of qubits in superposition into states with givenprobabilities is simulated using Java’s Math class randomnumbers.

4.2.3 OutputIn all cases, the system will output a visual expression

defining the input expression. It will also output the numberof clauses in the expression and the number of clauses sat-isfied. In situations where the satisfying exists, and can befound in the time limit, these will be equal, and the systemwill simply output the varaible assignments. In cases where

the expression is not satisfiable within the time limit, theuser will see that clauses in the expression are not equal tothe number of clauses satisfied. To justify this discrepency,the system will output a message explaining that time T haselapsed, but no satisfying solution could be found. It is likelythat no solution exists, but this is the system’s best guess forminimal energy assignments. Figure 6 shows sample outputfrom the simulated quantum annealer.

Figure 6: Sample Output

5. SYSTEM PERFORMANCE

5.1 Quantum Annealing PerformanceOne can judge performance based on two factors: accu-

racy and efficiency. Accuracy is fairly easy to test. Since themain impetus for studying quantum computational methodsis to tackle problems in NP and find polynomial solutions,we will likely be testing the simulation on problems in NP.Further, as mentioned above, annealing works for problemswhose solutions lie in optimal combinations, which are usu-ally Boolean satisfiability problems. These are often in NP,so they are likely the class of problems attacked. Luckily,since these problems are in NP, we can check if our solutionsare correct in polynomial time. Further, since we are simu-lating quantum states on a classical machine, the scale of theproblems is small. Recall the exponential growth in termsof space needed to store qubits. For an n qubit register, weneeded a 2n dimensional coordinate vector correspondingto the basis of the 2n possible states. Therefore, to repre-sent linearly more qubits, we need exponentially more space,which on a classical computer quickly becomes impossible.Since the problems we seek to solve will be on a small scaleand our solutions can be verified in polynomial time, mea-suring accuracy will be relatively simple.

Next, we look to measure efficiency, and this is lessstraight forward. The algorithm for simulated annealing it-erates until either a pre-determined time limit has elapsed oruntil we are close enough to an optimal solution. This makesefficiency difficult to calculate since this is not a normal al-gorithm we can run to completion and track the runtime.

First, track many different runs with different metrics todetermine a solution’s legitimacy. The algorithm will com-plete if the gap between our noted optimal state and currentstate in the annealer is small enough, but measuring smallenough is not clear. The small enough gap can be extrapo-lated by trying several different values and finding a middleground between efficient runtime and an accurate solution.If “good enough” is too loosely defined, our returned solutionmay be suboptimal, but if it is too strict in our definition,

then we will find ourselves always running to the end of thepre-determined clock limit when we may have found a rea-sonable solution much earlier.

Second, examine the time limit. If this time limit is tooshort, we output sub-optimal solutions, however, if the timelimit is too long, the system runs longer than necessary ifit already has found a good enough solution. As was thecase with the definition for “good enough,” finding a happymedium between these two extremes comes about throughtrials of many possible values and finding which best opti-mizes both factors.

Finally, one of the criteria for quantum annealing towork was that we transition from one state too the next“slowly enough,” yet up until now we have left this un-defined. Mathematically, we can define what is optimallyslowly enough. We define gmin = min0≤s≤1(λ2(s)− λ1(s)).Here, λ still represents the eigenvalues, which is equivalentto energy, so this formula gives us the difference betweenthe two lowest energy states of a given Hamiltonian. Nextdefine ε =max0≤s≤1|〈φ2(s)|| dH

ds||φ1(s)〉|. Recall that |φ〉 is

the eigenvector, and in this case φi is the eigenvector cor-responding to the eigenvalue λi. Also recall that when wereach the final complex state through annealing, the eigen-vector corresponding to the minimal eigenvalue is the solu-tion. This means that ε is defining the maximal change inenergy between two quantum states [10].

To move “slowly enough” is to change at a rate suchthat T � ε

g2min. This is clear theoretically, but in practice,

may not be a good baseline. Note that if these eigenvec-tors and eigenvalues were easy to find all along, we wouldhave no need for a quantum annealer. The usefulness ofan annealer comes from the fact that we start in a simplecase for which these values can be calculated and end ina complex state where we maintained minimal energy. Ifthe eigenvectors and eigenvalues were easy to calculate allalong, we would have just done that from the offset and dis-regarded the complexities of a quantum annealer. However,the eigenvalues and eigenvectors are what determine gminand ε respectively. Therefore, we may not always be able tocalculate these, and consequently may not be able to findthe exact speed that is “slowly enough” [10]. As with thetwo other metrics for efficiency, use many different speeds insearch of the best one that is both moving quickly enough togive efficient solutions but moving slowly enough such thatthe adiabatic theorem still holds and our final solution iscorrect.

5.2 Simulator PerformanceWhile most of these metrics still apply to the simu-

lated quantum annealing system, some are trivial and someare not applicable. First, examine accuracy. We test this asdescribed above. Test cases were written to cover all equiv-alence classes and edge cases. Each time, the program haseither returned a satisfying assigment or a best guess as ex-pected. Therefore, the system is always returning accurateresults.

In many combinatorial optimization problems, some-times having a very close to perfect solution is good enough;the solution does not have to be exactly optimal to be useful.For instance, for the traveling salesman problem, having asolution that is close to the optimal pat is still advantageous.In the case of 3SAT, however, a non-optimal solution meansnothing. Though the system will return an assignment of

minimal energy possible for a non-satisfiable expression, itis not useful since having no clauses evaluating to true isarguably just as bad as having all clauses except for oneevaluate to true. In these terms, it does not make senseto evaluate the system’s efficiency based on changes in theminimal gap. The optimal state is a solution with energy 0,and anything other than that is not a relevant or informa-tive solution. Therefore, the minimal gap must always be 0.

The paramater time inputed to the system is a constantthat is multiplied by the number of clauses. Most test casesare fairly small in scale, so this is not a hugely helpful metric.For test cases with satisfying assignments, these assignmentsare usually found far under the time limit. In cases wherethere is no sastisfying assignment, it is usually clear thatno solution exists before time runs out, but the system willstill run to completion, when time T has expired. In eithercase, the runtimes are usually so fast that it is negligible,even when the input time is a very large constant. We havenever yet encountered a case where a satisfying assignmentexists, but cannot be found in a reasonably large input time.In the Future Work Section, we will explore possibilities forgenerating test cases in which this might occur.

A key component of the adiabatic theorem is that thetransition between Hamiltonians is slow enough. Describedabove is the equation for this in a true quantum system.In a small scale simulation, this is not highly informative orhelpful. The changes in the simulation are highly quantized,i.e., they are discrete changes in the variable assignments.The slowest the transition can occur is by making one ofthese at a time. Under these conditions, the system stillsolves 3SAT in reasonable time, although as stated above,this is hard to guage since it is on such a small scale. Wewill explore opportunities for scaling up the test sets in theFuture Work Section.

6. FUTURE WORK

6.1 Scaling System TestingOne of the biggest obstacles for judging the system

performances was the small scale of the tests. While wenoted that cases could not be run a massive scale since spaceincreases exponentially when simulated, we still must test ata large scale to ensure the correctness of the system. Furtherfor the simulator to have any real-world implications, it mustbe able to perform at scale. The purpose of the simulator isto show that a large-scale true quantum annealer could beused to solve large scale problems efficiently. Therefore, wemust be able to solve these large problems on the simula-tor. As of now, the tests were generated by hand to fit thespecific format and data types required by the simulator. Inthe future, an automatic test case generator formatted spec-ficially for the syntax of the simulator.

In terms of scaling, this entails test cases that grow inboth size and variety. While all equivalence classes were cov-ered in current tests, running a wider variety of tests wouldfurther prove the robustness of the system. Increasing in sizewould not only show that the system operates at scale, butalso would help in efficiency analysis. We would be able tobetter analyze the optimal input time and rate of change inthe Hamiltonian and quantum state. Scaling the test caseswill allow for this further analysis.

6.2 System Robustness

We explored how the simple and complex Hamiltoni-ans must be defined on a per-problem basis; as such, thissystem only simulates quantum annealing specifically forthe 3SAT problem. In the future, the simulator could beexpanded to solve a wide variety of combinatorial optimiza-tion problems, particularly those in NP.

While a simulated annealer must be tailored specificallyto the problem, the system design still applies to all prob-lems that can be solved using quantum annealing. 3SAT isa relatively academic problem, and it does not have obvi-ous practical implications. On the other hand, being ableto solve a problem like traveling salesman efficiently using asimulated quantum annealer has many more tangible busi-ness, entrepreneurial, and economic implications. The bruntof the work in terms of the annealing model and the simula-tion by mathematical abstraction techniques has been done,and the system can be expanded to address a wider scopeof combinatorial optimization problems.

6.3 EthicsThere are no major ethical implications for a sim-

ulated quantum annealer, but the simulated system is astepping stone for a physical quantum annealer, and a truequantum annealer paves the way for a large scale, robustquantum computer. Given a true quantum computer, wewould have a machine capable of running Shor’s polynomialtime prime factorization algorithm.

Almost all data today is encrypted using the RSA al-gorithm. The RSA algorithm keeps data safe contigent onthe fact that it is hard to prime factorize large numbers, i.e.,we do not yet have a polynomial time algorithm that runson classical machines. Using Shor’s algorithm, however, aquantum computer could quickly prime factorize, thus en-abling decryption of almost all encrypted information thattravels across the Internet. This would include everythingfrom financial information to medical records to personalemails. Obviously there would be enormous ethical and le-gal ramifications if a functional quantum computer were tobe developed that could properly execute this algorithm atscale.

If it were public knowledge that the RSA algorithmcould be cracked using a quantum computer running Shor’salgorithm, shockwaves would be sent throughout the com-puter science community as a search for a new method ofencryption would become necessary. The bigger ethical con-cern comes from an organization owning a functional quan-tum computer and thus being able to view all encrypteddata, but unbeknownst to the senders, receivers, or ownersof the data. The idea of a large corporation or governmentwho has much to gain from a new method of data miningand collection is formidable. This is particularly relevantconsidering that Google has purchased a D-Wave machineand reports were leaked that the NSA is conducting exten-sive research on quantum computing; however, issues suchas these are not an immediate concern given the currentstate of quantum computation technology.

7. CONCLUSIONThe goal of the simulated quantum annealer is sim-

ulate quantum state on a classical machine and explore thepossibilities of applying the adiabatic theorem to quantumcomputation. We explored the foundations of quantum com-puting and the mathematics and physics that allow us to

use quantum particles such as qubits in computation. Weexamined the current physical implementations, their bene-fits, and their shortcomings. Through study of the quantumgate model, we understood how one can use mathematicalabstraction to linear algebraic structures when simulatingquantum state on a classical machine. We then exploredhow one can apply these concepts to quantum annealing.Given the high level algorithm for quantum annealing, wecan simulate by representing each of the necessary steps andcomponents using mathematical structures. We exploredthe system performance, noting that this could be betteranalyzed with more extensive future work on scaling androbustness.

Though Shor’s algorithm is still the driving force be-hind research and work in the field of quantum computation,we are still years away from a functional, robust quantumcomputer that can run the algorithm. Physical implemen-tations operate on quantum annealing, a completely differ-ent paradigm that is not as robust. Further, it is not clearwhether these physical implementations provide exponentialspeedup or are fully functional due to issues of decoherenceand other physical problems that arise in nature. When wesimulate, we better understand the potential of quantumannealing as a computational model because we bypass theexperimental challenges and errors. The simulated quantumannealer shows that quantum state and quantum annealingsubprocesses can, in fact, be simulated on a classical ma-chine. This provides a basis and paves the way for furthersimulation, which in turn may help overcome the obstaclesthat currently limit physical implementations. The simu-lated quantum annealer also acts as a proof of concept forthe adiabatic theorem applied to computation. By exam-ining a proof of concept of the theoretical underpinning ofquantum annealing, we can better understand and hypoth-esize new uses and applications of a true quantum annealer.The simulated quantum annealer provides a justification andincentive to further study and explore quantum annealing asmeans to the next phase of computational machines.

8. REFERENCES[1] Scott Aaronson. D-wave: Truth finally starts to

emerge. http://www.scottaaronson.com/blog/,August 2013.

[2] D-Wave. D-wave products & support. http://www.dwavesys.com/en/products-services.html,October 2013.

[3] Andrew Daley. Quantum optics and quantummany-body systems. http://qoqms.phys.strath.ac.uk/research_qc.html,January 2011-2012.

[4] Andreas de Vries. Quantum Computation: AnIntroduction for Engineers and Computer Scientists.Books on Demand GmbH, 2012.

[5] Kathryn A Dowsland. Simulated annealing. Modernheuristic techniques for combinatorial problems, pages20–69, 1993.

[6] Edward Farhi, Jeffrey Goldstone, Sam Gutmann, andMichael Sipser. Quantum computation by adiabaticevolution. Technical report, Massachusetts Institute ofTechnology, 2000.

[7] Darrall Henderson, Sheldon H. Jacobson, and Alan W.Johnson. The theory and practice of simulated

annealing. Technical report, United States MilitaryAcademy, University of Illinois at Urbana-Champaign.

[8] Catherine C. McGeoch and Cong Wang. Experimentalevaluation of an adiabiatic quantum system forcombinatorial optimization. In Proceedings of theACM International Conference on ComputingFrontiers, CF ’13, pages 23:1–23:11, New York, NY,USA, 2013. ACM.

[9] Max Mintz. Quantum Computing and InformationScience: Lecture Notes. University of Pennsylvania,2012.

[10] Max Mintz. Lectures on Quantum Computer andInformation Science. University of Pennsylvania, 2013.

[11] D. B. Trieu. Large-Scale Simulations of Error-ProneQuantum Computation Devices. Dr. (univ.), Univ.

Diss. Wuppertal, JAijlich, 2009. Record convertedfrom VDB: 12.11.2012; Wuppertal, Univ. Diss., 2009.

[12] Matthias Troyer. Quantum Annealing. Institute forTheoretical Physics.