Learning to Decode the Surface Code with a Recurrent, Transformer-Based
  Neural Network
Quantum error-correction is a prerequisite for reliable quantum computation.
Towards this goal, we present a recurrent, transformer-based neural network
which learns to decode the surface code, the leading quantum error-correction
code. Our decoder outperforms state-of-the-art algorithmic decoders on
real-world data from Google's Sycamore quantum processor for distance 3 and 5
surface codes. On distances up to 11, the decoder maintains its advantage on
simulated data with realistic noise including cross-talk, leakage, and analog
readout signals, and sustains its accuracy far beyond the 25 cycles it was
trained on. Our work illustrates the ability of machine learning to go beyond
human-designed algorithms by learning from data directly, highlighting machine
learning as a strong contender for decoding in quantum computers.
Johannes Bausch, Andrew W Senior, Francisco J H Heras, Thomas Edlich, Alex Davies, Michael Newman, Cody Jones, Kevin Satzinger, Murphy Yuezhen Niu, Sam Blackwell, George Holland, Dvir Kafri, Juan Atalaya, Craig Gidney, Demis Hassabis, Sergio Boixo, Hartmut Neven, Pushmeet Kohli
# Learning to Decode the Surface Code

###### Abstract

Quantum error-correction is a prerequisite for reliable quantum computation. Towards this goal, we present a recurrent, transformer-based neural network which learns to decode the surface code, the leading quantum error-correction code. Our decoder outperforms state-of-the-art algorithmic decoders on real-world data from Google's Sycamore quantum processor for distance 3 and 5 surface codes. On distances up to 11, the decoder maintains its advantage on simulated data with realistic noise including cross-talk, leakage, and analog readout signals, and sustains its accuracy far beyond the 25 cycles it was trained on. Our work illustrates the ability of machine learning to go beyond human-designed algorithms by learning from data directly, highlighting machine learning as a strong contender for decoding in quantum computers.
## 1 Quantum error correction

### Context and background

The idea that quantum computation has the potential for computational advantages over classical computation, both in terms of speed and resource consumption, dates all the way back to Feynman [26]. Beyond Shor's well-known prime factoring algorithm [83] and Grover's quadratic speedup for unstructured search [39], many potential applications in fields such as material science [59, 3, 4, 75], machine learning [8, 47, 46], and optimization [25, 86], have been proposed.

Yet, for practical quantum computation to become a reality, errors on the physical level of the device need to be corrected so that deep circuits can be run with high confidence in their result. Such fault-tolerant quantum computation can be achieved through redundancy introduced by grouping multiple physical qubits into one logical qubit [82, 52].

One of the most promising strategies for fault-tolerant computation is based on the surface code, which has the highest-known tolerance for errors of any codes with a 2D nearest-neighbor connectivity [15, 29, 53]. In the surface code, a logical qubit is formed by a \(d\times d\) grid of physical qubits, called _data qubits_, such that errors can be detected by periodically measuring \(X\) and \(Z\) stabilizer checks on groups of adjacent data qubits, using \(d^{2}-1\)_stabilizer qubits_ located among the data qubits (Fig. 1A). A _detection event_ occurs when two consecutive measurements of the same stabilizer give different parity outcomes. A pair of observables \(X_{L}\) and \(Z_{L}\), which commute with the stabilizers but anti-commute with each other, define the logical state of the surface code qubit. The minimum length of these observables is called the _code distance_, which represents the number of errors required to change the logical qubit without flipping a stabilizer check. In a square surface code, this is the side length \(d\) of the data qubit grid. The task of an error correction _decoder_ is to use the history of stabilizer measurements, the _error syndrome_, to apply a correction to the noisy logical measurement outcome in order to obtain the correct one.

