A beginner’s guide to quantum computer programming

Quantum computing takes a radically different approach to programming. IBM’s education head discusses how to get started

The field of quantum computation has made rapid progress just in the last few years. In 2016, IBM put the first quantum computer on the cloud, expanding the reach of the technology beyond research laboratories. Our goal is to make quantum computing available to anyone who is interested, and to help prepare a quantum-ready workforce that can translate industry challenges into problems that quantum computers can solve.

Industry has begun experimenting with quantum computers to help optimise transaction settlements, use machine learning to tease out new insights and accelerate scientific discoveries. For those and other projects to succeed, we will need a lot more quantum developers. Wondering if you, too, should get “quantum ready”? The short answer is: yes.

Just four and a half years ago, when I was a graduate school teaching assistant at Princeton University, I taught quantum computation using a whiteboard to roughly 20 students. Since IBM made cloud-based quantum computers available, instructors at Princeton – an IBM Q Network academic partner since 2019 – have been able to integrate hands-on experiences into its curriculum. Attendance in the course (ELE 396/COS 396) has grown to become one of the largest in the department.

Today, several universities around the world offer similar quantum computing courses, integrating cloud-based quantum computers in their pedagogy.

What you need to know about quantum computers

First, a bit about how quantum computers work. Quantum computing effectively harnesses the power of quantum mechanics for computing. Quantum bits, or qubits, are the basic units of information used by quantum computers, as opposed to the bits used by today’s classical digital computers.

While the bits in our classical computers can only take on values of 0 or 1, qubits can exist in combinations of 0 and 1. This property, known as superposition, means that individual qubits can take on states that are not available in classical computers like the laptop I used to type this article.

Multiple qubits can also become entangled. Given two entangled qubits, if I were to measure the state of one of them, then the outcome of measuring the other qubit is correlated in some way and isn’t completely random any more, even if the two qubits are far apart. Together, superposition and entanglement can be harnessed for quantum computation. 

Another concept that becomes important in writing quantum algorithms is interference. To have a clear picture of interference, think of a pair of sine waves. When the waves align, then the two signals add up, which means you get an enhanced signal. In the opposite case, when they don’t line up, you get destructive interference that diminishes the signal.

Several quantum algorithms begin by creating superpositions of an exponentially large number of logical states. These algorithms take advantage of interference in such a way that all the incorrect answers of the specific problem destructively interfere and no longer appear in the final output, leaving behind only the correct answer.

Putting quantum computing to work

It takes only one operation to go from a classical computing state that looks like either a 0 or a 1, to a superposition state, where the information can be in a combination of 0 and 1. Similarly, it takes only two operations to create entanglement between two qubits.

The IBM Quantum Experience provides access to IBM’s public 5-qubit, and 15-qubit systems. IBM provides a tool called Circuit Composer to write quantum programs by dragging and dropping gates individually on qubits.

Developers can also program using Qiskit, an open-source quantum programming platform that uses Python. If you already know Python, then you’re well on your way to take advantage of superposition, entanglement and interference in your quantum programs. 

For seasoned developers in industry looking to explore the potential applications of quantum computing, the Qiskit element Aqua (algorithms for quantum computing applications) offers a library of algorithms for artificial intelligence, chemistry, finance and optimisation. For example, there are a number of finance-related tutorials to experiment with credit risk analysis, fixed income pricing, basket option pricing, and others.

IBM and JP Morgan Chase scientists published research on testing potential future speedups to option pricing, versus current, classical Monte Carlo methods, using the amplitude estimation algorithm on Qiskit. 

Abraham Asfaw is quantum education lead at IBM Quantum

Read more about quantum computing

  • Google claims it has developed an algorithm for a quantum computer that would take a traditional “classical” computer 10,000 years to run.
  • Volkswagen Group recently demonstrated how it was working with D-Wave to research uses for quantum computing. We find out what the car maker is hoping to achieve.

Read more on Chips and processor hardware

CIO
Security
Networking
Data Center
Data Management
Close