Thursday, 30 June 2016

13 - The Planar Code

So far we've been looking at the toric code which, as the name suggests, needs to be wrapped around in a doughnut shape. This isn't really the most practical thing in the world. So how about something that can be done on an ordinary flat surface. Something like the following, perhaps?
As before, the little white squares are qubits. For each big white square there is a rule that all the qubits must obey. Usually they have four qubits around them, but the ones on the edges only have three and the ones at the corners have just two. The blue squares also have a rule that their qubits must follow. All of those have four qubits around them. When the rules are broken on any square, we can think of it as a particle: an anyon.

The whole point of a quantum code is to store a qubit, and to protect it from bit flips and unwanted measurements. For the toric code, this was done with big loops around the doughnut. But there are no loops like that any more. We'll have to work out a different way.

One thing we can do is to take the big white square at the top left, and stop enforcing its rule. We'll also do the same for the big white square at the bottom right. Now these squares are allowed to both have an anyon in, or both not (because these anyons always come in pairs). They could also have some superposition of the two.

These squares can now be used to store our qubit. We can have them both empty for a qubit that is 0, and both with anyons for a qubit 1. This is then nicely protected against logical bit flips, as a line of bit flips would have to stretch from top left to bottom right to do any harm.

Unfortunately, the qubit won't be protected from unwanted measurements. To see if there is an anyone on the top left square, you only need to look at two qubits. The same is true for the bottom right. So it's quite easy to measure our logical qubit.

To make it harder, let's knock down the wall between the top left square and its neighbour. We'll also do the same at the borrom left. Specifically, let's look at the code below.
This has a 'double square' at the top left, which is just two of the old squares stuck together. Otherwise it is exactly like a normal square. A rule can be set for the three qubits around it, and an anyon can live there. The same is true for the bottom left. Now the Gremlins need to measure three qubits to destroy our superpositions. So it's a bit harder than before.

To protect the qubit from unwanted measurements even more, we can just carry on knocking walls down. Now we have a big multisquare at the top and bottom. Both can hold an anyon, but they will be smeared across the whole edge, and so need lots of measurements to work out which you have. Now we have a good way of storing a logical qubit, this finally deserves the 'code' part of the name 'planar code'. 
Now that's basically it. You could check out what is happening from the perspective of the other kind of anyons, the ones living on the blue squares, but I'll leave that as an exercise to the reader.

Thursday, 23 June 2016

12 - Swapping Toric Code Anyons

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

Last time we showed that broken rules in the toric code behave like particles. The white squares have one type of particle, that are created, moved around and annihilated using bit flips. The blue squares have a different type of particle, which are manipulated by phase flips instead.

Since then, we also published an article about anyons. These are strange particles that do strange things when they dance around each. Anyons are impossible in our 3D universe. But the surface code is a 2D universe of particles. Could they behave as anyons? It turns out that they do!

In the following picture, some of the qubits are given different colours. One is half blue. Doing a bit flip here creates a couple of particles on the white squares either side. These are shown in orange, so I'll call them orange particles.

Another qubit  is light green. Doing a phase flip there creates the other kind of particle on the blue squares either side. These are shown in red, so I'll call them red particles.

What about the dark green qubits? Doing phase flips on these, one after the other, would move the top red particle in a loop around the rightmost orange particle. 

For example, if we first do a couple of them, we move the red particle two steps to the left.

The next one, which is on the same qubit as we did a bit flip earlier, moves it up past the orange particle.
The rest then take it back to where it started.

In 3D universes, as we learned here, having a particle loop around another does absolutely nothing. But with particles living in 2D, interesting things can happen. Let's see what happens here.

Firstly, let's see what we mean by a loop that does nothing. Say you never did the bit flip, and never had any orange particles. Then all we'd have is a loop around nothing.
This is what boring looks like.

So let's compare the following two situations.
  1. First we do the blue bit flip, then the light green phase flip, then the dark green phase flips.
  2. First we do the light green phase flip, then the dark green phase flips, then the blue bit flip.
Both start with nothing and end with a pair of orange particles and a pair of red ones. Both had one of the red particles do a little loop. The difference is that the first case has a red particle doing the loop around an orange one The second has a boring loop that won't do anything, because the orange particles haven't been created yet.

If these two orders of doing things end up the same, we know that moving one of these particles around the other does nothing. If they are different, it does something. But which is it?

Most qubits have just one thing happen to them, and don't talk to any other qubits. So they don't really even know if their phase flip is happening before or after other stuff. They won't give us much insight.

The important qubit is the one where both a bit and phase flip happen. In the first case, the bit flip happens first. In the second, it happens after the phase flip.

To see if this makes a difference, we have to remember what bit and phase flips do.
  • Bit flips flip a 0 to a 1, and an 1 to a 0.
  • Phase flips flip a + to a -, and a - to a +
But what if you have a qubit that is 0 or 1, and do a phase flip to that? Understanding what happens here would take a wee bit of maths. The maths from this post in fact. But let's keep it simple. It turns out that it does nothing to 0, but turns 1 to -1.

What the flipping heck is -1? It's basically 1, but with a -. If you asked the qubit whether it was 0 or 1, it would still tell you that it's 1. But if you had superpositions, the - might do some stuff with the maths. Like turning a + to a -, for example.

Now, let's suppose that this qubit was initially 0 and do the flips according to order number 1. When we first do the bit flip, we get a 1. When we then do the phase flip, we get -1. But if did order number 2, doing the phase flip first, it would do nothing. Then when we did the bit flip we'd get a 1.

So when we do bit and phase flips to the same qubit, it does matter which order we do them in! The results differ by some weird mathsy -1! The same would happen whether the qubit started as a 1, or a +, or a -, or anything.

So there is a difference between an empty loop of a red particle, and one that goes round an orange one. Their dancing does things that are impossible for particles in our universe. They are anyons!

Thursday, 16 June 2016


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

Don't know what anyons are? I'm not surprised. Want to how we could build a quantum computer from them? Then read on!

Indistinguishable Particles

Every day we see objects that look identical. Two cans of coke roll off the same production line, as do two copies of the same magazine. They were created by the exact same process, which makes it pretty hard to see differences.

But there are differences. Lots of them. If you weigh them, you'll probably find a difference of a milligram or two. If you count the number of atoms, the difference will probably be more than the number of grains of sand on a beach. These are not easy differences to find, but they are there all the same.

This is not true for elementary particles, like electrons and photons. These are indistinguishable, in practice and in principle. T
hey are exactly the same, so much that it has been proposed that the universe actually only has one electron that zips forwards and backwards in time.

Swapping Particles

Suppose you and your friend each have a can of coke. Yours weighs 366.300 grams, and your friend's weighs 366.301 grams. Then you swap them. Now you have one weighing 366.301 grams and your friend has one weighing 366.300. The situation after the swap is different to the one before. Not by much, but different all the same.

Now suppose instead that you and your friend each have an electron in a box. Don't think too much about the boxes, though. They are just there for the story. It's the electrons that matter.

So you each have an electron. Then you swap them. Afterwards, you again each have an electron. Since electrons are identical, it is exactly the same situation as before you swapped. The laws of physics don't allow anyone to work out whether you did the swap or not by just looking at the electrons. Because they are identical.

What if someone comes along and shuffles the boxes, and gives you one back at random? Do you end up with the same electron, or a different one? The best answer you can give it that it is indeed one of these two possibilities. But which one? Even the laws of physics themselves neither know nor care!

Even if you watched the shuffling very carefully, you still can't be completely sure. Electrons are quantum things, and you can never know exactly where quantum things are. It's entirely possible that the electrons swapped boxes a few times just for fun. So even without the shuffling, the electron in your box is both the same one you had earlier, and a different one, at the same time.

This phenomenon of doing two contradictory things at once is not uncommon for quantum particles. It's called quantum superposition. But usually it only lasts until you look at the particle, and it has to decide which of the things to be. But since electrons are identical, you can look all you like and you'll never find out whether it is the same or different. So they will keep their muddled identities forever.

It's quite an odd thing that you can do something fairly big, like swapping a couple of particles, and yet the universe contains no trace that you did it. But when physics gives us odd things, we can often use it for stuff. So let's see what this property will do for us.

Swapping Superpositions

Electrons are quantum particles, so they can be in quantum superpositions. This allows them to be in two places at once, or do two things at the same time. We've said that the electrons must be identical, but there's no reason for their superpositions to be identical too.

So now say that your electron is in a superposition of being in your box and being at home. And your friend's electron is the same. Then you swap your boxes, without looking at whether the electrons are there or not.

If both boxes were empty, you swapped nothing with nothing. So nothing happened. If both had electrons, it's as if nothing happened too because they are identical. But if you had an electron and your friend didn't, after the swap he has it and you don't. That's definitely different! But what about the superpositions?

