In Qiskit, is there a way to perform a reset of a qubit with control on another without using an additional ancilla qubit?
-
$\begingroup$ could you explain a bit better what you mean? It seems to me like perhaps the answer to your question is a CNOT gate... $\endgroup$– LiorApr 7, 2022 at 9:45
-
1$\begingroup$ @Lior: No, the CNOT negates, while reset changes any state to $|0\rangle$. $\endgroup$– Martin VeselyApr 7, 2022 at 10:06
3 Answers
-
$\begingroup$ Hi and welcome to Quantum Computing SE. Please note that once you have enough reputation, you should post such short answers (or link-only answer) as comments. $\endgroup$ Apr 7, 2022 at 10:07
I’m not 100% sure I understand the context, but I’ll try to answer to the best of my understanding of the question:
If you want to reset a qubit using quantum operations only, you can swap the state with an ancilla in the 0 state. If you want to do it controlled on the state of another qubit, do a controlled swap between the 0 state ancilla and your target qubit with the control qubit as, well, control.
You could perform a hand-rolled conditional reset with something like the code below. This will reset the second qubit if the first qubit is excited.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
qreg_q = QuantumRegister(2, 'q')
creg_cw = ClassicalRegister(1, 'cw')
circuit = QuantumCircuit(qreg_q, creg_cw)
circuit.measure(qreg_q[0], creg_cw[0])
circuit.reset(qreg_q[1]).c_if(creg_cw, 1)