However, decoding quantum codes is a hard problem. For instance, they exhibit _degeneracy_, whereby exponentially many configurations of errors may produce the same history of stabilizer measurements. They must also contend with rich noise models induced by quantum circuits that include _leakage_, qubit excitations beyond the computational states \(|0\rangle\) and \(|1\rangle\) that are long-lived and mobile [30]; and _crossstalk_, unwanted interactions between qubits inducing long-range and complicated patterns of detection events [93]. Degeneracy, circuit-level correlations, leakage, and the difficulty in modeling these errors produce decoding problems that resist many tried-and-true methods commonly utilized for classical codes [73, 70, 57, 43].
Despite significant progress on quantum error correction [100, 60, 37, 84, 88, 55, 23, 76, 104, 40], challenges remain. Ultimately, to perform fault-tolerant quantum computation such as the factorization of a \(2\,000\) bit number, the logical error rate needs to be reduced to less than \(10^{-10}\) per logical operation [29, 33]. Logical errors for the surface code are suppressed exponentially, \(\sim\Lambda^{-d/2}\), when increasing the code distance \(d\), where \(\Lambda\) is a 'quality factor' determined by the accuracy of the device and the performance of the decoder. This means that improving the inference accuracy of the decoder will reduce the required size or required gate fidelity of a quantum processor to run a quantum algorithm. Consequently, an accurate decoder is vital to realizing a fault-tolerant quantum computer using realistic noisy hardware and minimal resources. In addition, the decoder must be fast enough to keep up with the rate of syndrome information produced by the quantum computer, test it creates an exponentially increasing backlog of syndrome information to process [91].

### Quantum error correction with machine learning

In recent years, there has been an explosion of work applying machine-learning techniques to quantum computation, including decoding. Initial decoders used restricted Boltzmann machines [92], and many subsequent approaches use reinforcement learning [89, 27, 2, 62] or supervised learning [95, 61, 19, 22]. Several previous works have focused on the surface code, observing that machine-learning techniques could utilize correlations introduced by \(Y\)-type errors to outperform popular minimum-weight perfect matching (MWPM) decoding [54], and could even be used as a preprocessing step for graph-based decoders [64]. Other works have focused more on speed and scalability [68, 103, 66, 31], including the use of symmetries to improve performance [24, 99]. There have also been examples of machine-learning decoders applied to the fully fault-tolerant setting with more realistic noise models [20, 7, 56]. In particular, on distance-7 color codes, a recurrent neural network architecture has been used to demonstrate good performance over many error correction cycles [6]. However--unlike us--none of these works considered crosstalk or leakage.

More recently, [94] built on the architecture of [6], and assessed its performance on the Sycamore surface code experiment [37]. They trained their recurrent neural network-based decoder on a circuit-level depolarizing noise model (with noise parameters fitted to the experimental data) and evaluated on experimental data, demonstrating parity with the best previously-published decoder at code distance 3. Furthermore, the authors directly quantified the benefits of modelling correlations. They also explored the use of analog inputs (modelled by a symmetric Gaussian I/Q readout noise model), which allowed a slight increase in accuracy.
In this work, we push the boundary of both scale and accuracy of machine-learning decoding in the fault-tolerant setting of circuit-level noise. We present a novel recurrent architecture using transformers and convolutions, which learns to decode the surface code. We evaluate our machine-learning decoder on experimental data from a surface code logical qubit implemented on Google's Sycamore quantum computer [37], and observe markedly better error suppression than state-of-the-art correlated matching and tensor network decoders [37, 43, 14, 35] by training on data directly.

Furthermore, for larger code distances up to 11, we benchmark our ML decoder against a noise model which realistically simulates the effects of leakage, crosstalk, and analog readout as present in a real-world quantum device. The ML decoder outperforms state-of-the-art correlated matching decoders, and sustains its accuracy over at least 100 000 error correction cycles (when only trained on up to 25 cycles). Our recurrent transformer model achieves a further accuracy boost by being able to seamlessly incorporate raw measurement signals from the device (in the form of "in-phase and quadrature" readout signals [48]), and leakage information from the syndrome.

These capabilities, emerging from the ML decoder's ability to learn from raw data--as well as the decoder's provision of calibrated error probabilities--come without computational overhead. In short, our decoder expands the scope of fault-tolerant machine-learning decoders while offering better accuracy in realistic settings than the most competitive alternatives.

## 2 A recurrent syndrome transformer

### Model architecture

