Hello everyone, I know you all want to do quantum machine learning and be on the cutting edge of quantum computing. In this article, we'll check how to make quantum machine learning more efficient using a technique called mid-circuit measurement and qubit reuse & we'll try to reduce qubits using a new feature of blueqat.
Mid-circuit measurement and qubit reuse (MCMR)?
MCMR, for short, is a technique that involves taking a measurement of only a specific qubit in the middle of a circuit, and then resetting the circuit after the measurement of that qubit. By taking a measurement on a particular qubit and initializing it to
In this example, we will try to reduce a three-qubit circuit to two qubits. Let's look at the following structure.
|0> --*-----
|
|0> --U--*--
|
|0> -----U--
Let's look at the top qubit and the bottom qubit. The circuit will be the same only if the bottom qubit is initialized after the top qubit is measured. If we turn the bottom circuit upside down and rewrite it using MCMR, we can do the following
|0> --*-- U--
| |
|0> --U----*--
In mid-circuit measurement and qubit reuse (MCMR), the order of measurement and initialization of qubits is devised in such a way that complex calculations can be performed with fewer qubits. Currently, MCMR is implemented on Honeywell machines and on IBM machines.
Let's look at the state vector
To understand how it works, let's look at the transition of the state vector, and check out the circuit of two qubits.
|0> --H--*--
|
|0> -----X--
This is a quantum entanglement circuit. The state vector is
from blueqat import Circuit
Circuit().h[0].cx[0,1].run()
array([0.70710678+0.j, 0. +0.j, 0. +0.j, 0.70710678+0.j])
You can use rxx to write it in one step.
|0> ---*----
|
|0> ---RXX--
from blueqat import Circuit
import math
Circuit().rxx(-math.pi/2)[0,1].run()
array([0.70710678+0.j , 0. +0.j ,
0. +0.j , 0. +0.70710678j])
Thus, we have an entangled state of
|0> ---*----測定
|
|0> ---RXX---------
If
import numpy as np
vec00 = np.array([1, 0, 0, 0])
If
vec11 = np.array([0, 0, 0, 1])
The result is
vec01 = np.array([0, 1, 0, 0])
In other words, the state vectors are initialized to different quantum states, with the state vectors diverging depending on the measured qubit.
|0> ---*---- |0>--
|
|0> ---RXX--------
Finally, when we measure the above circuit again, the first time we get
Circuit(2).m[:].run(shots=100, initial=vec00)
Counter({'00': 100})
Also, the first time
Circuit(2).m[:].run(shots=100, initial=vec01)
Counter({'10': 100})
The result of the first measurement changes the result for subsequent sampling, and by using entanglement many times, the state vector of the quantum state will diverge with each intermediate measurement and reset.
Applications to Quantum Machine Learning
To apply these to quantum machine learning, we can reuse these for convolution and other applications of quantum machine learning. For example, suppose we have a convolutional circuit such as QCNN for image recognition.
|0> --*--
|
|0> --U--*--
|
|0> --U--U----
|
|0> --*--
This means that the
|0>--U------------*--
| |
|0>--*-- |0>--U--U----
|
|0>------------*--
Using the MPS circuit, the number o qubits can be further reduced. In this way, quantum machine learning can be efficiently used on Honeywell and IBM machines by efficiently using MCMR in quantum circuits that approximate quantum states, such as MPS and TTN/MERA.