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