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 ∣0⟩, you can sample a more complex quantum state than the state vector alone for a number of qubits.
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
Copy
from blueqat import Circuit
Circuit().h[0].cx[0,1].run()
Thus, we have an entangled state of 2∣00⟩+∣11⟩. If we measure only the 0th qubit in this state, we get
|0> ---*----測定
|
|0> ---RXX---------
If q0=0 is measured, then ∣00⟩ is determined and ∣ψ⟩=∣00⟩. The state vector in that case is
Copy
import numpy as np
vec00 = np.array([1, 0, 0, 0])
If q0=1 is measured, then ∣11⟩ is confirmed and ∣ψ⟩=∣11⟩.
Copy
vec11 = np.array([0, 0, 0, 1])
The result is ∣11⟩. Now, if we initialize the 0th qubit to ∣0⟩, then ∣11⟩ becomes ∣01⟩.
Copy
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 q0=0, the second time we get 00, so we get a sample of 000.
Copy
Circuit(2).m[:].run(shots=100, initial=vec00)
Counter({'00': 100})
Also, the first time q0=1, the second and subsequent measurements will give 01, giving a sample of 101. In blueqat, the value of the 0th qubit is on the right.
Copy
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.
This means that the q0 circuit is collapsed into q1, q3 is collapsed into q2, and q1 is collapsed into q2 again. It is a four-qubit circuit, but using MCMR
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.