# Quantum Teleportation — From Fiction to Reality

## Applying Quantum Information Theory with Qiskit

I’ve heard the word ** ‘quantum’ **dozens of times throughout my life, but never gave it a second thought. It sounded sick but I was always way too scared to dive into the

**math**and

**physics**of it all to realize what I was missing out on.

A couple of weeks ago, I found a random Twitter thread about **‘quantum teleportation.’**

Teleportation? Like sci-fi teleportation?

That’s what I thought too. Unfortunately, it’s not ** actually** referring to the teleportation of

*material thing*s. Instead, it’s the teleportation of information…

*quantum information*…

At face value, it definitely doesn’t seem as cool, but *before dismissing it* let’s learn what quantum teleportation actually is — and how we can implement it ourselves!

Note that we’re going to be focusing on *applying* quantum teleportation as opposed to *rigorously learning* **exactly** what’s happening. Unfortunately, quantum teleportation requires a strong foundation in the field of* quantum mechanics* and* linear algebra *but we’re not gonna let these won’t stop us from learning **how to code it out ourselves**.

Note that if you’re looking for a more mathematical approach to quantum computing, check outthisarticle.

# What is Quantum Teleportation?

Quantum teleportation is the teleportation of information between special types of classical bits known as quantum bits or ‘**qubits**.’

If that sounds like absolute gibberish to you, don’t worry about it. Let’s go through this one step at a time.

## Review time! What’s a classical bit?

I’m sure you’ve heard that all of our technology runs in something known as ‘**binary**’ — or in other words, **0’s and 1’s**. Think of a classical bit like a* storage compartment* for these 0’s and 1’s.

Each 0 or 1 is represented in a bit. However, classical bits are limited to these 0’s and 1’s. Quantum bits however work a little bit differently.

## Sooo what’s so special about a quantum bit?

Quantum bits aren’t exactly as simple as just 0’s and 1’s. They’re somewhere in the middle.

They actually live in something known as a **superposition** of 0’s and 1’s. Instead of simply being a 0 or 1, a quantum bit has a probability of being **either 0 or 1** with the probabilities stored in a **mathematical list **known as a *vector*. Pretty sick, right?

Despite living in a superposition, all qubits ultimately turn into 0’s or 1’s when measured.

Think of it this way. You have a qubit that has a **60% chance **of being a 0, and a **40% chance **of being a 1. Until you measure the value of the qubit, it lives in this probability forever. However, once you actually measure or try to observe it, it collapses into *either a 0 or a 1.*

There are certain gates that we can use to manipulate these specific states. For example, we can flip the probabilities of being 0 or 1 using a gate called the **NOT** or** **‘**X**’** gate**. For example, if we have a qubit with a **70% probability** of collapsing into a 0 and a **30% probability **of collapsing into a 1, the NOT gate will reverse that – *30% probability for 0, and 70% probability for 1.*

That’s just a simple example, we’ll go more into gates later on when we start using them,

## Why are qubits useful?

There are a lot of super useful applications of having qubits. A lot of the world currently runs on bits, so this new type of bit changes a lot of what we know about the world in a fundamental sense. A lot of this is seen in the study of ‘**quantum mechanics**.’

Unfortunately, we’re not actually going to go deep into why this is actually useful. For this article, we’re simply going to use these qubits to **implement quantum teleportation.**

# Redefining Quantum Teleportation

Now that we know what classical and quantum bits are, let’s **redefine** what quantum *teleportation* and *information* **actually** **is**. With quantum teleportation, we’re teleporting the superposition of **one qubit** to **another**.

## Alice and Bob

Suppose we have two people, **Alice** and **Bob**. Alice has a laboratory with a qubit in a specific superposition. This essentially means that her qubit has a set probability of collapsing to either a 0 or a 1. Bob also has a laboratory in a far-off location with a qubit. He wants **his qubit **to take the superposition of **Alice’s qubit**.

The first thing that might come to mind is **copying** the superposition of **Alice’s qubit **and applying it to **Bob’s qubit**. However, in quantum physics, there’s a theorem known as the ‘**no-cloning theorem**’ that states that the superposition of a qubit cannot be copied onto another qubit. The issue is that Alice doesn’t actually *know* the superposition of her quantum bit.

The second that anyone observes a qubit, it collapses into a 0 or 1, losing its superposition.

All the quantum information it possessed (aka its superposition) is lost. Think of it this way — suppose you flip a coin. Before you flip the coin, there’s a **50% chance of landing on heads** and a** 50% chance of landing on tails**. However, once the coin lands, this probability collapses. It’s definitively either a heads or a tails. At this point, the probability becomes irrelevant unless you flip the coin again.

