search instagram arrow-down

Programming Quantum Computers

I have a (rather big) announcement to make! At the beginning of July this year I published an O’Reilly programming book with two fantastic co-authors: Eric Johnston and Nic Harrigan. All of us work on quantum computing, but we have different backgrounds and we wore slightly different hats: programmer, educator and academic, which made for many compromises and overall a balanced piece of work. We were extremely lucky to work with the team at O’Reilly who kept us grounded and on track, as well as a great set of technical reviewers.

Our intention with the book was simple: to provide a programmer’s guide to quantum computing, removing the veil of mysticism so that people can start tinkering around without needing a PhD in quantum physics first. After all, should semiconductor physics be a prerequisite to learn Python?

Book structure and content

  • Part I: Programming for a QPU, where we explain basic operations on qubits (single and two-qubit gates on single and multi-qubit systems) as well as the visual notation that we use throughout the book.
  • Part II: QPU Primitives, where we introduce the basic quantum primitives that allow us to get a computational speedup.
  • Part III: QPU Applications, where we explore more complex computational tasks that make use of the QPU primitives.
  • Part IV: Outlook, where we provide pointers to other resources on quantum computing and link our physics-free notation with the common notation and terminology in the quantum literature.

Speaking of notation, something that might surprise any quantum-savvy reader is that we have not used almost any mathematical notation, instead we have used a graphical notation to indicate the amplitude and phase of the quantum state, as in the figure below. In this notation, the amplitude of a state is correlated with the filled area of the circle, while the phase is marked by the needle. We call it the circle notation, for obvious reasons.

Circle notation

This notation is basically a pictorial depiction of the state vector, and its main advantage is that it allows the reader to start getting familiar with the action of the quantum operations through the visual representation. Each quantum operation can be described by the action it has on the circles representing the state. For example, see below the actions of the NOT (Pauli-X) and CNOT operations on a three quit register (top and bottom respectively). I found that visualizing operations this way helped me understand some quantum algorithms in a completely new way.

Action of NOT (Pauli-X) and CNOT on a three qubit register (top and bottom respectively).

One of the coolest aspects of this notation, is that it makes it very accessible to start thinking of graphics applications, we devote an entire chapter to this topic. This is in part III, where we cover the more advanced applications such as Shor’s factoring algorithm, quantum search applications (the square-root speedup of any NP problem) and quantum machine learning.

The companion in-browser simulator

One of the challenges of getting started in any new technology is the barrier that exist with installing the appropriate software and tools. To aid this transition we built a companion website for the book, with all the book samples ready to run on the browser, so no installation is required. If you get the Kindle version of the book, they will even run on the kindle’s experimental browser! The samples that run in the browser are written in the QCEngine language, which is the simple high-level JavaScript based language that we use throughout the book. We are currently adding all the book samples in other quantum computing languages, such as IBM’s Qiskit or Microsoft’s Q#, so that samples can also be run in their simulators or hardware.

One of the nicest features of the simulator is the ability to trace the evolution of quantum state as we progress through the operations in a particular algorithm. For example, the gif below shows an example of the original Grover algorithm, we can see how the marked phase differences (in the circle notation shown as needle of the circle, and also with colors) can be turned into amplitude differences (marked by the size of the colored area of the circle).

There are many more things I could say about the contents of the book, but I hope this quick intro is enough to peak your interest and give it a read!

Octopus?

O’Reilly books are famous for the animals on their cover and we were excited to find out which animal would appear the cover of our book, as the choice was entirely O’Reilly’s. The animal in the cover is a musky octopus and some have conjectured that the octopus was chosen because of their high intelligence in comparison with other sea creatures. While I can neither confirm nor deny the reasoning behind the choice, the animals are chosen because of “intriguing correspondences between specific animals and specific technologies”, as Edie Freedman (the woman behind the initiative) explains in a short history of the O’Reilly. I have since been amused by some octopus references on quantum computing events, such as this quantum computing hackathon at CERN . 🐙

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: