Coding for quantum computers

Tech/IT

I recently read about the latest advancements in quantum computing made my Google with the 105 qubit chip Willow, achieving exponential suppression of errors. I note that quantum computer related stocks have gained quite a lot in the past few months, despite commercial and practical use of quantum computers being 20-30 years from now. You can check out how a quantum computer looks like and works in this short video or this longer one.

I am 41 years old now, will I even be alive to use and code with quantum computers? I hope so. During my research into the subject of quantum computers, I realized things wont change much in terms of coding. As this Quera glossary page explains, “Quantum computer coding, in fact, uses classical programming languages and looks like classical computer programming, so the fundamental difference between the two is what happens at compilation and execution times.”.

I will in this article try to share the results of my research into the subject of quantum computers and quantum coding, and leave links to interesting articles in which you can dig deeper. Its been an interesting ride, and my vocabulary has been broadened with words such as Dirac and CNOT.

Lets get started – the introduction

There is a large layer of abstractions between the human-language-like programming languages for regular computers too. On the lowest level, currents go through transistors, data stored as bits with values being either 1:s or 0:s (true or false), and using a set of operators (e.g. and, or). With quantum computers, you are dealing with probabilities, entanglements and qubits (short for quantum bit) dealing with superposition and qubits storing two states at the same time (e.g. both 0 and 1). When measured (an action that will change the state of the qubit, unlike bits), the value will still be either 1 or 0, but in during the computation you will get different probabilities of what the value can be; this article from the American Scientist explains it quite well.  

Image: the state of a qubit.

Regular computers have quit low error rates, while the opposite currently being true for quantum computers – one of the main reasons for quantum computers not yet yielding any practical or commercial use. The strength of quantum computers is the speed with which they solve certain types of problems which are quite important to the med tech/life science and security industries (e.g. Shor’s Algorithm). An estimate is that in 10-15 years RSA encryption will be breakable using quantum decryption, and that we should aim at replacing these in 0-5 years.

Quantum coding

How do you code for computers that work with quantum mechanics? For me who got quite a bad grade from that part of physics (I think it was a D? I should check with KTH) the bad news is I need to revisit my old physics books as quantum computing and coding is based on, well, quantum mechanics and physics. The good news is that knowledge of vectors, matrices and corresponding calculations (e.g. tensor product) is a great start which I do better in, and that you can use current programming languages you know (e.g. Python) with open source SDK:s (code libraries) to simulate quantum calculations to be used with Quantum Computers.  New languages have been created that deal solely with coding for qubits (e.g. functional ones like Quipper or imperative ones like QCL, and the adapted ones created by Google and Microsoft).

Quantum Computers are currently way over most people’s budget (well, unless you can settle for say an NMR based one with only 3 qubits, e.g. £17 200 for a “Triangulum Mini”) so I will settle for running simulations on my “old school” computer; there are cloud sources that give you access to quantum comps on the cloud, but the cost is ca 95 USD per minute. I decided to start off my quantum coding journey using the open source SKD from IBM for Python, Qiskit.

Image: Python code using the Qiskit and Qiskit Aer libraries. The code creates and measures a Bell state – copied and adapted from www.qiskit.org.

I hope to be able to update this article with my experiences of coding using Qiskit, listing challenges and findings along the way.

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *