# Compiling stabilizer circuits for quantum error correction

- Date
- Reading time
- 8 minute
- Author
- Brendan Reid, Senior Research Scientist

Achieving practical quantum computational advantage to solve complex, high-impact problems will require quantum error correction (QEC) to combat the proliferation of noise. There are significant hardware, software and scientific challenges to overcome before large-scale QEC becomes a reality, and this may take several years. The good news is that when the moment arrives, you will not need to be a QEC expert to use the machines. Entropica Labs, alongisde other companies and organisations, are working to ensure that the implementation complexities of error-corrected quantum computations are fully abstracted away from the end-user, making the devices as simple to use as existing classical compute technologies.

Much of the software complexity involves transforming and optimizing a high-level quantum program, which expresses the desired computation, to a low-level fault-tolerant executable that can be run on a target device. This transformation involves passing through different layers of abstraction, with different problems to be solved at each stage. In this blogpost, we discuss a method developed at Entropica Labs to tackle one of the simpler problems in this pipeline. Full technical details may be found in our paper, available on ArXiv here .

Most quantum error correction protocols are built from a set of instructions belonging to a particular class known as âCliffordâ operations, which include the familiar CNOT (CX), Hadamard, and phase gates. While these operations alone are not sufficient for universal quantum computation (a non-Clifford gate such as the $T$-gate is also required), they are the backbone of techniques to detect and correct errors in quantum computations. If a circuit contains only Clifford operations, together with single qubit reset and measurement operations, we refer to it as a *stabilizer circuit*. In this work we focus on the most widely used type of stabilizer circuit, namely syndrome extraction circuits.

Syndrome extraction is a âlogical thermometryâ that must be performed continuously during quantum error correction protocols, yielding information on errors that have occurred in the computation. However, its utility is not limited to the detection of errors. Within the leading proposal today for fault-tolerant computation – lattice surgery on the surface code – syndrome extraction also allows us to perform logical Clifford gate operations on encoded qubits. In other words, by constructing a suitable circuit containing physical-level Clifford gates, together with qubit measurements and resets, we can also execute logical-level Clifford operations such as the CX and Hadamard gates.

Despite the prominent role of the CX and Hadamard gates in quantum computing, typically neither of the two is a native physical operation on quantum hardware platforms. That is, they cannot be implemented directly, and must be decomposed (or âcompiledâ) into the native operations of the device. For instance, superconducting systems either employ a $CZ$ gate or the echoed cross-resonance interaction (ECR). Trapped ion systems employ a MĂ¸lmer-SĂ¸rensen interaction, which is a $\pi/2$ rotation around the joint $XX$ basis of two qubits. Any circuit containing $CX$ gates (as syndrome extraction circuits do) will need to be compiled into the native gateset of the hardware, and here we outline a new algorithm for this task.

We call this algorithm Tableaux Manipulation (TM), as we directly interrogate *stabilizer tableaux*, a data structure that completely defines stabilizer circuits. Our algorithm reduces the quantum gate overhead to implement this key class of circuits, and as such can improve the efficacy of logical operations in error-corrected quantum computing.

## How does it work?

Compiling a circuit expressed in one gateset to a circuit expressed in another gateset is typically a task that tracks matrices. We want to change the constituent gates in the circuit without modifying the unitary matrix that describes the circuit action. As a result, many compilation algorithms work with a âbottom-upâ approach: identify small, repeated structures within the circuit and compile them first, before reinserting into the appropriate places in the circuit. From there gate cancellations and optimisations can be done to improve the structure and remove any redundant operations.

When working with stabilizer circuits, this task is actually much simpler. If two stabilizer tableaux are equal, then the circuits that they represent have the same unitary action [1] . As our paper describes in full, we use this fact to build a new circuit from our desired gateset, and slowly modify it such that its tableau is equal to the desired one.

As mentioned above, a major difference between quantum hardware types is the two-qubit unitary employed for entangling operations. The goal of our algorithm is not to reduce the number of two-qubit gates, but instead to provide a more efficient and explicit method for circuit compilation into native operations. Our algorithm therefore aims to reduce the number of single-qubit gates, and, as we show, this can significantly improve the performance of QEC protocols.

## How does it perform?

