# Here’s How to **Test** Error Correction on an IBM Quantum Computer

We now live in a world with quantum computers. Many are on the cloud and ready to use, requiring little more than an internet connection. But what can we do with them?

First, we need to be realistic with our scope. No world crisis will be solved with a current quantum computer. No fortunes will be made. When thinking of these current devices as a computer, you have to think of them as pretty bad computers. The limited number of qubits means that they can’t do much, and the effect of errors means they can’t do even that very well.

Instead, we can think of these devices as pieces of experimental physics equipment that we can run tests on. From that perspective, their size and precision is very impressive. Never have we had such control over such a large quantum system. They represent the frontier of what we have been able to probe experimentally. With them, we have an opportunity to test whether quantum theory continues to hold in this unexplored territory.

It was in 2016 that IBM handed this opportunity over to the world. At that time, I worked at the University of Basel and primarily did research on quantum error correction — ensuring that we don’t lose quantum information to the effects of noise and quantum decoherence. So I started to probe this particular corner of quantum theory: if we implement elements of quantum error correction on real devices, do they behave as we would expect them to?

I wrote some papers with those results. These are now among the more than 200 papers that have been written by scientists around the world who have performed experiments on IBM’s quantum devices.

Using prototype quantum computers for science is obviously something that is easier when you are a professional scientist. However, given the right resources and tools, this is something that everyone else can have a go at as well.

This was one of the main motivations for creating the `topological_codes`

module in Qiskit. The module has all of the basic tools you need to create experimental tests of quantum error correction. Specifically, it helps set up and analyze instances of the so called ‘repetition code,” the simplest example of something that uses the principles of quantum error correction to store information and protect it from errors. The repetition code uses multiple physical qubits to simulate a logical bit, rather than a logical qubit. To store a bit you simply repeat the desired value many times, to make it unlikely that that the majority of copies will get garbled by errors. It is simple enough that it can be run on current devices, and used to see how well the ideas of quantum error correction actually work.

To see it in action, you can read the relevant section of the Qiskit textbook. You can also now check out our paper, “Benchmarking near-term devices with quantum error correction” that has just been published in the journal *Quantum Science and Technology**.*

This paper aims to serve as an introduction to what quantum repetition codes are all about, and how to implement them with `topological_codes`

. It also shows an example of the software in use, by doing the largest test of quantum error correction performed so far: a repetition code with 43 qubits.

If you want to discover more about all this, just check out the paper. It has been written for a broad audience, and so it isn’t too full of technobabble. It’s also open access, so you needn’t worry about a paywall.

To give you a taste, let’s take a look at some results from the 53 qubit device called *Rochester*. Unfortunately, this specific device is not accessible to the public. But it is accessible to me, so I couldn’t resist the urge to put it to the test.

The main result was to look at how well repetition codes of different sizes can protect information. For this, we make repetition codes and use them to store a bit value ( `0`

or `1`

). Then we read out the bit value from the code. In a perfect world, we read out exactly what we put in. However, due to errors, sometimes this will go wrong. The probability of this is called the ‘logical error probability’, which we use as our main measure of how well the code is working.

The theory of quantum error correction tells us that making bigger codes should give us better protection against errors. In fact, we should find that the logical error probability decreases exponentially. Let’s see what actually happens.

Here the ‘code distance’ is a measure of how large the code is. So we do indeed see that the logical error probability decreases with code size, and does so in a way that is consistent with the exponential decay we expect. This is true whether we are doing the test by storing a bit value of `0`

(blue) or `1`

(orange).

In addition, we get to see some of the details of real devices that theorists like me sometimes forget about. The decay of logical error probability is not smooth, but instead rather bumpy. This is due to the fact that different qubits suffer errors of different types and different strengths. So if making our code bigger means using some dodgy qubits, things might not improve as much as we’d like.

Also we see that it is easier to store a `0`

than a `1`

. This is due to to the fact that we use a lot of qubits in the state |0 ⟩ to encode the `0`

, and a lot in state |1 ⟩ to encode a `1`

. The superconducting qubits we use prefer to be in the |0 ⟩ state rather than the |1 ⟩ state. So more errors cause a |1 ⟩ to flip to |0 ⟩ than vice-versa. The results we see are due to exactly this.

You don’t need 53 qubits to get insights like these. Repetition codes can be run just as well on 5 qubits or 15, which is what is available on the public devices. They can be used to test how well you can store a bit value if you use only the best qubits, or how much of an effect the errors will have if you use the worst. You could also add in extra noise using tricks like the ones below.

- The
`id`

gate makes the qubit pause for a moment and risk experiencing some stray interaction with its environment. - Doing any gate and then immediately undoing it gives you the errors associated with that gate (make sure to put a
`barrier`

in between so the compiler doesn’t just remove them).

You could even start thinking about new ways of decoding the results that come out, and contributing them to the `toplogical_codes`

module for other people to use.

In summary, by running repetition codes, you can start getting insights into how our devices work. You’ll be able to see the effects of errors and how error correction is able to deal with them. By comparing against simulations, you’ll be able to investigate whether these devices really can tamed in the way that we require to achieve fault-tolerant quantum computers.

Whether you are a high school student or someone doing a research project for their masters, you can do experimental tests of quantum physics from your own home. All the hardware and software you need is free and accessible through the IBM Quantum Experience.

So why not see what you can discover? And perhaps get to know a quantum device even better than the people who made it!