Monday, 18 April 2016

10 - The Toric Code (part 5)

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

I'm going to jump straight in with this post. If you want an intro, see part 4.

Protecting against measurements

We have information stored in a toric code, which is a grid of noisy qubits. If they get hit by bit flips, its mostly fine. The only way for bad things to happen is if a load of bit flips happen all at the same time, and do so on a loop that goes around the doughnut. That's unlikely, so we're mostly okay.

Bad things also happen if the qubits get measured on a loop through the doughnut. Currently we have no way of detecting or correcting these, so they will build up over time and soon mess up our logical qubit. So how can we manage them?

Currently we have a rule for each white square: each must have an even number of 1s around it. By looking at which of these rules are broken, we can work out how to get rid of the bit flip errors. But let's forget about these rules for a while. Instead we will come up with some new rules that can be used to detect the measurements. Once we've worked those out, we can try the two sets of rules play well together.

Rules for blue plaquettes

Let's now think about the code using the + and – states from last time. With these we can declare a rule for each blue squares: when looked at in terms of + and -, each must have an even number of -'s (and therefore an even number of +'s).

There are many possible patterns of +'s and -'s that obey these rules. Here's a few.

These should look pretty familiar. They are the same ones as before, but with 0 replaced with +, 1 to –, white squares with blue and everything turned 90 degrees.

Now we go off and get a cup of tea, and a Gremlin sees an opportunity for some mischief. It measures one of the qubits to see if it is 0 or 1. Every qubit here is + or -, both of which are a superposition of 0 and 1. So the measured qubit will randomly choose one or the other. Let's say, for sake of argument, it chooses 0.

When we get back from our tea break, we check whether the blue squares are following the rules. Most are, but what about the two near the measured qubit?

When we measure those squares, we are asking them to look at how many of the qubits are in state +, and how many are in state -, and tell us whether the number of -'s is odd or even. For most of the qubits, which are simply in state + or -, this is an easy job. But the measured one is in state 0, a superposition of + and -. This has to decide whether to be + or – before the question can be answered.

If it decides to be +, which is what this qubit was originally, the rules are obeyed on these squares. The qubit has also been forced into a state that is nothing like the 0 state that the Gremlin measured, so that information is now out of date and the Gremlin knows nothing. All is well.

If it decides to be the opposite of what it was originally, the effect is similar to a bit flip. Except this kind of flip turns + to – and – to +. We call these phase flips. The phase flip causes the rules to be broken on the two blue squares. But, just like with bit flips and white squares, this allows us to detect and correct the errors. Also, the qubit is again forced into a state that has nothing to do with the one that the Gremlin measured. So its information is again out of date, and all is well.

With these rules, protecting the code from measurements is exactly the same as protecting it from bit flips. So a few measurements here and there don't cause a big problem. We can just detect them, remove their effects and update the state to make sure their results can't tell anyone anything about our logical qubit. The only way for an unwanted measurement to happen is if a load of measurements happen all at the same time, and do so on a loop that goes through the doughnut. That's unlikely, so we're mostly okay.

Combining the rules

We now have a set of rules for dealing with bit flips, and a set for dealing with phase flips. But we really need them to work together, so we can deal with both at the same time.

Getting things to work together in quantum mechanics is not always possible. Suppose we have a single qubit, and set two rules:

i) When we measure whether it is 0 or 1, the answer must always come out 0.
ii) When we measure whether it is + or -, the answer must always come out +.

The only way to make a qubit always give us the result 0 for a 0/1 measurement, as rule (i) requires, is to have it in state 0. But this is a superposition of + and -. So it gives the result – half the time when we do a +/- measurement, breaking rule (ii). Similarly, the + state is the only one that always obeys rule (ii), but it breaks (i) half the time.

If the same was true for the rules for the squares, we would get loads of broken rules all the time. It would be impossible to get enough information to detect and correct the errors, because of all the random nonsense that comes from the rules fighting each other.

But there is a big difference between rules (i) and (ii), and the rules we use in the toric code. There is not just one state that satisfies the rules for the white squares, but there are many patterns of 0s and 1s that do it. And any superposition of these will obey them too. There are also many patterns of +'s and -'s that obey the blue square rules, as do their superpositions. With more possibilities, there is hope.

Any state can be thought of either in terms of 0s and 1s or in terms of +'s and -'s. Just like a single qubit in state 0 can be thought of as just a 0, or as a superposition of + and -. So it could be that some superposition of white rule abiding 0s and 1s turns out to be the same state as some superposition of blue rule abiding +'s and -'s. If so, states like this would obey both the rules for white squares and blue squares at once.

Fortunately, it turns out that there are states like this. They are not just nice simple patterns of +'s and -'s as in the figure above, or nice simple patterns of 0s and 1s as in the figures for previous posts. We need a big superposition to make sure that the rules can work well together. In fact, for a logical 0 we need a superposition of every possible set of 0s and 1s that could be used for a logical 0. Making such a complicated set of correlated qubits is going to be quite hard, and is the main reason that you can't buy a toric code from the shops at the moment. But experimentalists are working hard towards this goal..

With both sets of rules working well together, we just need to keeping checking on both types of square. When we see white rules broken, we know that a bit flip has happened, and can correct it. When blue rules are broken, we detect and correct phase flips. As long as unlikely things don't happen, or logical qubit will keep nice and safe.

Phase flips and +/- measurements

So far we've assumed that the only kind of bad things that happen are bit flips and unwanted measurements of 0 and 1. But what about phase flips, or unwanted measurements of + and -? Our code naturally sorts those out too. What about other crazy weird quantum stuff? It turns out that anything that could ever happen can be thought of as some combination of bit and phase flips. So whatever happens, once we measure what rules are being obeyed, the noise gets forced to decide what kind of bit and phase flips it wants to be. The we detect and correct those, and all is well. The toric code (as well as other quantum error correcting codes) protects us from everything.


Well, perhaps it doesn't protect is from everything: big and horrible errors that hit us all at once can still get under the radar. But as long as they are rare, our logical qubit will last a long time. And if they are not rare enough, we just make our code bigger so they need to be ever bigger and more horrible before they can mess us up.

So that's the toric code in 5 parts. Next we will move on to its flat brother, the planar code. But first, in this post we take a look at some of the maths behind all this. I try to keep it with little maths as possible, but it did turn out to be a bit long. There is a bit of teleportation in there, though.