Our machine-learning decoder is a neural network with a structure designed to match the structure of the error correction problem, which learns to decode the surface code by training on experimental and simulated data. Its design mirrors the time-invariance of the stabilizer readout by repeated iteration of a fixed computational block (Fig. 1B). This _recurrent_ architecture constructs a fixed-size _decoder state_ representation which stores information about the stabilizers observed up to the current cycle.

Since the data received at each cycle correspond to individual stabilizers, our model maintains the decoder state as a vector representation _per stabilizer_. The model applies a neural network block (Fig. 1D) at each cycle to update the decoder state by incorporating the current cycle's stabilizers (Fig. 1C). While decoders like MWPM typically accept sparse binary _detection events_, a neural network allows for less restrictive inputs. We find better results and more stable training when providing both measurements and events, rather than events alone
(see materials and methods, Appendix B.4). In Section 2.3 we will show that these inputs can be extended further to include probabilistic representations of I/Q readouts and leakage information. Each stabilizer \(i\) at cycle \(n\) is represented by a stabilizer embedding vector \(S_{ni}\), created by combining the inputs in the network of Fig. 1C, and directly added in to the decoder state (Fig. 1D).

The key processing operation is the _Syndrome Transformer_ (Fig. 1E) which updates the decoder state by passing information between stabilizer representations in a learned, structured manner. The Syndrome Transformer augments the multi-headed attention of a conventional Transformer [97] with an _attention bias_ (Fig. S6) and spatial convolutions, each of which learn to modulate the information flow between stabilizer representations based on their physical relationship and type. At any stage in the computation, the decoder state can be processed by a readout network (Fig. 1F) to predict whether a logical error has occurred. In the readout network the decoder state is scattered to a 2D representation and projected to a per-data-qubit representation before pooling into a representation per-row or column of data qubits (representing logical \(X_{L}\) or \(Z_{L}\) observables, respectively), which a final residual network processes before predicting the probability of a logical error. We show the effectiveness of these architecture design decisions by ablation (Fig. S15).
Figure 1: **The neural network architecture designed for surface code decoding.****(A)**\(5\times 5\) rotated surface code layout, with data qubits (dark grey dots), \(X\) and \(Z\) stabilizer qubits (labelled light grey dots, or highlighted in blue/red when they detect a parity violation) interspersed in a checkerboard pattern. Logical observables \(Z_{\text{L}}\) and \(X_{\text{L}}\) are shown as bold lines on the left and bottom grid edges respectively. **(B)** The recurrent network iterates over time updating a representation of the decoder state and incorporating the new stabilizers at each cycle. **(C)** Creation of an embedding vector \(S_{ni}\) for each new stabilizer. **(D)** Each block of the recurrent network combines the decoder state and the stabilizers \(S_{n}\) for one cycle (scaled down by a factor of 0.7). The decoder state is updated through three Syndrome Transformer layers. **(E)** Each Syndrome Transformer layer updates the stabilizer representations through multi-headed attention modulated by a learned attention bias followed by a dense block and dilated 2D convolutions. **(F)** Logical errors are predicted from the final decoder state.
### Decoding the Sycamore memory experiment

As a first demonstration, we apply our ML decoder to the _Sycamore memory experiment dataset_, experimental data for surface code logical qubits on Google's Sycamore device [37]. The experiment comprised both distance 3 and 5 surface codes; the \(3\times 3\) code block executed at four separate locations (labelled _north_, _east_, _south_, _west_, 'NESW'), within the Sycamore chip, and the \(5\times 5\) code block executed at a single location. Both \(X\) and \(Z\) memory experiments were performed for up to 25 error correction cycles. Within each experiment, stabilizer syndromes were measured over each cycle, followed by a final cycle of data qubit measurements, from which a final set of stabilizers in the experiment basis as well as the logical readout were computed. \(50\,000\) experiments were performed for each total cycle count \(n\in\{1,3,\ldots,25\}\), and the resulting data split into _even_ and _odd_ subsets for 2-fold cross-validation.

Decoder performance is quantified by the _logical error per round_ (where round means the same as cycle, abbreviated LER), a measure of the fraction of experiments in which the decoder fails for each additional error correction cycle. As in [37], we calculate the LER by a linear regression of the log-fidelities for experiments of different numbers of cycles \(n\in\{3,5,\ldots,25\}\) (see materials and methods, Appendix A.2.1, Fig. 2A).