To make it easier to see the effect on the superposition alone, let's swap twice. Then everything ends up where it started, and the superpositions are the only things that could have changed.

Now we've got to start talking about how you do the swap. Suppose you both do the first swap by giving with your right hand, and taking with your left.

If you did the second swap by giving with your left hand, and taking with your right, you would be doing the exact opposite of the first swap. It would look exactly like you are going backwards in time, undoing the first swap. So the result of these two opposite swaps will have to be nothing. Everything you did, you undid.

Now suppose you do the second swap is exactly the same as the first: give with right and receive with left. To work out what happens after two swaps of the same type, we'll need some topology.


When you swap your boxes, you will probably intend to do it with a graceful and smooth movement. But, alas, our bodies let us down. No matter whether you are a ballerina or a drunkard, your movement will be at least a tiny bit wobbly.

This doesn't matter, though. A swap is a swap, wobbly or not. In more mathematical terms, it is only the topology of the swap that matters, not the exact details.

For example, suppose we had two particles that once were together, but then got separated, and then later came back together again. Their journey through space and time can be represented by the picture on the left, below. The two circles at the bottom are the particles together in the past. Those at the top are the particles together now, and the lines show how they drifted apart and then back together.

The next picture is the same thing, but slightly changed. The movement of the particles is a bit more wobbly. But hopefully you can agree that it tells the same basic story. The next picture is a slightly changed version of the second, and so on. Each picture is slightly different than the one before.

The last one is quite different looking that the first. At some point in this one, the particles swap round. But then they unswap a bit later. So again, it's still the same basic story with no swapping really happening. Because of this, we say that these shapes are all 'topologically equivalent'.

Now consider the two pictures below instead.

These tell a very different story to the one before. They both have a single swap. They also tell a very different story to each other, since the swaps go the opposite way.

There is no way, through lots of small changes, to turn one of these pictures into the other. There is no way to turn them into the pictures above with no swaps. Because of this, we say that they are all topologically distinct from each other.

So topologically equivalent trajectories of particles through space time (you probably didn't think you'd be reading that phrase today!) tell the same basic story of what kind of swaps happened. And topologically distinct trajectories have different kinds of swaps.

But what does this tell us about our problem? What happens when we do two swaps?

In this picture we start off with two swaps on the left, and then by little changes we end up with something quite different on the right. One of the particles does nothing. It just sits there. The other one does all the work, rotating all the way around the lazy particle until it ends up back where it started.

So two particles swapping twice is the same as one particle looping around the other. Does this help us understand the process?

Let's imagine that, instead of the two swaps, our friend walks in a big circle around us. Topologically it's equivalent, so the effects on our superpostions will be the same.

Perhaps he finds that walk a bit boring after a while, so digs a hole and tunnels along for a bit. This is just a small change, so it's fine. It's topologically equivalent.

A small change to this would be to have him tunnel a bit longer, and then longer still until he digs down straight away and does the whole circle underground. Again, just small changes. So still topologically equivalent to the original loop.

A small change to this would be to make the loop a little smaller. Then smaller still until he's not even going around you any more.

In the end, this tells us that a particle going in a circle around another is in fact equivalent to the particle going in a circle that isn't around the other. This doesn't even involve both particles! There's no swapping going on at all! 

He can then make his circle so small that it doesn't really even exist. Then neither particle is doing anything! A particle going in a circle around another turns out to be equivalent to nothing at all! So two swaps can't have an effect on our superpositions.

Now you are maybe annoyed that I am wasting so much of your life telling you about things that don't do anything. But don't worry. Something more interesting is coming.

The circle our friend makes around us is only equivalent to nothing because he could dig down. Or fly up with his jetpack. He can do this because we live in a universe with three spatial dimensions. This up/down motion is something he is allowed to do, as well as the forwards/backwards and left/right that's needed to make the circle.

But suppose we lived in a 2D universe. Then he would only be allowed to move forwards, backwards, left and right. Tunnelling is no longer possible.

He could still change the circle by making it smaller. But at some point, the circle won't be big enough to go round us any more. He'll get stuck, and won't be able to finish the circle. This is not topologically equivalent to a circle. And since this is not an allowed path for him to take, he can't go on to change it a little to make the circle smaller again. He can no longer make the circle so small that it doesn't go around us. In a 2D universe, two swaps are not equivalent to nothing. They are something. They can change our superpositions.

