[PYTHON] Quantum computer implementation of quantum walk 2

Quantum computer implementation of quantum walk 2 ~ Exponentiation of cycle 2 Hadamard walk ~

*** Summarize the implementation of Hadamard Walk on cycle $ 8 $ ***. If cycle 8 is realized, cycle $ 2 ^ n $ can be increased in the same way, so only the case of cycle 8 will be introduced. The method introduced here is the same as Efficient quantum circuit implementation of quantum walks.

About Hadamard Walk on Cycle 8

For a brief explanation of the quantum walk, refer to Quantum Walk Quantum Computer Implementation 1.

The cycle to think about this time is image.png

Is. Define a quantum walk on this cycle ($ 000,001, ..., 110,111 $ (0-7 in decimal))

Coin operator and shift operator

As the overall dynamics $ W=\hat{S}\hat{C}\\ $ It is represented by. The coin operator and shift operator are shown below.

\hat{C}=(I\otimes H)\\
\mbox{However}I=\sum_{x}|x\rangle\langle x|,\quad
H=\frac{1}{\sqrt{2}}\begin{bmatrix}
1&1\\1&-1
\end{bmatrix}
\hat{S}=\sum_{x}|x-1\rangle\langle x|\otimes|0\rangle\langle 0|+|x+1\rangle\langle x|\otimes|1\rangle\langle 1|

Let. However, $ x \ pm 1 $ is considered as $ mod 8 $.

Considering the gates of the coin operator and the `shift operator`, the time evolution of the quantum walk can be expressed as a quantum walk.

In particular, *** Coin operator *** $ \ hat {C} = I \ otimes H $ can be expressed by passing $ H $ only through the qubit of the state. *** Shift operator *** $ \ hat {S} $ is • If the state $ q [3] $ is `0```, then $ q [0] q [1] q [2] $ corresponding to the location` `x``` is -1. -If the state $ q [3] $ is 1```, then $ q [0] q [1] q [2] $ corresponding to the location `x``` is +1. Think of a gate to do.

Implementation in IBM Q

4qubits ($ q [0] q [1] q [2] q [3] $) is used for this implementation. Consider $ q [0] q [1] q [2] $ as the qbit corresponding to the location (000,001, ..., 110,111) and $ q [3] $ as the qubit corresponding to the state.

Construction of shift operators (for cycle 8)

Considering the algorithm of +1 operation and -1 operation of $ n $ digit binary,

Each of these gates can be controlled by the state $ q [3] $. Therefore, the shift operator is as follows. image.png In red frame </ font>, if the lowest qubit is `0```, the top 3 qubits are -1. In <font color = "Blue"> blue frame </ font>, if the lowest qubit is `1```, the top 3 qubits are +1.

However, in order to implement it with IBM-Q, the toffoli gate with three or more control parts needs to be rewritten as follows. toffo1.png

Creation of circuit part

Quantum register, classical register, and set quantum circuit qwqc from them

Prepare to rewrite the toffoli gate.

def toffoli(circ,c1,c2,c3,t,a1):
    circ.ccx(c3,c2,a1)
    circ.ccx(a1,c1,t)
    circ.ccx(c3,c2,a1)

Use this replacement to create cycle 8 code.

  • Location qbits $ \ Rightarrow q [0] q [1] q [2] $
  • State qbits $ \ Rightarrow q [3] $
  • Spare qbits $ \ Rightarrow aq [0] $
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute

from qiskit.tools.visualization import plot_histogram

q = QuantumRegister(4, 'q')
aq =QuantumRegister(1, 'aq')
c = ClassicalRegister(3, 'c')
qwqc = QuantumCircuit(q,aq,c)

#t times time evolution
t=1

#Initial setting
qwqc.h(q[3])
qwqc.s(q[3])

for i in range(t):
    #coin
    qwqc.u3(pi/3,0,0,q[3])
    #shift-1
    qwqc.x(q[3])
    qwqc.cx(q[3],q[2])
    qwqc.ccx(q[3],q[2],q[1])
    toffoli(qwqc,q[1],q[2],q[3],q[0],aq[0])
    qwqc.x(q[3])
    #shift+1
    toffoli(qwqc,q[1],q[2],q[3],q[0],aq[0])
    qwqc.ccx(q[3],q[2],q[1])
    qwqc.cx(q[3],q[2])
    