We trained our decoder in two stages: pre-training and fine-tuning. In the pre-training stage, and e.g. for the even fold, we train on \(2\times 10^{9}\) samples drawn from detector error noise models (DEMs, [32]) fitted to the even experimental detection event distributions, and choose the model with the best validation LER, computed on the even experimental samples. For the fine-tuning stage we randomly partition the even experimental samples, training on \(19\,880\) with weight decay relative to the pre-trained model to regularize the parameters. We choose the parameters giving the lowest LER on the remaining \(5\,120\) samples (after \(\approx 120\) passes through the data). This procedure allows us to train a decoder to high accuracy with limited access to experimental data, while holding back the other (odd) fold as test set. When the pre-training stage uses a more'standard' noise model such as circuit depolarizing noise, fine-tuning compensates for most of the mismatch (see materials and methods, Appendix B.5).

Our ML decoder achieves a lower LER (\(2.901\pm 0.023\%\) at distance 3, and \(2.748\pm 0.015\%\) at distance 5, for a \(\Lambda=1.056\pm 0.010\)) than the tensor network (TN) decoder (\(3.028\pm 0.023\%\) resp. \(2.915\pm 0.016\%\), \(\Lambda=1.039\pm 0.010\)), the most accurate decoder hitherto reported for this experiment [37, 14]. The accuracy gain becomes even more pronounced in comparison to state-of-the-art MWPM-based decoders, such as correlated matching (MWPM-Corr), matching with belief propagation (MWPM-BP), as well as PyMatching, an open-source implementation of MWPM [43, 37, 42] (Fig. 2A). Fine-tuning on experimental data, as well as _ensembling_ (training multiple models and combining their outputs, see materials and meth
ods, Appendix A.7) take our technique from parity with the TN decoder to a clear advantage (Fig. 2B).

Figure 2: **Accuracy of our machine-learning decoder and other leading decoders on the Sycamore experimental data.** All results are averaged across bases, even/odd cross-validation splits and, for the \(3\times 3\) experiments, the location (NESW). (**A**) Fidelity (\(2\times\text{accuracy}-1\)) vs. error correction cycle for code distance 3 and 5 memory experiments in the Sycamore experimental dataset for the baseline tensor network decoder (black), our decoder (blue) and three variants of MWPM (shades of gray). In the legend, we show the logical error per round (LER), calculated from the slope of the fitted lines. (**B**) Fitted logical error per round for different decoders for the \(3\times 3\) and \(5\times 5\) datasets. Variants of our ML decoder without ensembling or fine-tuning are also compared to show the advantage of the complete training procedure.
### Beyond Pauli noise: leakage, cross-talk, I/Q noise

To achieve reliable quantum computation, the decoder must scale to higher code distances. Since hardware implementations at the time of our study do not reach scales capable of running a surface-code experiment beyond distance 5, we explore the performance of our decoder for larger code distances using simulated data at error rates both comparable to and significantly lower than the Sycamore experimental data (see materials and methods, Appendix A.6, Fig. S8). The conventional circuit-noise model [69, 7] is limited, failing to account for several crucial real-world effects, such as cross-talk, leakage and analog readout information. A decoder that recognizes these patterns can be especially valuable, since correlated errors are highly damaging to fault-tolerance [1]. In this section, we use circuit simulators that can model and modulate the above effects independently at code distances \(3,5,7,9\), and \(11\).

#### 2.3.1 Analog readouts

Projective measurement is essential to extract information about errors from the surface code. Typically, each measurement is classified as a discrete outcome \(|0\rangle\) or \(|1\rangle\). However, in some quantum computing architectures, there is underlying analog data with information about uncertainty and leakage to non-computational states. This is the case for standard dispersive measurement of superconducting qubits, where a microwave pulse probes the frequency of a superconducting resonator that is coupled to a qubit in order to infer the qubit's state [101, 9, 48]. The returned microwave signal contains information in its amplitude and phase, traditionally represented in a two-dimensional space of in-phase ("I") and quadrature ("Q") amplitudes. It is simple to provide this information to our ML decoder: for each stabilizer readout, instead of a binary value (0 if the most likely state is \(|0\rangle\), 1 if \(|1\rangle\)), we provide the probability of being in state \(|1\rangle\), based on a decay model, parameterized by the signal-to-noise ratio (SNR) and normalised measurement time \(t=t_{\rm meas}/T_{1}\). This is provided as the network input at cycle \(n\) along with a probabilistic analog to detection events (see materials and methods, Appendix A.1.7, Fig. S4).