Bosons and Fermions

We've seen that two swaps do nothing. What about one just swap? One possibility is that one swap also does nothing to the superposition. It just moves the particles around. That is, of course, perfectly consistent with the restriction that two swaps should do nothing too.

Another possibility is that one swap will multiply some mathsy stuff in the superposition by -1. Then when it multiples by -1 again on the second swap, you end up multiplying by (-1)x(-1)=1. Multiplying things by 1 doesn't tend to do much, which is why these two swaps would also be the same as doing nothing.

These are the only two possibilities in a 3D universe. Particles have to behave in one or the other of these ways. Particles whose swaps do absolutely nothing are called bosons. Photons, the particles of light, behave like this. So do Higgs bosons, obviously.

The particles that get some -1's in their superpositions are called fermions. Electrons, protons and neutrons are all fermions.

If we lived in a 2D universe, though, maths would not be so strict. We could get almost any kind of crazy stuff happen when we swap particles. Particles that behave like this, we call anyons.

Combining Particles

Suppose we have two particles in our box, rather than just the one. We can think of this as a single 'composite particle'. This will also be indistinguishable from other similar composite particles. So how will these behave when swapped?

If the composite particles are just made up of bosons, swapping just does a whole lot of nothing. So the composites are also bosons. If each composite particle is made up of two fermions, you get some -1's. But these always end up doing the (-1)x(-1)=1 trick with each other, even for a single swap. So you again end up with nothing. This means that the composite of two fermions also turns out to be a boson.

If each composite is made of one fermion and one boson, the bosons do their usual nothing when swapped. Only the fermions contribute, and they contribute their normal fermionic stuff. The composite of a fermion and a boson is therefore a fermion.

This is as fun as the rules get in our boring 3D universe. For some more exciting composites, we must enter Flatland, and take a look at anyons.

Abelian and Non-Abelian Anyons

To get some idea about composite anyons, why not have a play around with them yourself using our game, Decodoku.

The game comes in two flavours: 10 and Φ-Λ. These are examples of the two flavours of anyonic universes that are possible: Abelian and non-Abelian.

Abelian anyons are only a tiny bit stranger than bosons and fermions. There are a set of rules for what kind of particle your composite will be, given the particles that you combine. In 10 there are nine possible kinds of anyon (or 10 if you count nothing as a thing). These are represented by the numbers from 1 to 9. When you combine two anyons, you add up the numbers and remove any multiples of 10. This then tells you what your composite is. Combine a 2 with a 4, for example, and your composite is a 6. Combine a 5 with a 9, and your composite is a 4. If you combine a 3 with a 7, and then remove the resulting 10, the composite ends up as nothing. These particles have annihilated to the vacuum, which is the most bosonic kind of boson there is.

Non-Abelian anyons are a lot stranger. For these, you don't know exactly how a composite will behave. You just know what the possibilities are. When combining two Φ anyons in the Φ-Λ game, they could annihilate, they could give you a type of boson called Λ, or they could behave as a single Φ. You won't know which, until you try.

Well, maybe not. As the tutorial for the game will tell you. These anyons are really just the 10 ones all over again. A
 Φ is a number other than 5, you just aren't told which. So if you cracked open a couple of Φ's to see the number hiding within, you'd be able to work out what they would combine to.

But this is because the Φ-Λ particles in our game are just a simulation of anyons. They act in the same way as anyons as long as you follow the rules, and cracking them open is against the rules.

For real non-Abelian anyons, cracking them open just isn't possible. So you can examine two real Φ's as much as you like. They will give you no clues at all about how their composite would work. That information doesn't live on either particle. It lives somehow in the ether around them. A magical cloud of knowledge which no mortal may access.

Putting Anyons to Work

The Φ-Λ anyons are easy to simulate, but they are also quite boring. So let's think of a different kind of anyon instead. We'll use the so-called Fibonacci anyons. When you make a composite of two of these, they will either annihilate each other, or become a single Fibonacci anyon.

Suppose we have a pair of these which appear out of the vacuum. If we combine them, they will annihilate and turn back into the vacuum again. Ashes to ashes, dust to dust. It is also possible to take a Fibonacci anyon and break it into two
Fibonacci anyons, both identical to the original. If we combine them again, they'll always turn back into the original one.

Given this, we could use the anyons to store information. In normal computers we store information using bits, which are either 0 or 1. So to store a 0 we could make a pair of Fibonacci anyons that will annihilate when combined. And to store a 1 we could make a pair that will become a single Fibonacci anyon when combined.

