Coding for Qubits: How to Program in Quantum Computer Assembly Language

Sandia Labs pioneers Just Another Quantum Assembly Language ("Jaqal") on their QSCOUT platform

4 min read
QSCOUT’s ion trap uses an electromagnetic field to hold a chain of ytterbium-171 ions that function as qubits.
QSCOUT’s ion trap uses an electromagnetic field to hold a chain of ytterbium-171 ions that function as qubits. Launched in February with 3 qubits, the trap will be upgraded in 2021 to hold 10 qubits. Programs command lasers to shoot pulses of UV light at the ions to control their orientations and quantum states.
Image: Sandia National Laboratories

Quantum computing arguably isn’t quite full-fledged computing till there’s quantum software as well as hardware. One open-source quantum computer project at Sandia National Laboratories in Albuquerque, New Mexico aims to address this disparity with a custom-made assembly language for quantum computation. 

Over the next several years, physicist Susan Clark and her team at Sandia plan to use a $25 million, 5-year grant they won from the U.S. Department of Energy to run code provided by academic, commercial, and independent researchers around the world on their “QSCOUT” platform as they steadily upgrade it from 3 qubits today to as many as 32 qubits by 2023. 

QSCOUT stands for the Quantum Scientific Computing Open User Testbed and consists of ionized ytterbium atoms levitating inside a vacuum chamber. Flashes of ultraviolet laser light spin these atoms about, executing algorithms written in the team’s fledgling quantum assembly code—which they’ve named Just Another Quantum Assembly Language or JAQAL. (They’ve in fact trademarked the name as Jaqal with lowercase letters “aqal,” so all subsequent references will use that handle instead.) 

Although Google, IBM, and some other companies have built bigger quantum machines and produced their own programming languages, Clark says that QSCOUT offers some advantages to those keen to explore this frontier of computer science. Superconducting gates, like those in the Google and IBM machines, are certainly fast. But they’re also unstable, losing coherence (and data) in less than a second.

Thanks to ion-trapping technology similar to that developed by the company IonQ (which has published a nice explainer here), Clark says QSCOUT can maintain its computation’s coherence—think of it like a computational equivalent of retaining a train of thought—over as much as 10 seconds. “That’s the best out there,” Clark says. “But our gates are a little slower.” 

A vacuum chamber encloses the ion trap to protect the ultrasensitive ions from interactions with gas particles and from thermal and electromagnetic noise that might change their states, effectively crashing the quantum processor.A vacuum chamber encloses an ion trap that protects individual ions from sources of thermal and electromagnetic noise that might change their states, effectively crashing the quantum processor.Photo: Sandia National Laboratories

The real advantage of QSCOUT is not performance, however, but the ability it gives users to control as much or as little of the computer’s operation as they want to—even adding new or altered operations to the basic instruction set architecture of the machine. “QSCOUT is like a breadboard, while what companies are offering are like printed circuits,” says Andrew Landahl, who leads the QSCOUT software team.

“Our users are scientists who want to do controlled experiments. When they ask for two quantum gates to happen at the same time, they mean it,” he says. Commercial systems tend to optimize users’ programs to improve their performance. “But they don’t give you a lot of details of what’s going on under the hood,” Clark says. In these early days, when it is still so unclear how best to deal with major problems of noise, data persistence, and scalability, there’s a role for a quantum machine that just does what you tell it to do.

To deliver that combination of precision and flexibility, Landahl says, they created Jaqal, which includes commands to initialize the ions as qubits, rotate them individually or together into various states, entangle them into superpositions, and read out their end states as output data. (See “A ‘Hello World’ Program in Jaqal,” below.) 

The first line of any Jaqal program, e.g.

from qscout.v1.std usepulses *

loads a gate pulse file that defines the standard operations (“gates,” in the lingo of quantum computing). This scheme allows for easy extensibility. Landahl says that the next version will add new instructions to support more than 10 qubits and add new functions. Plus, he says, users can even write their own functions, too. 

One addition high on the wish list, Clark says, is a feature taken for granted in classical computing: the ability to do a partial measurement of a computation in progress and to then make adjustments based on the intermediate state. The interconnectedness of qubits makes such partial measurements tricky in the quantum realm, but experimentalists have shown it can be done.

Practical programs will intermix quantum and classical operations, so the QSCOUT team has also released on Github a Python package called JaqalPaq that provides a Jaqal emulator as well as commands to include Jaqal code as an object inside a larger Python program.

Most of the first five project proposals that Sandia accepted from an initial batch of 15 applicants will perform benchmarking of various kinds against other quantum computers. But, Clark says, “One of the teams [led by Phil Richerme at Indiana University, Bloomington] is solving a small quantum chemistry problem by finding the ground states of a particular molecule.”

She says she plans to invite a second round of proposals in March, after the team has upgraded the machine from 3 to 10 qubits.

A “Hello World” Program in Jaqal

One of the simplest non-trivial programs typically run on a new quantum computer, Landahl says, is code that entangles two qubits into one of the so-called Bell states, which are superpositions of the classical 0 and 1 binary states. The Jaqal documentation gives an example of a 15-line program that defines two textbook operations, executes those instructions to prepare a Bell state, and then reads out measurements of the two qubits’ resulting states. 

But as a trapped-ion computer, QSCOUT supports a nifty operation called a Mølmer–Sørensen gate that offers a shortcut. Exploiting that allows the 6-line program below to accomplish the same task—and to repeat it 1024 times:

register q[2]        // Define a 2-qubit register

loop 1024 {          // Sequential statements, repeated 1024x
    prepare_all     // Prepare each qubit in the |0⟩ state
    Sxx q[0] q[1]    // Perform the Mølmer–Sørensen gate
    measure_all     // Measure each qubit and output results

The Conversation (0)