Figure 3A shows that ML can outperform correlated matching for a superconducting-inspired circuit depolarizing noise model (SI1000 noise, see materials and methods, Appendices A.1.5 and A.6.2, [34]), augmented with I/Q measurements (where we always threshold the final data qubits to prevent the logical measurement from leaking into the training inputs, see materials and methods, Appendix B.2). If the network is provided with the richer probabilistic inputs derived from I/Q readouts (which our ML decoder can process without runtime penalty), the performance improves further, for both \(3\times 3\) and \(5\times 5\) codes. Incorporating probabilistic measurement inputs into MWPM-Corr [71] also leads to an improvement (though this comes with a runtime penalty).
#### 2.3.2 Leakage and crosstalk

Training and evaluating on Pauli+ simulated data (see materials and methods, Appendix A.1.9), we show that our ML decoder is robust to crosstalk and leakage (Fig. 3B). For SNR = 10, characteristic decay rate \(t_{\mathrm{meas}}/T_{1}=t=0.01\), and 0.1% leakage (meaning 0.1% leakage chance for stabilizer readouts and \(\approx 0.3\%\) on the data qubit measurements, where leakage is removed after each round [63]), our ML-based decoder is more accurate than MWPM-Corr for all code distances 3-9 when trained on a consistent \(2\times 10^{9}\) samples, and at distance 11 when training for \(10^{10}\) samples. We highlight that the number of network parameters is kept almost constant across code distances (see materials and methods, Appendix A.8, Table S5).

At distance 11, the ML decoder achieves a logical error per round of \(5.37\pm 0.01\times 10^{-6}\) (resp. \(6.74\pm 0.02\times 10^{-6}\) for MWPM-Corr). While the shape of the ML decoder curves suggest a decrease in relative error suppression \(\Lambda\) at larger code distances, training to convergence takes longer (cf. Fig. S18); the additional point at distance 11 illustrates that at sufficient training samples an average error suppression factor from distance 3 to 11 of \(\Lambda=4.28\pm 0.02\) is possible, on par with MWPM-Corr (\(\Lambda=4.33\pm 0.04\), see Table S6). \(\Lambda\) for matching is determined by the distribution of errors and the decoder's noise model. For an ML decoder it also becomes a function of training: improved training improves the logical error per round, and this improvement versus the code distance is what determines \(\Lambda\).

Hitherto, leakage states were usually ignored and classified as either \(|0\rangle\) or \(|1\rangle\), but can sometimes be distinguished in the I/Q representation [78, 51]. With traditional binary inputs and without leakage information, our machine-learning decoder outperforms MWPM-Corr at code distances 3-9, and achieves parity at distance 11. Providing leakage information in the form of an additional binary input (leaked/not leaked) slightly increases the lead (Fig. 3B, blue dashed vs. dotted lines) beyond MWPW-Corr (dotted magenta line). Yet, if we provide the model with richer soft information (a probability of being leaked, and a conditional probability of being in \(|1\rangle\), given the measurement was not in a leaked state), the advantage against correlated matching becomes greater (Fig. 3B, solid blue line), even when MWPM-Corr incorporates probabilistic measurement inputs (Fig. 3B, solid magenta line).

For intermediate code distances, the relative penalty incurred from increased leakage as compared to the case of no leakage is much less pronounced for our machine learning decoder (Fig. 3C for code distance 7 and Fig. S13 for 3,5,9 and 11). E.g. compared to no leakage, when adding 0.1% leakage, the ML decoder's logical error per round at distance 7 increases by \(\approx 30\%\) (blue bar), whereas leakage-unaware MWPM-Corr suffers a larger penalty of \(\approx 60\%-80\%\) (magenta bar). While there have been proposals for incorporating leakage information into
matching in idealized models [87], our ML decoder architecture learns to mitigate the effects of leakage without the difficulty of directly characterizing them.

