maxcut problem on QAOA with IonQ device

In this article, we will review QAOA. We will solve a combinatorial optimization problem with quantum gates. First, let's check the calculation with blueqat cloud.

from bqcloud import load_api
from bqcloud import Device
from blueqat import Circuit
import math

#import api key
api = load_api()
#let's make a simple entanglement using rxx gate for trial
qc = Circuit().rxx(math.pi/2)[0,1]
#post task to IonQ on the cloud
qc = Circuit().rxx(math.pi/2)[0,1]
task = api.execute(qc, Device.IonQDevice, 10)
#task queued
#get the result
result = task.wait(timeout=3600)
if result:

The calculation results came out successfully. Now, let's try QAOA on IonQ.

Let's start with a simple equation and consider the three-vertex maxcut problem.

Let's consider three vertices and set the edge weights all to 1.

For the formulation, we will consider the Ising model. We will create an equation called the Hamiltonian. Assign qubits to the vertices, each of which takes the value 1 or -1.

The formulation is,

$$ H_c = Z_0Z_1 + Z_1Z_2 + Z_2Z_0 $$

The coefficients in front of Z correspond to the weights of the edges, respectively.

Next, we need to prepare one more formulation. That is a mixer to search for a solution. We usually use X as the most simple formulation.

$$ H_{init} = X_0+X_1+X_2 $$

Another thing that needs to be prepared in the above formulation is the superposition state, which is the eigenstate of $H_{init}$.

The quantum state is then time-evolved. The equation for time evolution is based on the operation of gradually replacing the Hamiltonian with respect to time t. The time evolution is

$$ \mid \psi_{t+1} \rangle = U \mid \psi_t \rangle $$

The Hamiltonian to be applied is the process of swapping the above two Hamiltonians.

$$ H_t = s*H_{init} + (1-s)*H_c $$

We use time evolution operator $e^{-iHt}$

Finally the quantum circuit to solve the qaoa in 1step p=1 is

|0> --H--RZZ(beta)-------------RZZ(beta)--RX(gamma)--
         |                     |   
|0> --H--RZZ(beta)--RZZ(beta)--|----------RX(gamma)--
                    |          |   
|0> --H-------------RZZ(beta)--RZZ(beta)--RX(gamma)--

To optimize beta and gamma, we can get solution for qaoa. blueqat sdk has a function to create the qaoa circuit. We call this circuit Ansatz.

from blueqat.pauli import Z
from blueqat import vqe

hamiltonian = Z[0]*Z[1] + Z[1]*Z[2] + Z[2]*Z[0]

result = vqe.Vqe(vqe.QaoaAnsatz(hamiltonian, 1)).run()

It has a function to check the quantum circuit


rzz is usually rewrited as combination of cx,rz,cx.

beta = -25.930489083659825
gamma = 0.4578213663591716

Circuit(3).h[:].cx[0, 1].rz(beta)[1].cx[0, 1].cx[0, 2].rz(beta)[2].cx[0, 2].cx[1, 2].rz(beta)[2].cx[1, 2].rx(gamma)[:].run()

If we check the rzz form, we have the same state vector.


Basically IonQ has rzz/rxx basic gate set for trapped ion. For qaoa rzz is much more suitable and we can write the quantum cirucit shorter with these gate set. Let's apply for IonQ device.

task = api.execute(Circuit(3).h[:].rzz(beta)[0,1].rzz(beta)[0,2].rzz(beta)[1,2].rx(gamma)[:], Device.IonQDevice, 100)
#get the result
result = task.wait(timeout=3600)
if result:

Now we have results from IonQ device precisely. It is quite precise than expected.

Yuichiro Minato
blueqat CEO/CTO 2015年総務省異能vation最終採択 2017年内閣府ImPACTプロジェクトPM補佐 2019年文科省さきがけ量子情報処理領域アドバイザー
Yuichiro Minato
blueqat CEO/CTO 2015年総務省異能vation最終採択 2017年内閣府ImPACTプロジェクトPM補佐 2019年文科省さきがけ量子情報処理領域アドバイザー
Related posts

blueqat Inc.

Shibuya Scramble Square 39F 2-24-12, Shibuya, Shibuya-ku, Tokyo