common.title
Cloud support

Nobisuke

Dekisugi

RAG


autoQAOA
RAG for dev
Fortune telling app
Annealing
DEEPSCORE
Translation

Overview
Service overview
Terms of service

Privacy policy

Contact
Research

Sign in
Sign up
common.title

Preparing 2-opt swap on IonQ quantum computer with entanglement and swap operation.

Yuichiro Minato

2021/07/06 03:44

#IonQ

1

Here we think about the way to implement 2-opt method on quantum computer using quantum circuit

2-opt method

Evalutating the cost function swapping two cities. To use this method on quantum computer, we need some techniques.

./img/210706opt3.jpg

Thinking about the route we round ABCD cities, we need N*Nqubits for N cities. To realize 2-opt method on ising model we have to swap 4qubits once together.

./img/210706opt4.jpg

The quantum circuit would be,

|0> --X--RXX--RYY-- 
         |    |
|0> -----RXX--RYY--

|0> -----RXX--RYY--
         |    |
|0> --X--RXX--RYY--

By making 1 using X gate and then swap each qubits we can make 2-opt swap.

from blueqat import Circuit import math Circuit(4).x[0,3].m[:].run(shots=100)
Counter({'1001': 100})

First we made 1001 state. Then let's try to swap.

Circuit(4).x[0,3].rxx(math.pi/2)[0,1].rxx(math.pi/2)[2,3].ryy(math.pi/2)[0,1].ryy(math.pi/2)[2,3].m[:].run(shots=100)
Counter({'0110': 100})

Now we could make a 2-opt swap 1001 to 0110. Let's try on IonQ Device on blueqat cloud

from bqcloud import load_api from bqcloud import Device #import API key. api = load_api() task = api.execute(Circuit(4).x[0,3].rxx(math.pi/2)[0,1].rxx(math.pi/2)[2,3].ryy(math.pi/2)[0,1].ryy(math.pi/2)[2,3], Device.IonQDevice, 100)
print(task.status())
Status.QUEUED
# get the result result = task.wait(timeout=3600) if result: print(result.shots()) else: print("timeout")
Counter({'0110': 80, '0010': 7, '0100': 4, '0101': 4, '1110': 2, '1010': 1, '1001': 1, '0111': 1})

We could realize on IonQ Device.

From now we try to implement a quantum circuit to realize hard constraint using entanglement. When we think about 4qubits, the possible states are,

0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111

But, if we only think about the 2-opt method, what we need is just these two states,

0110
1001

To realize these states once on the quantum circuit, we can use entanglement. By realizing this circuit we can rezlize 2-opt swap operation on just one circuit.

The circuit to realize the entanglement is,

Circuit(4).x[0,3].rxx(math.pi/2)[0,1].cx[1,2].cx[2,3].m[:].run(shots=100)
Counter({'1001': 51, '0110': 49})
task2 = api.execute(Circuit(4).x[0,3].rxx(math.pi/2)[0,1].cx[1,2].cx[2,3], Device.IonQDevice, 100)
#realize it result2 = task2.wait(timeout=3600) if result2: print(result2.shots()) else: print("timeout")
Counter({'0110': 52, '1001': 40, '0101': 3, '1000': 2, '1110': 2, '1011': 1})

Then let's flip these states at once.

Circuit(4).x[0,3].rxx(math.pi/2)[0,1].cx[1,2].cx[2,3].rxx(math.pi/2)[0,1].rxx(math.pi/2)[2,3].ryy(math.pi/2)[0,1].ryy(math.pi/2)[2,3].m[:].run(shots=100)
Counter({'0110': 53, '1001': 47})

Now we applied flip operation and get the same state, means we have flipped two state at once.

task3 = api.execute(Circuit(4).x[0,3].rxx(math.pi/2)[0,1].cx[1,2].cx[2,3].rxx(math.pi/2)[0,1].rxx(math.pi/2)[2,3].ryy(math.pi/2)[0,1].ryy(math.pi/2)[2,3], Device.IonQDevice, 100)
result3 = task3.wait(timeout=3600) if result3: print(result3.shots()) else: print("timeout")
Counter({'1001': 54, '0110': 33, '0101': 4, '0010': 2, '1010': 2, '1000': 1, '1110': 1, '1101': 1, '1011': 1, '0111': 1})

Here we also succeded to make flip on IonQ device. To apply this 2-opt method to combinatorial optimizaiton on quantum computer would be little complicated. I will follow on articles later, one by one. Thank you for reading.

© 2024, blueqat Inc. All rights reserved