As a baseline, we compare our algorithm to the Qiskit compiler functionality, arguably the most popular quantum abstraction software available. The circuits we will be comparing are syndrome extraction circuits for a distance-$d$ rotated surface code. For all code distances we consider this circuit is depth-6, where 4 layers of interlaced $CX$ gates are sandwiched by two layers of Hadamard gates. We compile these circuits into two different gatesets: one employing an $ECR$ interaction as its two-qubit gate, and another using a MĂ¸lmer-SĂ¸rensen interaction ($\sqrt{XX}$). For single qubit gates we permit the phase ($S$) gate and $\sqrt{X}$, the latter being $\pi/2$ rotation around the $X$ axis. These are common single qubit gates across all hardware modalities. Full simulation details can be found in our work.

For a gateset indicative of trapped ion hardware, in [Figure 1]
we are displaying the *gate count ratio* of circuits compiled with our TM technique to those compiled with Qiskit. For a given gate type, such as single-qubit rotations around the $Z$ axis, we calculate the total number in each compiled circuit and take the ratio.

In the left-hand plot we are showing the ratio of single-qubit gates in each circuit, divided into $X$-type rotations ($\sqrt{X}^{(\dagger)}$, $X$) and $Z$-type rotations ($S^{(\dagger)}$, $Z$)

We see that TM always introduces more $Z$-type single qubit gates than Qiskit, but significantly fewer $X$-type gates. In fact, for large distances we find a reduction of nearly $86\%$ for $X$-type gates.

In the right hand plot we show (in red) the ratio of all single qubit gates in each circuit, and the ratio of all gates (in navy). For all code distances, the TM technique succeeds in reducing the required number of quantum operations. Notably, at large distances, TM only introduces $58\%$ of the quantum operations that Qiskit does.

We show similar plots for a superconducting-qubit gateset in [Figure 2] . This time, TM introduces fewer gates than Qiskit for both single-qubit gate types. In the right-hand plot we again see that TM introduces fewer total quantum operations – only $76\%$ of those introduced by Qiskit for $d=17$.

We remind the reader that the circuits after compilation are *completely equivalent* and this is just a change of gateset – our algorithm simply does this with far fewer gates, and in a completely deterministic process.

## Final thoughts

This algorithm is straightforward and intuitive to use, and for a key class of stabilizer circuits (syndrome extraction) we can *always* reduce the gate overhead compared to compiling with Qiskit. There are no downsides to using this method for unitary stabilizer circuits. In our paper we highlight that for near-term devices this algorithm will always improve the performance of quantum memory experiments.

With all this said, the noisiest events on quantum hardware are typically measurement operations and two-qubit gates, and our TM algorithm cannot reduce the number of these. However, communicating operations to qubits in a dilution fridge will always incur a non-zero heat cost, and we argue that using this algorithm to achieve the same circuits in fewer quantum operations would always be advantageous.

*Left*: Ratio of single-qubit gates present in the circuit when compiling with Tableaux Manipulation versus Qiskit. Ratios are split into $X$-type (orange circles) and $Z$-type (blue triangles) single qubit gates.

*Right*: Ratio of the total gates (navy arrowheads) and total single-qubit gates (red squares) when compiling with Tableaux Manipulation versus Qiskit.

Using stabilizer tableau to represent circuits abstracts away a lot of extraneous detail, and the effect of adding or removing gates can be more easily seen. While here we are simply changing the gateset, stabilizer tableau can also be used for circuit *construction*, and indeed Ref. [2]
employs tableaux to train a reinforcement learning agent with the goal of quantum circuit discovery. We believe this is a promising line of research, with the potential to yield new insights and tools for fault-tolerant quantum computation.

## References

Scott Aaronson and Daniel Gottesman. Improved simulation of stabilizer circuits.

*Physical Review A*, 70(5), November 2004. ISSN 1094-1622. doi: 10.1103/physreva.70.052328. URL https://dx.doi.org/10.1103/PhysRevA.70.052328 .Remmy Zen, Jan Olle, Luis Colmenarez, Matteo Puviani, Markus MuĂźller, and Florian Marquardt. Quantum circuit discovery for fault-tolerant logical state preparation with reinforcement learning, 2024. URL https://arxiv.org/abs/2402.17761 .