qwqc.measure(q[0],c[0])
qwqc.measure(q[1],c[1])
qwqc.measure(q[2],c[2])
qwqc.draw()

image.png

Simulator results at t = 1

from qiskit import IBMQ

provider = IBMQ.get_provider(hub='ibm-q')

backend_s=provider.get_backend('ibmq_qasm_simulator')
job_s = execute(qwqc, backend_s,shots=1024)
result_s = job_s.result()
counts_s = result_s.get_counts(qwqc)
plot_histogram(counts_s)

image.png

\begin{align}
W\Psi&=SC\left(\frac{1}{\sqrt{2}}|0\rangle\otimes|0\rangle+\frac{i}{\sqrt{2}}|0\rangle\otimes|1\rangle\right)\\
&=\frac{1}{2}S\left((1+i)|0\rangle\otimes|0\rangle+(1-i)|0\rangle\otimes|1\rangle\right)\\
&=\frac{1}{2}\left((1+i)|7\rangle\otimes|0\rangle+(1-i)|1\rangle\otimes|1\rangle\right)
\end{align}

Therefore $\mu(1)=\mu(7)=\frac{1}{2}$ The result is almost the same as the theory.

Results of the actual machine at t = 1

from qiskit.tools.monitor import job_monitor

backend_r=provider.get_backend('ibmq_london')
job_r = execute(qwqc, backend=backend_r,shots=1024)
job_monitor(job_r)

Job Status: job has successfully run

result_r= job_r.result()
counts_r = result_r.get_counts(qwqc)
plot_histogram(counts_r)

image.png

In cycle 8, the amount of control gates is large, and even one time evolution results in a large amount of error accumulation.

Summary

It can be seen that the larger the cycle, the larger the accumulation of errors in the actual machine. If the shift operator is created in the same way, the cycle can be increased to $ 8,16,32, .... $.

The quantum algorithm and system of $ n $ qubits with a quantum walk on the cycle as the background is based on this implementation method.

Recommended Posts

Quantum computer implementation of quantum walk 2
Quantum computer implementation of quantum walk 3
Quantum computer implementation of quantum walk 1
Quantum computer implementation of 3-state quantum walk
Qiskit: Implementation of quantum Boltzmann machine
Qiskit: Implementation of Quantum Hypergraph States
Qiskit: Implementation of Quantum Circuit Learning (QCL)
Implementation of Fibonacci sequence
Implementation of TF-IDF using gensim
Implementation of MathJax on Sphinx
Explanation and implementation of SocialFoceModel
Implementation of game theory-Prisoner's dilemma-
Implementation of independent component analysis
Python implementation of particle filters
Implementation of quicksort in Python
Deep reinforcement learning 2 Implementation of reinforcement learning
Implementation of Scale-space for SIFT
Implementation of Bulk Update with mongo-go-driver
Read "Basics of Quantum Annealing" Day 5
Explanation and implementation of PRML Chapter 4
Introduction and Implementation of JoCoR-Loss (CVPR2020)
Explanation and implementation of ESIM algorithm
Introduction and implementation of activation function
Python implementation of self-organizing particle filters
Summary of basic implementation by PyTorch
Implementation of a simple particle filter
Implementation of a two-layer neural network 2
Implementation of login function in Django
[Beginner] Quantum computer learning site [Free]
Einsum implementation of value iterative method
Implementation of life game in Python
Explanation and implementation of simple perceptron
Basics of Quantum Information Theory: Entropy (2)
Implementation of desktop notifications using Python
An implementation of ArcFace for TensorFlow
implementation of c / c ++> RingBuffer (N margins)
Python implementation of non-recursive Segment Tree
Implementation of Light CNN (Python Keras)
Qiskit: Implementation of QAOA without Qiskit Aqua
Implementation of original sorting in Python
Implementation of Dijkstra's algorithm with python
Read "Basics of Quantum Annealing" Day 6
Read "Quantum computer made in 14 days". Day 5 Quantum well improvement / addition of barriers