2
$\begingroup$

So recently I was building some circuit made of subcircuits. My subcircuits happen to use auxiliary qubits, that are always initialized in the state $|0\rangle$ and are not used after the calculation. Hence, I wanted to use the same set of auxiliary qubits for all the subcircuits by reinitializing them between subcircuits. As I code on Qiskit, I used reset gates to do so.

But I have a problem : my circuit is correct on each possible input state that belongs to the basis $\{|0\rangle,|1\rangle\}^{\otimes n}$, but the reset gates make it fail for any superposed state, henceforth losing all quantum advantage.

I'll explain the problem with a simplified example : let's say that I have two subcircuits, C and C', that operate on 1 main qubit (that I want to change) and use 1 auxiliary qubit. When C takes as input $|0\rangle$ for the main qubit, it outputs the main qubit in the state $|0\rangle$ and leaves the auxiliary qubits in the state $|0\rangle$, and when it takes as input $|1\rangle$ for the main qubit, it outputs the main qubit in the state $|1\rangle$ and gets the auxiliary qubits in the state $|1\rangle$. My full circuit resets the auxiliary gate between C and C' (with the Qiskit reset gate) and then C' is applied to get the wanted output on the main qubit. Now, if I input the state $\frac{|0\rangle+|1\rangle}{\sqrt{2}}$ on the main qubit, which is overall (taking into account the auxiliary qubit) the input state $\frac{|0\rangle+|1\rangle}{\sqrt{2}} \otimes |0\rangle$, after C we get : $$\frac{|00\rangle+|11\rangle}{\sqrt{2}}$$ But then after the reset gate we don't get : $$\frac{|00\rangle+|10\rangle}{\sqrt{2}}$$ But $|00\rangle$ 50% of the time and $|10\rangle$ 50% of the time. As superposition is broken, the main circuit gets flawed.

This behavior can be reproduced with the following code:

qc=QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc.reset(1)
backend=Aer.get_backend('statevector_simulator')
plot_histogram(execute(qc,backend,shots=1024).result().get_counts())

And by the way, in my understanding, this is in disagreement with this answer - which motivated me to ask my question, even if it may seem redundant at first sight.

Is there a way I could fix that ?

I am pessimistic, as in my previous example, the operation I'd like to apply isn't unitary. But I know that I can find on this site people that are amazing at quantum computing, so I have hope that a solution can be found.

Thanks a lot,

Thomas

$\endgroup$
2
  • $\begingroup$ Hi Thomas! I can't reproduce your issue, if I'm running your code above I'm getting 50% $|00\rangle$ and 50% $|10\rangle$. Can you try installing the latest version of Qiskit and see if the behavior persists? $\endgroup$ – Cryoris Apr 8 at 21:22
  • $\begingroup$ Hello Cryoris ! Well we then have the same behavior running this code :) And here is my problem, because I wanted to keep the superposition, and it is lost. My problem isn't a bug in Qiskit, it is that what I used to perform my resetting qubits action didn't go as I wanted. I am not saying that Qiskit reset gates behave wrongly, I'm saying that they do not fit my needs, as explained in the example. Thanks for your help :) $\endgroup$ – Thomas Pochart Apr 9 at 6:15
3
$\begingroup$

The important point to understand is that you lose the superposition and obtain a classical mixture of states $|0\rangle$ and $|1\rangle$ on the first qubit. If you look at the circuit diagram below:

  • Before applying the reset you're in a Bell state (green).
  • As you apply the reset, you effectively remove the qubit from the system, you can think of it as tracing it out. If you trace out system B in the Bell state you obtain a maximally mixed state (blue).
  • Finally, you add a new qubit in state $|0\rangle$ that has no correlation whatsoever with qubit A, so you end up in a product state of a mixed state and the zero state (red).

enter image description here

This means your final state is not a pure state where the first qubit is in state $\frac{|0\rangle + |1\rangle}{2}$ and the second one, reset, in state $|0\rangle$. Instead, it is a mix of classical probabilities $$ \rho_{AB} = (p_1 \rho_1 + p_2 \rho_2) \otimes |0\rangle\langle 0| $$ where $p_1 = p_2 = 1/2$ and $$ \rho_1 = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}, \rho_2 = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix}. $$

If you now perform a statevector simulation of this circuit, you have a 50% probability of measuring state $|00\rangle$ and 50% of measuring $|10\rangle$. Running this in Qiskit

from qiskit import QuantumCircuit, Aer, execute

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.reset(1)

print(circuit.draw())

backend = Aer.get_backend('statevector_simulator')
statevector = execute(circuit, backend).result().get_statevector()
print('Statevector')
print(statevector)

will print [1, 0, 0, 0] in half the cases and [0, 1, 0, 0] in the other half. It is a classical combination of quantum states, not a superposition like [0.707, 0.707, 0, 0].

What's a bit confusing now is that counting shots gives the same histogram for the classical mix of quantum states as for superposition. That's because the probability to measure either $|0\rangle$ or $|1\rangle$ is the same for both. In Qiskit code:

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.reset(1)
circuit.measure_all() 

backend = Aer.get_backend('qasm_simulator')
counts = execute(circuit, backend).result().get_counts()
print('Counts')
print(counts)

Will give on average {'00': 512, '10': 512}. But the pure state $|\phi\rangle = \frac{|0\rangle + |1\rangle}{2} \otimes |0\rangle$ will give the same histogram:

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.measure_all() 

A reset is a very "brutal" non-unitary operation and will destroy the pure state you have.


Note: you can derive the same result by computing the density matrices in the circuit from @Egretta.Thula, I just skipped it to make the diagram easier.

$\endgroup$
4
  • $\begingroup$ Overall, your answer makes sense to me, but there's something I don't really understand. You said $\mathbb{1}_2/2 \otimes |0\rangle \langle 0 |_B$ to be a state, and I don't follow you on that. From what I know of quantum mechanics (I'm still a grad student, so maybe it's incomplete), you are taking the tensor product of two operators, and thus you get an operator and not a state. As a result, I don't know whether your answer proves that in a general manner, there is no way I can reset my qubits as I initially wanted. Could you please clarify that ? Thanks a lot for your time $\endgroup$ – Thomas Pochart Apr 10 at 13:34
  • $\begingroup$ This is a density matrix representation (in fact all $\rho$ I used are) of a quantum state. A density matrix can represent more general states, such as mixed states, while the "ket"/vector representation only works for pure states. So $\mathbb{1}/2 \otimes |0\rangle\langle0|$ is a tensor product of two states (in density matrix representation), not operators. See e.g. en.wikipedia.org/wiki/Density_matrix for more details on density matrices. $\endgroup$ – Cryoris Apr 10 at 22:02
  • $\begingroup$ Ok, I think that I understand your answer now, thanks a lot. It definitely answers my question, thanks a lot for all the details you provided. $\endgroup$ – Thomas Pochart Apr 11 at 12:24
  • 1
    $\begingroup$ Sure thing, it was a good question! $\endgroup$ – Cryoris Apr 11 at 12:39
2
$\begingroup$

According to this link, IBM does not implement Reset instruction as a swap gate between the target qubit and a new ancilla qubit in the $|0⟩$ state. It is implemented as a

not-gate conditioned on the measurement outcome of the qubit

Which means your circuit is equivalent to the following circuit:

enter image description here

This should explain the results you have obtained.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.