# In Qiskit quantum teleportation protocol, why they use CZ and CX gate at the end?

I understand the simple quantum teleportation protocol and why it uses X and Z gate at the end of the circuit.

I was researching about the Qiskit and I came across this video

which uses the following algorithm for quantum teleportation.

I don't understand why they use CX and CZ gate with qubits $$q_0$$ and $$q_1$$ as controls and qubit $$q_2$$ as the target at the end.

Please try to explain why they're using CZ and CX gate at the end of the circuit.

• Which part exactly don't you understand? In the top example they also use cx and cz gates at the end of the circuit May 19, 2020 at 19:23

The top circuit uses classically controlled X and Z gates - gates that are conditioned on the measurement result.

The bottom circuit uses quantum version of controlled X and Z gates - gates that are conditioned on the state of another qubit. Since each of the control qubits have been measured before applying CX and CZ gates, their state matches exactly the measurement results: measurement result 1 (which would lead to gates applied in the top circuit) corresponds to qubit state $$|1\rangle$$ (which leads to gates applied in the bottom circuit).

More generally, you can do teleportation even without those two measurements in the bottom circuit, following the principle of deferred measurement.

Let's say Alice is transferring her qubit to Bob. Alice measures her own qubits and tells the outcome to Bob. Depending on the measurement result of Alice, Bob applies some operations on his qubit so that he obtains exactly the same qubit intended to sent by Alice.

If Alice observes 1 in her first qubit, then Bob should apply Z and if she observes 1 in her second qubit, then Bob should apply Z. As indicated in the first picture, those are classically controlled operations, that is performed according to the measurement results written in the classical register.

You can check the following notebook for implementation and more details. https://gitlab.com/qkitchen/basics-of-quantum-computing/-/blob/master/bronze/B56_Quantum_Teleportation.ipynb