Let's store two bits like this, as in the (very simple) picture below. We have four anyons in a line. The two on the left store one bit. The two on the right store another.

We can remind ourself what the first bit is, by combing the two anyons on the left and seeing if they disappear or not. Combining those on the right, we find out what the second one is. What if we combine the middle two instead? These have never seen each other before. They don't know what to do when combined. In fact, they are in a quantum superposition of the two possibilities: annihilation or becoming a single anyon.

A superposition! This is something that can be changed by doing swaps. And swapping them isn't something made boring by topology, because they are anyons: they live in 2D. So could swaps do something to our bits?

Suppose both our bits are 0. So both the left pair and right pair are certain to annihilate when combined. But before combining the pairs, let's first swap the middle two. Now the left pair are two anyons that never saw each other before. And the same for the right. When they are combined, the result will be random. It is no longer certain to be annihilation.

Because the Fibonacci anyons are indistinguishable particles, the swap just turns four anyons on a line to four anyons on a line. The superposition is the only thing that can change. 
So swapping these anyons does indeed change the superposition, and that change affects our bits.

Even so, this change is not a very impressive one. It just seems to be a strange quantum way of keeping track of how the anyons of moved, and which ones know each other. So what happens if we do another swap, putting the anyons back to their original places? The two on the left are again the two that once emerged together from the vacuum. But now, when combining them, the maths tells us that they won't always go back to the vacuum. The outcome will be random! The effect of swapping goes beyond just keeping track of how things move around. It does weird quantum stuff too!

Now we can start to have some real fun (if you think that building computers out of particles too exotic for our universe is fun, at least). Let's take the whole left pair, and swap it with the whole right pair, and then do the same swap again. Equivalently, we could take the left pair in a circle around the right pair.

By doing this, we are swapping the composite particles. If the left pair is storing a 0 bit, its composite behaves as if it has already annihilated. So we are effectively just moving nothing in a circle. Unsuprisingly, nothing happens. If the right pair is a 0 bit, then the left pair is moving in a circle around nothing. So nothing happens again. The only time that something will happen is if both bits are 1. Then we are taking a Fibonacci anyon around a Fibonacci anyon, and weird quantum stuff happens!

This has similarities to something called an AND gate, which is used in normal computers and can be built from a couple of transistors. This takes two bits, and tells you whether they are both 1 (by giving you an output of 1) or not (by giving you a 0). Two swaps of the Fibonacci anyon pairs similarly does something if both bits are 1, and nothing if not.

Transistors in our computers give us many ways of doing tiny little computations with a couple of bits, just like the AND gate above. The computer then breaks down every problem into lots of these little jobs and uses the transistors to solve them.

As we see here, swapping Fibonacci anyons also lets us do tiny little jobs on bits. Some of these are kind of similar to the ones transistors can so. But others are completely different. So now we could build a computer that breaks any problem down into lots of swapping anyons.

This would give us a whole new way to do computation. And because the little jobs done by anyons are different to the ones done by transistors, it might turn out that we need to use much, much fewer anyonic swaps to solve a problem than we would need to use transistors. A problem that might take the age of the universe for even a supercomputer to solve, could maybe be done during your tea break by anyons.

It turns out that this is actually true. Such an anyonic computer would be an example of a quantum computer: An awesome new architecture for computation, that we scientists are currently trying to bring to life.

Anyons in the Real World

There's one obvious problem with building an anyonic quantum computer: We don't have any anyons. They are not allowed in our boring 3D universe.

Fortunately, there is a way around this. Our universe can have 2D things inside it. So maybe we can build a 2D universe in the lab!

It sounds like sci-fi, but it's possible. In some materials you can get excitations, little clumps of energy, that behave just like particles. If you have a 2D material, so that these fake particles can only move in two directions, it can turn out that they can behave as anyons. For example, I do it with dice in this video.

Getting a material that will give us non-Abelian anyons like Fibonacci anyons will not be easy. But finding Abelian anyons will likely be much easier. These are not so fun, but there are ways to tempt them into becoming useful for quantum computation too. One way of getting Abelian anyons is through the so-called surface codes, which are what our game and puzzle are based on. We have a whole series of blog posts about these codes, and their relation to the quantum error correction needed to keep quantum computers clean. You can start reading through it here.

So now it's our job to build one of these things. If you want to help us, you can! That's what this project is all about. See here for more details.