# Quantum Firmware

By Will Zeng: Software & Applications @Rigetti Computing

Read this first: The Quantum Software Challenge.

This is the third of a series of posts on the software stack for quantum computing. This post describes the firmware layers. We focus on the problems that engineers need to solve to build I/O control firmware, error-correction control firmware, and the firmware compiler for quantum computing.

Looking for higher layers? You can read about them here.

# Layer -1: The metal

As we move up the software stack, we will progressively abstract away from the specific hardware implementation, but it is worth mentioning a few things about what lies beneath. There are two main approaches for building qubits:

- Take something that is inherently quantum and figure out how to control it.
- Take something you know how to control (and scale) and make it quantum.

The former approach applies to some hardware implementations [1], but at Rigetti we take the latter approach and build qubits out of superconducting non-linear resonators that are controlled with microwave pulses. They bear a lot of similarity to traditional semiconductor chips. You can read more about these kinds qubits with tutorials on quantum circuits here.

These superconducting qubits are a leading approach with the first hints of error-correction experiments demonstrated by IBM and Google earlier this year.

# Layer 0: I/O Control Firmware

Though this layer is closest to hardware, software control (sometimes embedded in hardware) coordinates the microwave pulses and control devices that actually operate the chips. This requires high accuracy and low-latency control as qubits have a finite lifetime due to decoherence. This layer is embedded software written in low-level languages like C, or directly on FPGAs using VHDL, Verilog, etc.

At present, test devices are manually calibrated with procedures developed by experimental physicists. The requirements of larger and more complex systems demand that this process become automated. This theme: encoding the years of scientific know-how developed in the academic community into software, will recur throughout the layers.

## Further reading — papers etc.

- S. Asaad et al.
*Independent, extensible control of same-frequency superconducting qubits by selective broadcasting.*2015. ArXiv:1508.06676. - D. Ristè and L. DiCarlo,
*Digital feedback in superconducting quantum circuits.*2015. - Lamb et al.
*An FPGA-based Instrumentation Platform for use at Deep Cryogenic Temperatures.*2015. ArXiv:1509.06809

# Layer 1: Error-correction control firmware

Once we have control of these more delicate physical qubits, we use the redundancy of error correcting codes to clump them into larger logical qubits. While the individual physical qubits may have short coherence times, the error-correcting codes group them into logical qubits that last much longer. Generally speaking, the larger the ratio of physical qubits to logical qubits, the longer the logical qubits will last. Some codes are good enough to make logical qubits that last arbitrarily long if that ratio continues to grow.

Here are three basic reasons why this is especially interesting (a.k.a. why we can’t just use the repetition code):

- You can’t perfectly copy quantum states, so creating redundancy of quantum information is subtle.
- There are more exotic sources of noise than simple bit flips.
- When you measure the physical qubits to check a majority vote, you change their quantum state.

To solve these problems, rich approaches to quantum codes have been developed. One leading kind of code, called topological codes, uses physical qubits arrayed into a 2D lattice. The logical bit is then encoded in a topological degree of freedom of the lattice. Figure 2 diagrams how we keep track of errors that develop in a 2D qubit array.

Error syndrome extraction occurs by making parity checks of qubits at the vertices of the faces of the lattice.

There are many software challenges to implementing these codes:

- Not only do we need to coordinate complex control schemes using the control layer, but we must write fast and accurate optimization algorithms to decode error syndromes into error corrections. These algorithms keep track of errors as they accumulate throughout a computation and decide on the most efficient method of correcting them.
- Additionally, encoded memory bits are not enough. We need to manage the operation of logical gates on our encoded qubits. This can be fairly involved, as in the surface code where one braids lattice defects (parts of the error correcting code that are switched off) around each other to perform controlled-not gates.

It is worth noting that although this layer is composed of purely classical code that solves classical syndrome decoding problems, the requirements on computing resources are significant relative to the speed of the response required.

## Further reading

Gottesman’s thesis: “Stabilizer Codes and Quantum Error Correction.” 1997. http://xxx.lanl.gov/abs/quant-ph/9705052

Fowler et al. *Surface codes: Towards practical large-scale quantum computation.* 2012. ArXiv:1208.0928

Córcoles, A. D., et al. “Demonstration of a quantum error detection code using a square lattice of four superconducting qubits.” *Nature communications* 6 (2015). Kelly, J., et al. “State preservation by repetitive error detection in a superconducting quantum circuit.” *Nature* 519.7541 (2015): 66–69.

# Layer 2: Firmware compiler

The system must turn commands for logical qubits into error corrected physical gates that can be implemented through the control layer. Lots of optimization can happen at this level through symbolic manipulation of the quantum circuit, as we coordinate how encoded gates are performed by the hardware and apportion resources to error correct the most sensitive parts of a computation. The efficiency of this layer can change the power of a quantum processor by orders of magnitude.

This is also the interface between the hardware sensitive firmware below and the hardware agnostic software above. As current quantum chips are relatively small, hardware specific optimizations will be necessary and will always be tempting. The appropriate level of software abstraction to enable underlying optimization as well as appropriate modularity is the key balance that must be struck.

## Further reading:

Paler et al. A compiler for fault-tolerant high level quantum circuits

# Where to go from here.

## All of this is just scratching the surface. These problems are real. They are here today, and of the relatively few people who have been trying to solve them, fewer still are software engineers.

We need more software engineers looking at these challenges. Difficulties are just things to overcome, after all.

Building this stack is a chance to impact an entire technology (and entire new industry) at the embryonic stage. There do not yet exist large quantum code bases.

Right now, we have a chance to learn as much as possible from the history of classical software development and to devise architectures that will be used for decades, like C. They will need to be elegant and creative solutions and will need to leverage the very best of applied and theoretical computer science.

# At Rigetti Computing our team is building the world’s most powerful computer. If you’re ready to be a part of this, let us know.

Footnotes:

[1] NMR, ion trap, and photonic implementations.