Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Home
- Education Sector
- Educator Developer Blog
- Quantum Teleportation in Q#

Quantum Teleportation in Q#

- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content

Published
Mar 21 2019 11:51 AM
1,073
Views

Mar 21 2019
11:51 AM

Mar 21 2019
11:51 AM

First things first, quantum teleportation isn’t going to get my grandma in Yorkshire to my flat in London, although that would be nice. Now, she’s heard I like this thing called ‘quantum’ and has decided that instead of sending me money and socks for my birthday, she wants to send me a quantum state instead.

But unfortunately, she can’t just email me this qubit or pop it in the post, no. She needs a quantum channel to send it through, and Yorkshire only just got internet, so chances are slim they’ve got one of those.

If my grandma has no means to send quantum information, then maybe she can communicate it classically instead – for example over the internet, or over the phone. The trouble is, a quantum state is continuous, so she’d need to tell me an

Just when she was beginning to lose all hope, I say

- Sending Grandma's quantum mail
- Getting the code up and running
- Making sense of the code

Step 0 – "Here's what you should've prepared earlier"

For this to work, my grandma and I need to have pre-prepared a Bell state, where her qubit |

Remember the great property about entanglement - that measurement outcomes are correlated? If my grandma measures her qubit, it's going to affect my qubit (again, despite the distance). We're going to exploit this property in the following steps.

Step 1 – Entangle grandma’s qubit with |ψ⟩

This is a quantum circuit which we can use to describe our initial starting point. At the top left we’ve got the source of all this effort – a qubit my grandma wishes to send me. It’s in an unknown state which we can represent in the following way,

Also in her possession is her qubit, |

We’re going to begin by entangling my grandma’s qubit |

Applying a CNOT

This is our circuit once we’ve added the CNOT gate into the mix. The input state of the CNOT gate can be written as |ψ⟩|G⟩, where the first input corresponds to the upper wire, and the second input corresponds to the middle wire. Replacing |ψ⟩ and |G⟩ with their definitions, we have

We can multiply out the brackets, as shown below:

This gives us the input . Each of these terms is operated on by the CNOT gate. We talked about the CNOT gate in the first post, and we said how it works on two qubits. The eagle-eyed will have noticed that each of our terms |000〉, |011〉, |100〉 and |111〉 have three qubits. In this instance, the first two qubits are used as the control and the target, shown below.

When the control value is |1〉, the target qubit is flipped. This means the |100〉 state becomes |110〉, and |111〉 becomes |101〉. All the other states remain the same.

So once the CNOT gate has acted, we have the result .

Applying a Hadamard

The second step to entangle |

Just to remind you of the Hadamard transformation, it takes |0〉 and |1〉 to these states:

The output of the CNOT gate was . Time to apply the Hadamard gate to the first qubit of each term. What’s coming up doesn’t look pretty, but take a deep breath, this is our output:

So our result is now

Spring cleaning

It’s in a right old state. Let’s tidy this up. If we look at the first term , you’ll notice we have two √2 factors, we’re going to pull these out of their fractions, and multiply them like so,

Applying the same logic to the remaining terms, we obtain , and . You’ll notice the 1/2 factor is common to each of them, so we can take it outside the brackets giving the collective result: This is already looking better. Now we’re going to expand out the brackets (this will make it easier for our next step). I’m going to expand as an example.

I’d leave the remaining ones “as an exercise” but if you’re anything like me that means you won’t do them. So here’s the expansions of the remaining terms:

Collecting them all together, we get the following result:

Step 2 - Taking a measurement

Now that we have entangled my grandma’s qubit |

More tidying up

This is the last time we do this, I promise. When we measure the first and second qubit, we’re going to get one of four results, either 00, 01, 10, or 11. Currently, it’s not all too clear what our third qubit would be, for each of these measurements. We’re going to regroup our result so that we know what state the third qubit, my qubit |

Currently we have the result

Let’s highlight the first and second qubit of each term:

Consider the cases where the first and second qubit equal |00〉. If we look at this case in isolation, we have . We can refactor this term as shown below,

And we can do similarly for the |01〉, |10〉, and |11〉 cases.

In summary, our regrouping looks like this:

Perfect.

Making a measurement

This is what our circuit looks like with the measurement symbols added. I just want to point out the double lines after the measurement symbols – that’s not an accident, it means they’re carrying

My grandma is going to measure her two qubits |

Now say we measure the second qubit, |