This means that there isn’t an **innate way **of telling what the superposition of a qubit is *in a general sense*, thus making it incredibly difficult to** replicate its superposition in Bob’s qubit.**

Quantum teleportation refers to the manipulation of these qubits in such a way that **one qubit’s superposition **is able to *teleport* to **another **qubit physically distanced from it by leveraging the concept of ‘**quantum entanglement**.’

## Quantum Entanglement

The last pre-requisite to properly understanding quantum teleportation is understanding **quantum entanglement**.

Quantum entanglement is a phenomenon in which a *pair of qubits* are **defined** by one another.

Suppose we have two qubits: **qubit A** and **qubit B**. Qubit B is the opposite of qubit A. This means that if qubit A is 0, qubit B must be 1, and if qubit A is 1, qubit B must be 0.

This is a form of quantum entanglement since the second qubit is **defined** through the state of the first qubit. However, this isn’t the *only* scenario of quantum entanglement, it’s just an example.

We’re going to be leveraging quantum entanglement for the** implementation of quantum teleportation**.

Let’s put everything together. There’s a specific protocol known as the ‘*Quantum Teleportation Protocol*’ which allows for the teleportation of superpositions **between two qubits**.

# Quantum Teleportation Protocol – An Intuitive Explanation

Going back to our Alice-Bob example, all we need in order to achieve quantum teleportation is 1** regular qubit**, 2 **entangled qubits**, and 2 **classical bits**.

The first quantum bit is in some superposition that we’re going to denote through the symbol Φ — *pronounced* *‘phi.’ — *This qubit is going to be in **Alice’s lab **and holds the superposition we’re **going to be teleporting**.

The second and third quantum bits are **entangled** with Alice and Bob having **one each**. Alice’s qubit will be used during the teleportation process to facilitate it, while Bob’s qubit will be the one that will **receive** **the** **state** Φ.

The classical bits are used in a unique way. Alice is actually going to measure her qubits at some point and tell Bob what the results are. Bob is, in some way, going to be able to use this information to apply certain transformations to his qubit to achieve the state Φ. *For now,* *don’t worry about exactly what’s going on.*

Note that Alice and Bob can physically be **any distance away from each other **and the result will be the same. After all, there’s a reason why we refer to this process as ‘*quantum teleportation.*’

From here, the states of these different qubits are manipulated in such a way that the state of Alice’s qubit gets sent over to Bob’s qubit in a way that almost resembles magic — *if you consider math magical.*

This is actually the** quantum circuit **for the* quantum teleportation protocol*. q0 and q1 are *Alice’s qubits *and q2 is *Bob’s qubit*, while crz and crx are our *two classical bits*. The symbols on the circuit refer to the **different operations**. The H is the ‘** Hadamard gate**,’ the connected dots with the + symbol is the ‘

**,’ the Z is the ‘**

*controlled-NOT gate***,’ the X is the ‘**

*Z-gate*

*NOT-gate**,*’ and the black square

**.**

*measures the qubits*Every single one of these gates other than the measuring operation **manipulates these qubits **in some way, shape, or form. At the beginning of this article, I said that you’re not going to be walked through *all of the mathematical and physics-related rigor *of quantum teleportation due to its **vast complexities**. For now, you’re unfortunately going to have to accept that these gates are doing the job that they’re meant to be doing.

If you want to learn more about what’s going on in a** rigorous sense**, the **qiskit textbook** is a great place to start. Here, you’re walked through all the mathematics that make this protocol work, as well as a bunch of other algorithms.

# Quantum Teleportation Protocol – Coding it Out

Let’s actually create our quantum circuit! Before starting, if you want to head straight to the GitHub repo, click here. We’re going to be coding in *Python* using the famous quantum computing library ‘*Qiskit*.’

## Imports

Let’s start off with some imports. We’re going to import *Qiskit*, as well as some other important libraries that we’re going to use to help us along the way.

## Initializing the Circuit

Now, let’s initialize the circuit. We want to create** registers **to store our individual qubits and bits. We’re going to create a **quantum register **to store our quantum bits and** two classical registers**, one to store each classical bit.

Once that’s done, we’re going to initialize our quantum circuit.

## Entangling our Qubits

If you remember back to our Alice and Bob example, each of them has a qubit that is both entangled with one another. We’re going to be using a Hadamard gate, followed by a controlled-NOT gate to do so.

This combination of gates puts these two qubits in a state known as the ‘**bell state**.’ This form of entanglement essentially means that when these qubits are collapsed, there’s a** 50% probability **of both qubits collapsing into a 0, and a **50% probability **of both qubits collapsing into a 1, meaning that both qubits will always be the same when measured.

