How does a quantum computer work?

Actually, how does a conventional computer work?!

If you’re like me, you may have once known how your computer worked. But now, because for years I have only needed to know how to get it to do what I want, rather than understanding what is going on underneath, I’ve become vague on the details.

You can (apparently) program a quantum computer without really knowing what goes on underneath, but my first attempts at programming an experimental quantum computer were a little disappointing. I would have found it easier to remind myself of how a classical or conventional computer (like the one on my desk and in my phone) works first – and then learn a bit about quantum physics and quantum computers and then try to program one, first in a non-quantum way, and then using quantum phenomena.

So here’s what I’d have liked to have known first:

Conventional Computer:

It’s common knowledge that a computer uses bits – ones and zeros. But what are they and what does it do with them and how?

A bit is something with two distinct states – one we can label “1” and the other we can label “0” – such as a coin flip that will land either heads or tails. In electronics it is often a voltage of 0V or 5V, or simply on or off. A transistor is used as the on/off switch. It can be used to switch the bit from a one to a zero and vice versa. Inside a computer chip, it is not unusual to have over 5 billion transistors. Transistors are used as they do not have any moving parts – therefore they can be switched very fast and many times without breaking.

So, using a transistor, we can change a one into a zero. Which on its own isn’t going to help you hear a really entertaining podcast like this one.

Boolean Logic AND transistors can though. (BBC have a nice GCSE revision piece here). The Basic logic gates are AND, OR, XOR, NOT, NAND, NOR and XNOR. A more in-depth explanation of logic gates in electronics is available in this online book chapter “Introduction to Boolean Logic” by Kurt Wick.

Aside: For fun, Saar Drimer@Boldport sometimes draws logic gates as rockets:

Logic Gates as Rockets by Saar Drimer - Credit @Boldport

Logic Gates as Rockets by Saar Drimer – Credit @Boldport

Transistors can be used to make all of the basic logic gates. And the basic logic gates can be used to do stuff like add, subtract, multiply and divide – in fact every computation, video player, document editor etc. that we have or do on our computers is just an arrangement of these basic logic gates.

We can now make transistors so small, that to make them any smaller, would be getting in to the realms of quantum phenomenon. And then they will not work properly. So we will soon reach the limit to how many we can put on a chip, which will limit the speed and/or power of conventional computers.

Quantum Computers

I’d heard about quantum computers – how they are going to cure cancer, solve climate change and work out why it always takes three attempts to insert a USB drive correctly. I’d also heard they will be able to break the encryption that we use on all our banking and financial transactions – and that we’ll have to invent new methods to keep our money secure. But that’s not a big worry at the moment as quantum computers are really hard to make – in part due to interference which will stop it working. Depending on the type of quantum computer, this could be interference from electromagnetic energy, heat energy above -273 degrees C or even other atoms, ions or photons.

Quantum computers do different things than conventional computers. There will be things that conventional computers do best (faster, easier, etc.), and things that quantum computers will do best. It’s like having a hammer and a screwdriver in your toolbox. Probably best not to use one when the other is more suited. You could make a quantum computer do most things that a conventional computer does. But a quantum computer is less sturdy and has more restraints (like being kept very cold or in a vacuum), so why would you? Instead, quantum computers can use their magic quantum properties to do some things a lot quicker than conventional computers. Such as working out the optimum path for a cross stitch pattern that uses the least amount of thread (also known as the travelling salesman problem). Or for working out the route through a maze. Or for searching for things in a database.

What is “Quantum”?

Quantum (plural quanta) is the minimum amount of a thing (physical entity/ property) involved in an interaction. Examples of quantum particles include a photon and an electron. Quantum stuff is weird. Remember the double-slit experiment at school when light acted like a wave and a particle? That was a quantum effect. Quantum phenomena make things happen that we (scientists, humans, etc.) can’t explain. Einstein called one effect “spooky action at a distance.”

And because quantum stuff is weird, programming a quantum computer is also weird – you can’t just program it like a classical computer. Currently, there is no “ideal” way to program one. The current state of programming a quantum computer is a bit like classical computer programming before Grace Hopper had invented the first compiler.  However, Qiskit (a set of open-source Python libraries) is more than “good enough” to program today’s quantum computers.

IBM’s 50 qubit quantum computing system Credit: IBM

IBM’s 20 qubit quantum computing system Credit: IBM

IBM has made a state of the art quantum computer – it’s an experimental device and not a realisation of a theoretical quantum computer, so it can’t do all the things the theory says quantum computers can do, but it can do some quantum stuff. The term for this type of quantum computer is a NISQ (noisy intermediate-scale quantum) computer.

And even better (for me) – they let anyone have a play with it through the cloud – called the IBM Q Experience. Here are some more things I wish I’d known before I started trying to program it – and some of it I still don’t really understand …

Qubits: Quantum computer bits are called Qubits. They are made from tiny things, such as a photon of light or an electron or sometimes an atom. The one and zero may be their polarity (photon) or something quantum physicists refer to as spin, which is a made-up label, like dark energy or dark matter, and is used to describe what a qubit does, even though they don’t really know how or why it does it.

Superposition: Qubits are not just a one or a zero. They have the potential to be either. Or both. Or anything in between. Until you look at them. Then they will be one or the other. But it’s not just a 50/50 potential to be either. Sometimes they are more likely to be a one than a zero. Other times more likely to be a zero than a one. This is called superposition. (In my head I am treating this like science fiction. It doesn’t make any logical sense, but to let the story flow, I will accept it.) Superposition is sort of like a coin when it’s spinning. It can land one way or the other, but until it stops and lands, we don’t know which it will be. But once you know whether it is a one or a zero, it won’t go back into the superposition state, it will stay as a one or a zero. (until you do other magic science to it). So you can’t take a peek midway through your program or whatever you’re doing with the qubits – and no-one can eavesdrop on a message – as looking at it changes it. This is what Shroedinger was trying to explain with his theoretical cat.

Entanglement: Qubits can also get entangled with other qubits. They become linked in some sort of telepathic way (my description – not one the quantum physicists use). So knowing what state one is in, you can deduce the state of the other. However, how they are entangled will change how they are linked – if one is a zero, the other may be a one, or they may both be zero, or they may have their probability of being one or zero the same – or complementary, or something … (my brain fried at this point) This is what Einstein was referring to as “spooky action at a distance”.

Other Quantum Stuff: There’s other weirdness that happens when we get down to quantum levels. But, just like we don’t need to know how a transistor works for us to uses a conventional computer, It seems prudent for me to just ignore it.

Blogs and videos I found useful in trying to understand ‘Quantum Stuff’:

Excellent cartoon by Scott Aaronson and Zach Weinersmith “The Talk

Frame of Essence “Building the Bits and Qubits” Youtube video

Frame of Essence “You don’t know how Quantum Computers work!” Youtube Video

Quantum Computing Zero to Hero Part One by Gwilym Newton

Quantum Computing Zero to Hero Part Two by Gwilym Newton

Introduction to Quantum Circuits by IBM

Podcast Stupid Qubit – quantum computers for the clueless