Getting to know your quantum processor

Dr James Wootton
Qiskit
Published in
8 min readNov 3, 2018

Quantum computers are built out of qubits. But just having lots of qubits is not enough.

A billion qubits working in complete isolation will never achieve anything. They need to talk to each other. This means that the need to be connected by so-called controlled operations. Every device has its own rules for which pairs of qubits can be connected in this way. The better the connectivity of a device, the faster and easier it will be for us to implement powerful quantum algorithms.

The nature of errors is also an important factor. In the near-term era of quantum computing, nothing will be quite perfect. So we need to know what kinds of errors will happen, how likely they are, and whether it is possible to mitigate their effects in the applications we care about.

These are the three most important aspects of a quantum device: qubit number, connectivity and noise level. To have any idea of what a quantum computer can do, you need to know them all.

So let’s make a game that runs on a quantum device and shows all these things directly. By just playing the game, the player will see exactly how big and connected the device is. By comparing a run on the real device with one on a simulator, they’ll see exactly how potent the noise is. Then by playing again with some error mitigation, they’ll get an idea of how much useful information can be salvaged even in the era of slightly noisy quantum computers. We’ll call this game Quantum Awesomeness, and we’ll play it on the IBM device known as ’ibmq_16_melbourne’.

The image above gives a quick guide to what’s going on in the Melbourne device. There are 14 qubits, numbered from 0 to 13, shown by coloured circles. The qubits that can talk to each other via a controlled operation are shown connected by lines, each of which has been given a letter for a name.

The most useful thing you can do with controlled operations is create and manipulate entanglement. Only with this can we explore the full space of possibilities that is open to our qubits, and hope to do things that are practically impossible for classical computers.

The simplest kind of entanglement involves just two qubits. It will cause each to yield outputs that are random, but with correlations between them. For example, consider following program on a couple of qubits.

This is a circuit diagram: a history of the qubits in our program told from left to right.

Here we perform an rx operation for the angle π/2, which results in what is essentially half an x gate. This is an example of what we called a ‘partial NOT’ in the Battleships with partial NOT gates game. Instead of flipping the qubit all the way from |0⟩ to |1⟩, it parks it in a quantum superposition state in-between.

The operation acting on both qubits is a controlled-NOT, which applies a NOT to the bottom qubit only when the top one is in state |1⟩. Since the top one is in a superposition of both possibilities, the effect of the controlled-NOT is to spread the superposition to the bottom qubit as well: a combined superposition of both |0⟩ and both |1⟩.

The final part of the circuit is to extract a simple bit from each qubit: |0⟩ becomes 0, |0⟩ becomes 1, and a superposition becomes a random choice of one or the other. But even though both qubits will give a random result in this case, they are sure to always agree.

To verify this, let’s run it. The result I got was,

{'11': 503, '00': 521}

Out of the 1024 samples that the program was run for, all results came out either `00` or `11`. And we have approximately equal numbers of samples for each. All as predicted.

By replacing the value of π/2 we can change the nature of the superposition. A lower value will produce results more biased to outputs of 0, and a value closer to π will result in a bias towards 1s. This means we can vary the probability with which each output will give a 1. But whatever value we choose, this form of circuit ensures that the results for the two qubits will always agree.

In this game we will make lots of these pairs of entangled qubits across the device. To do this, we must first choose a way to pair up the qubits monogamously (possibly leaving some spare ones left over). This pairing will be chosen randomly, and the whole point of the game is for the player to guess what the pairing was.

Once we have the random pairing, we’ll basically run the quantum program above on each independent pair. Though we will introduce one difference: for each pair we’ll randomly choose a different value for the rx operation, so the degree of randomness shared by paired qubits will differ from pair to pair.

When we run the circuit, the result will be a string of 14 bits: with each bit describing the output of each qubit. Since we run it for many samples to take statistics, the full result will be a list of all the bit strings that came out, along with the number of times that each occurred.

Since the aim of the game is for the player to deduce the pairing from the output, we could just dump all this data on them. But that probably wouldn’t be very fun. Instead, we can just focus on the important points:

  • What is the probability of each qubit giving an output of 1 instead of 0?
  • What is the probability that each pair of connected qubits give the same value?

We can then put that information on our image of the device. For example, here’s one particular set of runs.

The number displayed on each qubit is the percentage of samples for which the result was 1. The number on each connection is the percentage of samples for which the corresponding pair of qubits had outcomes that disagreed. With this information, we can easily find the pairs of qubits that were entangled: either by looking for the qubits that share the same probability of outputting a 1, or finding the pairs that never disagreed.

The above data was extracted from a simulator. Now let’s try it on the real quantum device.

Here the results are not so clear as for the simulator. The effects of noise are much stronger, making it much harder to identify the pairs.

But all is not lost! We can do some error mitigation. We know that the output should have a certain structure, so we can search for that structure and use it to clean up the result.

Here’s a very simplistic way to do that. First, each qubit will look at all its neighbours and see which one it agrees with most. It’ll then assume that this most agreeable qubit is its partner. To try and balance out the errors in its results, we’ll then replace the probability of getting an output of 1 for that qubit with the average from them both.

Though things have improved, they’ve not been made perfect by any means. This is because our error mitigation scheme is pretty simple, and is just bolted on at the end of the process. Error mitigation can have powerful effects, but it is most effective when built into the quantum program itself (something you could try to experiment with if yourself if you’d like to expand upon this project).

For now, let’s just play the game using these mitigated results.

Our job is to look at the numbers on the qubits, and try to find pairs that either have the same number, or at least have numbers that are close as possible. The two 48s on the left seem like a good start. So let’s go for pair A as one we think is entangled.

The two 46s of pair H are the same as each other, and also quite distinct from their neighbours. So we’ll go for that one too.

Then pair E seems pretty certain.

And pair C.

Now we’ve reached a point where noise makes it a little hard for us. Should the 42 be paired with the 55, or the 56? Since the 55 is closer in value, we’ll go for pair O.

Finally we are left with two qubits that must have been paired with nothing. That will always happen on this device due to the way its connectivity graph is structured. So we have reached the solution! But was it the correct one?

Let’s look again at the noiseless simulation, where the correct pairing was much easier to see.

The pairs that show perfect agreement here are exactly the ones we just chose. So we were indeed correct. We played a game on a quantum computer, and we won!

What next?

If you want to get started with quantum programming, why not take a look at the source code for this game, available on the Qiskit tutorial.

We’ve even collected a few ideas for ways you could extend it

  • Write an algorithm to play the game. This would guess the pairs as correct as possible by cleverly analyzing the analyse the data.
  • The puzzle is very easy to solve when there is no noise. You could introduce different difficulty levels.
  • The error mitigation used here is very simplistic. You could try to implement something more sophisticated, such as the ‘robust phase estimation’ described in this talk.
  • Could more complex entangled states, such as ones with three qubits, be used to ensure that no qubits on a device are left out of the fun?

Have fun, with this and our other quantum games!

--

--

Dr James Wootton
Qiskit

Helping to make quantum computers IBM Research . Occasionally misusing them for fun and/or science. Two Ts and no Es. All nonsense here is my own doing