We demonstrate that the advantage of our ML decoder against MWPM decoders persists even in the longest experiments we tried. We trained our decoder using Pauli+ simulated experiments of up to 25 error correcting cycles (soft inputs, SNR = 10, \(t\) = 0.01, and leakage 0.1%), and found its performance to generalize to Pauli+ experiments of up to at least 100 000 cycles (Fig. 4, see materials and methods, Appendix B.2).

Ultimately, our ML decoder's flexibility in seamlessly learning from leakage readout, I/Q information, and cross-talk induced error patterns is an advantage over other state-of-the-art decoders, as evidenced by its improved accuracy.
## 4 Results

Figure 3: **Scaling the decoder and the effect of noise levels and input modality on decoder accuracy.****(A)** Decoder performances for SI1000 data generated with different I/Q noise parameter values. Line styles denote whether the model is provided with the richer, continuous input representation for I/Q readouts (“soft inputs”, continuous lines) or with thresholded binary values (“hard inputs”, dotted lines). Both the ML decoder (blue) and MWPM-Corr (magenta) benefit from the soft inputs but our ML-based technique is more accurate for a range of readout noise levels. **(B)** Logical error per round for different decoders at different code distances, for the same Pauli+ noise model (SNR 10, \(t=0.01\), \(0.1\%\) leakage). Line styles represent whether decoder inputs are binary (hard) or soft and whether they contain information about leakage. Our ML decoder (blue), trained on \(2\times 10^{9}\) samples, leads MWPM-Corr (magenta) by a margin that further improves when augmented with leakage information and probabilistic inputs. The additional point at distance 11 extended training to \(10^{10}\) training samples. **(C)** The relative impact of leakage on the performance of different decoders and input modalities at distance 7. Our ML decoder is more robust to leakage than the MWPM-based decoders.
### Postselection: improving accuracy with confidence

We trained the neural network with a logistic output, minimizing cross-entropy against binary labels. As a result, its output can be interpreted as the probability that the true label is \(|1\rangle\), a probability we found to be well-calibrated (Fig. 5A, S10). For example, of samples with prediction probability 0.8, approximately 80% indeed have the true label \(|1\rangle\). Samples with a probability close to 0.5 are more likely to have been misclassified than samples with a probability closer to 0 or 1 (Fig. S11).

The probabilistic output can be used as a confidence measure to discard the least confident samples (Fig. 5B). On the same Pauli+ simulation (SNR=10, \(t=0.01\), 0.1% leakage) as in Section 2.3.2, and by rejecting only 0.2% of the 25-cycle experiments at distance 11, we can achieve a postselected error rate a factor of \(\approx 10\) lower (10% rejection gives a factor \(\approx 250\)), which could prove useful in repeat-until-success protocols [13, 12, 18, 33, 74, 72].

Figure 4: **Generalization to larger number of error correction cycles at code distance 11.** Fidelity (2 \(\times\) accuracy - 1) after up to 100,000 error-correction cycles (**A**) and the corresponding logical error per round (**B**) for PyMatching (green), MWPM-Corr (magenta) and for our ML decoder (blue) trained only on Pauli+ simulated experiments of up to 25 cycles, with 2B training samples (solid line) and 10B training samples (dashed line). Both training and test samples are Pauli+ (SNR=10, t = 0.01, 0.1% leakage). We only plot LER values where the corresponding fidelity is greater than 0.1. The data is generated from the same simulated experiments, stopped at different number of cycles.
### Discussion

#### 2.5.1 Advantages

In addition to improved error-suppression, our ML decoder inherently provides features desirable for a quantum error correction decoder.

Trainable on raw data.The network can be directly trained on examples from real hardware. As such, its performance is less dependent on the availability or accuracy of a noise model characterizing the device. This reduces reliance on the ability to obtain an accurate noise profile of the device, which is often difficult [37, 69].

Ability to use rich inputs.The network can process rich inputs, such as analog readout signals from the hardware [48], I/Q points, signatures of leakage [65], or potentially other side information such as temperature or calibration parameters [50, 37]. This leads to improved accuracy compared to processing stabilizer syndrome inputs alone (Fig. 1C, Fig. 3).

