Monday, 14 March 2016

8 - The Toric Code (part 3)

This is part of a project to get people involved with quantum error correction. See here for more info.

I'm going to guess that no-one jumps into part 3 of something without looking at part 1 and part 2. So I'll assume you know about the toric code in this post.


We have a bunch of qubits, which we call physical qubits. These are too noisy to do anything useful. To make a useful qubit, which we call a logical qubit, we put our physical qubits on a grid.

Here the physical qubits aren't just allowed choose whether to be 0 or 1 randomly. They have to follow the rules. The rules state that every white square must have an even number of 1's around it.

We want to make it relatively hard to see whether our logical qubit value is 0 or 1. We don't want some Gremlin coming along and measuring it, because he might mess up all our quantumness. So we take the physical qubits shown in blue below. Or the ones shown in green. Or any other loop that passes through blue squares and goes through the doughnut.

We just add up all the physical qubit values along one of these loops. If the answer is odd, the logical qubit value is 1. If it is even, the logical qubit is 0.

It turns out that this measures the number of loops of 1's that pass through white squares around the torus, and tells us whether it is odd or even. The examples in (a) and (b) don't have loops like this, so they come out even. If we want our logical qubit value to be 0 we could use one of these, or a whole bunch of other possibilities. The examples in (c) and (d) have one of these loops, so they come out odd. If we want our logical qubit value to be 1 we could use one of these, or a whole bunch of other possibilities.


How much effort would it take to mess everything up? If we've make a logical qubit with value 0, for example, how could errors make us think it was a 1?

Suppose we make our logical qubit using (a), and so all physical qubits are set to 0. Then an error happens, flipping one of the physical qubits to 1. For example:


Why is that red line there, you may ask. Don't worry, it'll make sense later.

For the blue physical qubits, this looks exactly the same as in (c). If we measure whether our logical qubit by looking at these, it will tell us that that its value is 1. That's wrong! All is lost!

Well, not quite yet. Remember that the 0's and 1's in the grid have to follow the rules. This error has broken them! The white squares either side of it now have an odd number of 1's around them. I have given them an orange border to shame them for their rebellion.

To make things more interesting, let's have a few more errors happen.


Here we have three all near each other. They form a little string of 1's. For every square, the rules are obeyed. This is because the string contributes two 1s: one when it enters and one when it leaves. But the ends of the string are a different story. These squares only get a single 1. They have an odd number of 1's. They are breaking the rules.

Correcting the errors

Finding the rule-breaking squares gives us a clue about what errors have happened. We know that they form a string, and that the orange squares are the endpoints.

That doesn't tell us exactly what happened. In both cases above, for the single error in (e) or the longer string of three in (f), the rules are broken in the same places. How can we correct the errors if we don't know what errors happened?

If errors are rare, the single error of (e) is a lot more likely than the three in (f). So we would assume that it was (e) that happened. To correct it, we would flip the corresponding physical qubit.

If we were right, and it really was (e) that happened, the 1 is flipped back to a 0. Everything is back to how it was. All the physical qubits will have the values of (a), the rules are all obeyed and our logical qubit is back to having value 0.

If we were wrong, and it was (f) that happened, we add to to the string rather than removing it. The addition joins the ends together making a loop. This is just a little loop, not one that goes around the doughnut. In fact, it is the same loop as in (b), which also corresponds to a logical qubit with value 0. We could have chosen to use these values for our physical qubits in the first place. So everything is fine. The errors have not been removed, but they have been integrated into society as productive and law abiding qubits.

In this example, it seems like the errors still leave a trace: they have added a little loop where none was before. But we can only see this because we are currently letting ourselves look at whether each qubit is 0 and 1. Actually doing these measurements would itself a source of errors. They will be outlawed in a later article, just as bit flips are here. So, in the end, the only things we'll be able to look at are whether the rules are obeyed, and what the loop around the doughnut is doing. As long as the errors don't effect these, any observable effect is completely removed.


When a bunch of bit flips happen on our nice neat code, it's best to think of them in terms of strings. When we look at the squares, and find out which ones break the rules, it tells us where the endpoints of those strings are. Then we have to try and stick the ends together and make loops.

We might not do this exactly right. We might end up making the loop bigger than it needs to be. We might end up combining a few different strings into the same loop. But that doesn't matter. All that matters is that none of the loops pass around the doughnut. As long as we achieve this, our logical qubit value will not change. The errors will have failed to have an effect.

It can be that we will get it wrong. If noise creates a string of flips that goes almost all the way around the doughnut, we'll probably end up completing it by mistake. But this needs a lot of errors to happen, and for them all to lie along the same loop. This is pretty unlikely, so we'll end up nicely correcting our errors most of the time.

What else do we need to know

We've now seen how to store a logical qubit in the toric code, and how to protect it from errors. So what else is there? Well, we've only looked at bit flip errors so far. What if those nasty gremlins were to go around measuring things that they shouldn't? They'd have to do a lot of it to cause any harm, because you can't measure the logical qubit values without looking at a whole bunch of qubits. But that's not the only trick that the toric code has up its sleeve. Next time we'll take a little look at how to foil this kind of error.

No comments:

Post a Comment