Path: blob/main/notebooks/ch-algorithms/teleportation.ipynb
3855 views
Quantum Teleportation
This notebook demonstrates quantum teleportation. We first use Qiskit's built-in simulators to test our quantum circuit, and then try it out on a real quantum computer.
Alice wants to send quantum information to Bob. Specifically, suppose she wants to send the qubit state . This entails passing on information about and to Bob.
There exists a theorem in quantum mechanics which states that you cannot simply make an exact copy of an unknown quantum state. This is known as the no-cloning theorem. As a result of this we can see that Alice can't simply generate a copy of and give the copy to Bob. We can only copy classical states (not superpositions).
However, by taking advantage of two classical bits and an entangled qubit pair, Alice can transfer her state to Bob. We call this teleportation because, at the end, Bob will have and Alice won't anymore.
2. The Quantum Teleportation Protocol
To transfer a quantum bit, Alice and Bob must use a third party (Telamon) to send them an entangled qubit pair. Alice then performs some operations on her qubit, sends the results to Bob over a classical communication channel, and Bob then performs some operations on his end to receive Alice’s qubit.

We will describe the steps on a quantum circuit below. Here, no qubits are actually ‘sent’, you’ll just have to imagine that part!
First we set up our session:
and create our quantum circuit:
Step 1
A third party, Telamon, creates an entangled pair of qubits and gives one to Bob and one to Alice.
The pair Telamon creates is a special pair called a Bell pair. In quantum circuit language, the way to create a Bell pair between two qubits is to first transfer one of them to the X-basis ( and ) using a Hadamard gate, and then to apply a CNOT gate onto the other qubit controlled by the one in the X-basis.
Let's say Alice owns and Bob owns after they part ways.
Step 2
Alice applies a CNOT gate to , controlled by (the qubit she is trying to send Bob). Then Alice applies a Hadamard gate to . In our quantum circuit, the qubit () Alice is trying to send is :
Step 3
Next, Alice applies a measurement to both qubits that she owns, and , and stores this result in two classical bits. She then sends these two bits to Bob.
Step 4
Bob, who already has the qubit , then applies the following gates depending on the state of the classical bits:
00 Do nothing
01 Apply gate
10 Apply gate
11 Apply gate
(Note that this transfer of information is purely classical.)
And voila! At the end of this protocol, Alice's qubit has now teleported to Bob.
In this notebook, we will initialize Alice's qubit in a random state (psi). This state will be created using an Initialize gate on . In this chapter we use the function random_statevector to choose psi for us, but feel free to set psi to any qubit state you want.
Let's create our initialization instruction to create from the state :
(Initialize is technically not a gate since it contains a reset operation, and so is not reversible. We call it an 'instruction' instead). If the quantum teleportation circuit works, then at the end of the circuit the qubit will be in this state. We will check this using the statevector simulator.
We can see below, using the statevector obtained from the aer simulator, that the state of is the same as the state we created above, while the states of and have been collapsed to either or . The state has been teleported from qubit 0 to qubit 2.
You can run this cell a few times to make sure. You may notice that the qubits 0 & 1 change states, but qubit 2 is always in the state .
3.3 Using the Simulated Counts
Quantum teleportation is designed to send qubits between two parties. We do not have the hardware to demonstrate this, but we can demonstrate that the gates perform the correct transformations on a single quantum chip. Here we again use the aer simulator to simulate how we might test our protocol.
On a real quantum computer, we would not be able to sample the statevector, so if we wanted to check our teleportation circuit is working, we need to do things slightly differently. The Initialize instruction first performs a reset, setting our qubit to the state . It then applies gates to turn our qubit into the state :
Since all quantum gates are reversible, we can find the inverse of these gates using:
This operation has the property:
To prove the qubit has been teleported to , if we do this inverse initialization on , we expect to measure with certainty. We do this in the circuit below:
We can see the inverse_init_gate appearing, labelled 'disentangler' on the circuit diagram. Finally, we measure the third qubit and store the result in the third classical bit:
and we run our experiment:
We can see we have a 100% chance of measuring (the purple bar in the histogram) in the state . This is the expected result, and indicates the teleportation protocol has worked properly.
As you have worked with the Quantum Teleportation's implementation, it is time to understand the mathematics behind the protocol.
Step 1
Quantum Teleportation begins with the fact that Alice needs to transmit (a random qubit) to Bob. She doesn't know the state of the qubit. For this, Alice and Bob take the help of a third party (Telamon). Telamon prepares a pair of entangled qubits for Alice and Bob. The entangled qubits could be written in Dirac Notation as:
Alice and Bob each possess one qubit of the entangled pair (denoted as A and B respectively),
This creates a three qubit quantum system where Alice has the first two qubits and Bob the last one.
Step 2
Now according to the protocol Alice applies CNOT gate on her two qubits followed by Hadamard gate on the first qubit. This results in the state:
Which can then be separated and written as:
Step 3
Alice measures the first two qubit (which she owns) and sends them as two classical bits to Bob. The result she obtains is always one of the four standard basis states and with equal probability.
On the basis of her measurement, Bob's state will be projected to,
Step 4
Bob, on receiving the bits from Alice, knows he can obtain the original state by applying appropriate transformations on his qubit that was once part of the entangled pair.
The transformations he needs to apply are:
After this step Bob will have successfully reconstructed Alice's state.
5.1 IBM hardware and Deferred Measurement
The IBM quantum computers currently do not support instructions after measurements, meaning we cannot run the quantum teleportation in its current form on real hardware. Fortunately, this does not limit our ability to perform any computations due to the deferred measurement principle discussed in chapter 4.4 of [1]. The principle states that any measurement can be postponed until the end of the circuit, i.e. we can move all the measurements to the end, and we should see the same results.
Any benefits of measuring early are hardware related: If we can measure early, we may be able to reuse qubits, or reduce the amount of time our qubits are in their fragile superposition. In this example, the early measurement in quantum teleportation would have allowed us to transmit a qubit state without a direct quantum communication channel.
While moving the gates allows us to demonstrate the "teleportation" circuit on real hardware, it should be noted that the benefit of the teleportation process (transferring quantum states via classical channels) is lost.
Let us re-write the bob_gates function to new_bob_gates:
And create our new circuit:
As we see here, there are a few results in which we measured . These arise due to errors in the gates and the qubits. In contrast, our simulator in the earlier part of the notebook had zero errors in its gates, and allowed error-free teleportation.
6. References
[1] M. Nielsen and I. Chuang, Quantum Computation and Quantum Information, Cambridge Series on Information and the Natural Sciences (Cambridge University Press, Cambridge, 2000).
[2] Eleanor Rieffel and Wolfgang Polak, Quantum Computing: a Gentle Introduction (The MIT Press Cambridge England, Massachusetts, 2011).