Figure 5: **The use of the network’s output as a confidence measure for post-selection.** For the ensembled model performance of our ML decoder, trained using 25-cycle Pauli+ simulated experiments (\(\text{SNR}=10\), \(t=0.01\), \(0.1\%\) leakage), tested on \(10^{9}\) samples. **(A)** Example calibration plot at distances 5 (green continuous line) and 11 (purple continuous line), with bootstrapped errors (small but present error bars). Black dashed line represents a perfectly calibrated classifier. **(B)** Logical error rate vs. the fraction of experiments discarded when discarding experiments with low confidence, (error bars: standard error of mean from values in each bin, visible for a \(\text{LER}\lesssim 10^{-8}\)).
Calibrated output.Instead of a binary output, the decoder outputs a calibrated error probability that can be used as a confidence measure e.g. for post-selection.

#### 2.5.2 Throughput considerations

To avoid backlog, any quantum error correction decoder needs to achieve a throughput (processing time per cycle) commensurate with the syndrome accumulation speed of the quantum chip--currently \(1\mathrm{\SIUnitSymbolMicro s}\) for superconducting qubits [35, 37], and \(>\)\(1\mathrm{ms}\) for trapped ion devices [80, 77]. Latency (the delay between the final input to the decoder and its output) plays a secondary role in dictating the quantum computer's logical clock speed [91, 68]. Improving throughput and latency remains an important goal for both machine learning and matching-based decoders [48, 58, 85, 90].

While the model has not yet been optimized for inference speed, a host of techniques can be applied to speed up the model (see materials and methods, Appendix A.8); yet even without those, when running our ML decoder on an accelerator and for code distances up to 25 (untrained for distances \(>\)\(11\)), its throughput is already within about one to two orders of magnitude of the target throughput rate of \(1\mathrm{\SIUnitSymbolMicro s}\) (see Fig. S9). Note that, in contrast to graph-based decoders, our decoder throughput is independent of the noise rate by design [95], avoiding slowdowns caused by spikes in noise rate. The recurrent architecture allows our architecture to decode an indefinite number of error correction cycles, and benefits from parallel processing (particularly GPUs and TPUs). Consequently, the ML decoder's inference time scales efficiently across code distance with a single, fixed-size architecture.

#### 2.5.3 Training data requirements

Fig. S18 shows the number of training samples needed to achieve LER parity with MWPM (PyMatching) and MWPM-Corr. As observed before [95, 67], the data requirements grow exponentially: a hundredfold increase to go from distance 3 to distance 11. Indeed, the trend suggests that one might expect to pre-train a model for code distance 25 to reach parity with MWPM-Corr using \(10^{13}-10^{14}\) training examples. However, this one-off pre-training on a generic noise model can be followed by fast fine-tuning on hardware-specific datasets to achieve the best performance, without training a completely new model from scratch.

## 3 Conclusions and outlook

We have shown that a neural network decoder with inductive biases motivated by the quantum error correction problem can learn to decode the surface code with state-of-the-art error
suppression. On experimental data, it outperforms the previous best-in-class tensor network decoder, which takes orders of magnitude longer to run, although achieving the real-time throughput rates of a superconducting architecture remains a challenge.

Our ML decoder's advantage in accuracy persists at scale, as we continue to outperform correlated matching performance at distances up to 11. This performance is maintained over numbers of error correction cycles that far exceed the training regime. While the architecture itself can be executed on even larger code distances with only a moderate runtime increase, training the decoder to continue suppressing error beyond distance 11 is a further challenge.

As a machine learning model, our decoder's greatest strengths come from its ability to learn from real experimental data. Allowing it to seamlessly take advantage of rich inputs representing I/Q noise and leakage, these capabilities come without a human in the loop to design an explicit algorithm to use each novel feature. This ability to use available experimental information showcases the strength of machine learning in a scientific context.

While we anticipate other decoding techniques will continue to improve, we believe that our work provides evidence that machine learning decoders may achieve the necessary error suppression and speed to enable practical quantum computing.