This is the *simplest form of entanglement *in quantum.

We can draw our circuit using **qc.draw(output = ‘mpl’) **to get the following result:

## Applying Gates to Alice’s Qubit

From here we apply a** controlled-NOT gate** from q0 to q1 and **Hadamard** **gate** to q0.

To provide a quick refresher on the **c-not gate**, this gate utilizes two qubits — a **control qubit**, and a **target qubit**. If the control qubit is a 0, *nothing happens*. If the control qubit is a 1, the t*arget qubit is flipped* (if it’s 0, it becomes a 1 and if it’s 1, it becomes a 0).

The Hadamard gate is a little bit harder to explain. It utilizes a concept in **Linear Algebra** known as matrix basis. Mathematically speaking, the **Hadamard gate **changes the base of a superposition from measuring in the** Z basis** to the **X basis**. *I don’t expect you to understand this, the math for quantum computing is pretty complicated! *To truly understand this, you’ll have to dive pretty deep into quantum computing.

After applying these gates, we also want to measure Alice’s qubits onto our classical bits and store them. This is going to be a little confusing at first but you’re just going to have to accept it.

## What’s going on here?

It’s probably incredibly confusing to see me applying all of these gates and not understand what we’re trying to do. Remember that our goal is to allow for Bob to **reconstruct Alice’s qubits’ superposition**. Superpositions are normally written as ** some probability * the 0 vector **and

**. This is essentially saying that all superpositions are simply made up of the probability that a qubit is 0, and the probability that the qubit is 1.**

*some probability * the 1 vector*Here’s what we’re doing. We’re essentially saying that after applying** **a** c-not gate to q0 and q1 **and then a **Hadamard gate to q0,** the measurement of q0 and q1 can give enough information for Bob to reconstruct our superposition.

Alice will measure these qubits, give Bob the results through **classical communication methods**, and then Bob will apply certain gates to reconstruct our superposition. This means that despite quantum teleportation being incredibly useful, it doesn’t allow for faster-than-light communication since classical communication methods are required.

We can draw this circuit to get the following result:

## Applying Gates to Bob’s Qubit

From here, we only have one last thing to do: **reconstruct Bob’s qubit**. If you recall, we’re going to be using Alice’s qubits measurements to figure out which gates to apply to Bob’s qubit.

If q0 measures 0, we want to apply the Z gate to Bob’s qubit. If q1 measures 1, we want to apply the X gate to Bob’s qubit. This essentially means that there are **four possible combinations** of gates that can be applied depending on the four possibilities of q0 and q1.

After we apply these gates, Bob’s qubit now has the super position that Alice’s qubit had, despite being physically distant from each other. The code for this is shown below:

Once again, understanding *why** *this works is much easier said than done. If you really want to have a good grasp of it, go through the qiskit textbook here. It may be beneficial to check out the** Linear Algebra section **as well.

One last time, let’s draw our final circuit:

## Simulation and Testing

Let’s test if this works and actually simulate this running on an actual quantum computer!

Note that we *can* run this on IBM’s actual quantum computer if we wished.However, simulations are a good way of testing to see if these circuits work.

The following code allows us to simulate our quantum circuit:

Above, we see spheres known as **bloch spheres. **These spheres are the way that we are able to visaulize quantum superpositions with the pink line being the superposition itself.

It’s a little bit hard to see if our code is working or not just through this. We know that our 0th and 1st qubit can be anything but our 2nd qubit **MUST be 0** since we teleported the** 0 state from q0 to q2**. However, this is hard to visualize at the moment. To make this easier, let’s teleport a state that’s more interesting than the 0 state (100% probability of resulting in a 0) since there’s nothing quantum about a 0 state.

I’m going to recreate all of the code from before but compile it into a cleaned up code block. This time, we’re going to** initialize q0** to have a superposition where there’s a **50% chance of being 0** and a **50% chance of being 1**.

**Let’s redraw our circuit:**

The only difference is that we now have an initialization.

# Results

Now that we have a more interesting circuit with a proper initialization, let’s resimulate our circuit multiple times to see if it’s working.

As we can see over here, q0 and q1 can be anything. However, q2 will **ALWAYS** be in the same superposition that we initialized q0 as. This means that we have **successfully teleported the superposition from Alice’s qubit to Bob’s qubit**, despite them being in different labs through the use of an entangled qubit.

If you want to access the full repository with all of my code, visit this link.

If you liked this article, please check out my other articles here.

Feel free to check out my other socials: **LinkedIn**, **Twitter**

Consider subscribing to my newsletter here! I talk a lot about my progress, experiences, and my struggles. My February issue just came out where I discuss my relationship with momentum, as well as its importance over motivation.