The lovely thing about this is, we now know what state the third qubit is in (that’s my qubit |

What if we have a measurement result of ‘01’? Let’s look at our factored result:

The only term consistent with a measurement of ‘01’ is (using the same logic we just used) which means my qubit must be . Again, applying that logic, if my grandma measures ‘10’, I know the third qubit is . And if my grandma measures ‘11’, then the third qubit is .

We can summarise this like so:

Step 3 - Performing an operation on my qubit (F) to get the state |ψ⟩

Currently we’re in a position where my grandma has measured her two qubits, and called me up and told me the result, so I now know what state my qubit is in. Remember that the unknown state we began with |

That’s a simple thing for us to do now. Look at the table above. If we’ve got a measurement of ‘00’, and my qubit in the state , then you can see this is exactly the same as |

Now look at the situation where our measurement is ‘01’, and my qubit is in the state . Note that in comparison to |

If we look at the ‘10’ case, my qubit would be in the state . If we compare this to |

Finally, we have the ‘11’ case, where by qubit is . Here, |0〉 and |1〉 are flipped, and also we have , but we’d like this term to be positive. We need to apply an

Notice that if the first bit of our measurement result is '1', we apply

We have shown that my grandma needs to communicate just two bits of classical information to me to share the unknown state, these are the results of the measurements of |

Now that we understand the theory behind quantum teleportation we can dive into some code!

If at any point you get stuck you can find the code here (just clone or download the repo, open ' QuantumTeleportation.sln ' in Visual Studio and follow Step 5).

Step 1: Create a new Project

Create a new ‘Q# Application’ in Visual Studio and name it something sensible like ‘QuantumTeleportation’.

Step 2: Get a copy of the code

Get a copy of the quantum samples on your machine – either by cloning or downloading from them here: https://github.com/Microsoft/Quantum .

Step 3: Edit Operation.qs

Next, you want to replace all of the code in ‘Operation.qs’ with the code in ‘TeleportationSample.qs’, which you’ll find under Quantum > Samples > Teleportation here .

Step 4: Edit Driver.cs

Similarly, you want to replace all of the code in ‘Driver.cs’ with the contents of ‘Program.cs’.

Step 5: Save and Run

Run the code by pressing ‘start’. The output should print results for rounds 0-8 which look like the below:

I say ‘making sense’ which isn’t fair, the code is commented beautifully :raising_hands:. What we’re going to do is relate the code back to the theory we’ve just learned, which won’t be too difficult.

Step 1: Teleport

Throughout the post we’ve talked about three qubits, the first being the qubit in an unknown state |

As we discussed, my grandma and I share a Bell state which we had to prepare ahead of time. So we need to entangle her qubit,
**
here
**
, with mine,
**
there
**
before we can do anything else. This is done in the code by applying the Hadamard gate and CNOT like this:

Now we’re going to refer to our circuit diagram which I’m going to annotate with the naming as it appears in the code.

Walking through the steps we’ve gone through in the blog post, we first entangled my grandma’s qubit

Then we measured the first and second qubit,

As we discussed in the final part of the blog, once we’ve got our measurement, we want to alter my qubit so that it matches with the qubit |

Done! My qubit is now in the state my grandma wished to send me :smiling_face_with_smiling_eyes:

Step 2: TeleportClassicalMessage

Next we’re going to look at how we can use our

We begin by allocating a register with two qubits, the Boolean message we will send (

The

We use our

We then measure my qubit’s state

This gives us the Boolean result – an important use of decades of research into quantum mechanics and computation – of whether a warm brew is in sight.

Running the code shows the result of sending different Boolean states, which you can find in the

And we’re done!

If you've got any questions about this blog, or the previous one, please comment below or ask me on twitter @frances_tibble . Next up we'll be looking at measurement in a bit more detail. If you'd like to go into more depth on some of the gates that we've seen in this post then do check out Anita's blog here .

- Learn more at the Microsoft Quantum website: https://www.microsoft.com/en-us/quantum/
- Download the Quantum Development Kit: https://www.microsoft.com/en-us/quantum/development-kit
- Stay up to date with the Microsoft Quantum newsletter: https://info.microsoft.com/Quantum-Computing-Newsletter-Signup.html
- Read about the latest developments on the Microsoft Quantum blog: https://cloudblogs.microsoft.com/quantum/
- Twitter: https://twitter.com/MSFTQuantum
- Facebook: https://www.facebook.com/MicrosoftQuantum/

0
Likes

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.