Adaptive weight estimator for quantum error correction

Quantum error correction of a surface code or repetition code requires the pairwise matching of error events in a space-time graph of qubit measurements, such that the total weight of the matching is minimized. The input weights follow from a physical model of the error processes that affect the qubits. This approach becomes problematic if the system has sources of error that change over time. Here we show how the weights can be determined from the measured data in the absence of an error model. The resulting adaptive decoder performs well in a time-dependent environment, provided that the characteristic time scale $\tau_{\mathrm{env}}$ of the variations is greater than $\delta t/\bar{p}$, with $\delta t$ the duration of one error-correction cycle and $\bar{p}$ the typical error probability per qubit in one cycle.


I. INTRODUCTION
To execute algorithms on a quantum computer, one must prevent the accumulation of errors by monitoring and correcting them in control hardware. The monitoring is made possible by a nonlocal encoding of the quantum information in a redundant set of qubits, allowing for repeated measurements via auxiliary (ancilla) qubits without collapsing and destroying the quantum superposition of the logical degrees of freedom [1,2]. Parity-check measurements produce strings of bits, the so-called error syndrome, that must be decoded to infer the correction which should be applied to the logical qubits.
For an important class of error correcting codes, the syndrome identifies the end points of an error chain in a space-time graph of ancilla measurements. (See Fig. 1.) The dimensionality of space can differ; it equals 1 in the repetition code [3,4], 2 in the surface code [5][6][7], and 3 for topological cluster states [8]. The identification is not unique: there is in general no unique way to construct a chain of error events consistent with a given syndrome (the decoding problem). One approach to decoding refers to the optimization problem of minimum-weight perfect matching on a graph, which may be solved by the "blossom" algorithm [9,10] in polynomial time. The blossom decoder is sub-optimal [11][12][13][14], but it performs sufficiently well for current quantum hardware to achieve the fault-tolerance threshold [15].
The weights that govern the optimization problem can be readily obtained if one has a calibrated model of the sources of error in the system [16]. Such an error model may not be available, and moreover the error rates may vary in time during the quantum computation. This complication has motivated the search for an adaptive decoder, that would infer the weights from the syndrome without requiring updates of the error model [17][18][19][20][21]. Since the syndrome depends nonlinearly on the weights, this inversion problem is nontrivial -a recent approach [21] employs a machine learning algorithm to learn the weights from the measured data.
Here we show that the inversion can be actually car-ried out by purely algebraic means: The covariance of measurements on pairs of ancillas exactly determines the weight of their matching. We demonstrate the method on the repetition code with time-dependent error rates.

II. QUANTUM ERROR CORRECTION AND THE REPETITION CODE
To set the stage, we summarize the elements of quantum error correction [2,22] that we need in what follows. The expert reader may skip this section.
A quantum error correcting code stores quantum information nonlocally in an array of physical qubits, such that it is protected from local errors (bit flips or sign flips). The encoded state |ψ evolves for a cycle time δt, after which a set of 'stabilizer' measurements is carried out. The stabilizers project |ψ onto a state |ψ that may differ from |ψ if an error occured during the cycle. The outcome of the stabilizer measurements, called the syndrome, identifies the error and allows for a correction. It is crucial that the stabilizer measurements do not measure the degrees of freedom of |ψ in which the relevant quantum information is stored, otherwise this information will be lost upon projection.
The simplest example of error correction via stabilizer measurement is a one-dimensional array, in which a logical qubit is encoded into d data qubits via |0 L = |00 · · · 0 , |1 L = |11 · · · 1 . In a classical setting, this would correspond to a distance-d repetition code, for which one would compare the value of adjacent bits to identify up to (d − 1)/2 bit flips. A quantum parity check achieves this goal without collapsing the superposition |ψ = a 0 |0 L + a 1 |1 L onto the state |0 L or |1 L . The parity-check measurements are performed on d−1 ancilla qubits, which are entangled with pairs of data qubits (see Fig. 1). Each ancilla measures the stabilizer operator Z i Z i+1 (i = 1, 2, . . . d − 1, with Z ≡ σ z a Pauli matrix). The stabilizer does not distinguish between the states |0 L and |1 L and thus preserves their quantum superposition. A bit flip error of qubit j (X j error) is detected by the stabilizer measurements Z j Z j+1 and Z j−1 Z j , which change their value from +1 to −1. A decoder may infer the underlying error from this signature and correct it without needing to measure qubit j itself (which would collapse the state).
The stabilizer measurements in cycle t form a binary parity-check vector π(t). The error syndrome is defined such that an error event is signaled by a nonzero element s i (t) = 1. A single error event is not sufficient to diagnose an error, as Z i Z i+1 would trigger an error event for either X i or X i+1 . To identify which qubit flipped we match pairs of error events. As indicated in Fig. 1, the match can be between error events that are separated in both space and time, at the end points of an error chain from ancilla i 0 at time t to ancilla j 0 at time t + nδt. The error chain may terminate at the boundary of the lattice (corresponding to errors on the boundary data qubits), so some error events may remain unmatched. This simple description to detect bit flips in a repetition code can be extended to the detection of both bit flips and phase flips (X i and Z i errors) and by encoding in 2D and 3D (surface codes and topological cluster states). The generic feature of this class of stabilizer codes is that A few other vertices and connecting edges are also shown, as well as edges that connect a vertex to a boundary (ei 0 i 0 and ej 0 j 0 ). The line thickness of an edge eij is proportional to the probability pij that a single error affects the ancilla qubit measurements on vertices i and j. We seek to determine these probabilities from measurements of the error syndrome.
the decoding entails the pairwise matching of error events in a space-time graph. The method of adaptive quantum error correction presented in the next section applies to this general setting, while for a demonstration we will return to the repetition code.

A. Formulation of the inversion problem
We collect the binary output of the stabilizer measurements in the error syndrome s(t). The discrete time variable t counts the error correction cycle and the elements of the vector s identify the ancilla qubits. For N ancillas and T cycles there are a total of N T variables v i ∈ {0, 1}, arranged as vertices in a space-time graph. (See Fig. 2.) An error event corresponds to v i = 1, while v i = 0 if the ancilla has not detected an error.
The vertices are pairwise connected by undirected edges e ij ≡ e ji ∈ {0, 1} such that e ij = 1 with probability p ij . We allow for i = j, the edge e ii connects a vertex to the boundary of the graph. We say that the edge is on or off depending on whether e ij = 1 or 0. The state of a vertex depends on the edges according to Each edge that is on toggles its vertex between the states 0 and 1, so that v i = 1 if an odd number of connecting edges is on.
The p ij 's are probabilities of a single-qubit error that correlates ancilla measurements i and j. Correlations of ancilla measurements due to uncorrelated multiple-qubit errors are described by weights w ij . The weight w ij for i = j is determined from the p's by following all paths through the graph from i to j: The prime in the sum indicates that the path should not pass through the boundary (i = k 1 = k 2 · · · = k n = j). For a boundary weight w ii the path terminates on the boundary, These sums over error chains can be carried out in terms of the matrix A ij = (1 − δ ij )p ij by matrix inversion [15], Given a set of error events V = {v i |v i = 1} the minimum-weight perfect matching decoder searches for a subset M = {e ij , w ij } of weighted edges such that each vertex in V is connected either to one other vertex in V or to the boundary, at minimal total weight M w ij .
Modern implementations [10] of the blossom algorithm [9] solve this optimization problem efficiently given an error model: A physical model for qubit errors from which the error probabilities p and hence the weights w can be calculated. Here we consider the opposite approach: can we infer the weights from the measured error syndromes, without an underlying error model? This is an inversion problem for Eq. (2), where we seek to reconstruct the statistics of the edges e ij from the measured statistics of the vertices v i . The inversion is possible, in spite of the nonlinearity of Eq. (2), as we now show.

B. Solution for edges connecting pairs of vertices
We first consider a pair of distinct vertices i 0 = j 0 , connected by an edge e i0j0 . (The case of a single vertex connected to the boundary will be dealt with later.) We define In words, E i0\j0 equals 1 or 0 depending on whether the vertex i 0 has an even or an odd number of connecting edges that are on -excluding the connection to vertex j 0 . Note that the sum over j includes j = i 0 , it only excludes j = j 0 . We then rewrite Eq.
Similarly, for vertex j 0 one has Since e i0j0 = e j0i0 = e 2 i0j0 , the product (AND) of v i0 and v j0 equals while the binary sum (XOR) equals By construction, all three variables e i0j0 , E i0\j0 , and E j0\i0 are statistically independent. We denote the average by · · · , with e i0j0 = p i0j0 (11) by definition. The averages of the E's are unknown, but they can be eliminated by combining the four equations (7)-(10). We thus arrive at The left-hand-side is symmetric under the exchange p i0j0 ↔ 1 − p i0j0 . We may safely assume that the error probabilities are < 1/2, resulting in the probability This is an exact relation between the probability of an edge and correlators of the pair of connected vertices. These correlators are measurable from the error syndrome, without any prior knowledge of the error model.

C. Solution for boundary edges
The probability p i0i0 of an edge e i0i0 connecting the vertex v i0 to the boundary cannot be determined by a correlator, since there is nothing to correlate with. We do have access to the average Using again the independence of the variables, we find So once the probabilities p i0j for non-boundary edges are determined from Eq. (13), we can use Eq. (16) to obtain the probability of a boundary edge.

IV. IMPLEMENTATION OF THE ADAPTIVE DECODER
A. Convergence in the large-time limit We test the adaptive decoder on the repetition code of Fig. 1, for a bit-flip error model: at the end of a cycle of duration δt each qubit i is flipped independently with probability γ i . The time-dependent density matrix of the quantum circuit is calculated using the quantumsim simulator of Ref. 15.
We implement the blossom decoder without any prior knowledge of the error probabilities, using Eqs. (13) and (16) to determine them from the measured syndrome data. We assume local sources of error and set p ij ≡ 0 for ancilla measurements i and j that are not connected by any local error. In a nonlocal situation, e.g. because of non-negligible crosstalk, a proliferation of negligibly small error probabilities can be avoided by setting p ij ≡ 0 when the deviation from zero is statistically insignificant.
The adaptive decoder needs sufficient syndrome data in the training stage to estimate the probabilities. Since p ij is the mean of a Bernoulli random variable with variance σ 2 ij = p ij (1 − p ij ), the statistical uncertainty δp ij in the estimation after N = t/δt error cycles is of order The requirement that δp ij p ij 1 implies that a minimum of N min 1/p (18) measurements are needed for a reliable estimation of error probabilities of typical magnitudep. After the training stage the probabilities are inserted into Eq. (5) to determine the weights which are passed to the minimumweight perfect matching (blossom) decoder for error correction. As a figure of merit we introduce a testing stage after the training stage in which we calculate the probability adaptive (N ) of a logical error per cycle using the adaptive decoder trained on N rounds of data. The error rates are calculated following the method of Ref. 15, measuring the average logical qubit fidelity over 100 cycles. The combination of training and testing is repeated a few hundred times to obtain an accurate value of adaptive (N ). We compare this with the probability 0 that would follow from a blossom decoder with pre-determined weights calculated from the error model. The relative error measures how well the adaptive decoder has converged to the ideal blossom decoder. Results are shown in Fig. 3, for a depth d = 3 repetition code with uniform single-qubit error rate γ i = 5 · 10 −3 . We observe a power law convergence ∆ ∝ N −α with α ≈ 1.2. (We do not have an analytical result for this exponent.)

B. Performance in a time-dependent environment
The adaptive decoder can be readily applied to sources of noise that vary in time, by recalibration of the weights as time proceeds. We implement this by estimating the error probabilities at time t from the syndrome data in the time interval (t − T, t). The optimal time window T = N δt should not be too short in view of the statistical error (17), and it should not be too large in view of the variation ωT p ij of the probabilities in the timedependent environment (with characteristic frequency ω). The sum of these sources of error is minimized for The adaptive decoder fails if the noise fluctuates too rapidly to acquire sufficient data for the probability estimation. The condition δp opt ij p ij implies an upper bound ω c p/δt (21) on the frequency of the noise variations that is adaptable for a typical error probabilityp. We test the adaptive decoder in the presence of time dependent errors by taking γ i = γ 0 for the data qubits and γ i = γ 0 (1 + sin ωt) for the ancilla qubits (with γ 0 = 5·10 −3 and 2π/ω = 2·10 4 δt). The predicted optimal time window at this frequency, forp = 5·10 −3 , is N opt ≈ 1265. As shown in Fig. 4, when a larger window N N opt is used, the decoder experiences a time lag in determining optimal weights; for a smaller window N < N opt the weight estimation is degraded by sampling errors.

V. CONCLUSION
We have demonstrated that it is possible to analytically calculate the underlying error probabilities from measured error syndromes in a broad class of stabilizer codes. As this requires inverting a set of non-linear equations, it is surprising that it should be possible at all, let alone with such small overhead. Because the inversion is exact, the convergence of our adaptive decoder to the ideal blossom decoder should be optimal in the absence of additional information about the error rates. This implies that fluctuations faster than a critical frequency ω c are uncorrectable; we have estimated ω c p/δt, withp the single-qubit error probability and δt the duration of one error-correction cycle. Such rapid fluctuations will contribute relatively more to the logical error rate of a quantum error correcting code than slow fluctuations to which the decoder can adapt.
It would be interesting for future work to test the adaptive decoder on more complex noise models, where the optimal window must be chosen for an entire noise frequency spectrum, instead of for a single frequency. We expect white noise to be significantly worse for quantum error correction than 1/f noise, due to the much larger contributions from high frequencies. Future work could also extend our results to simulations of the surface code or topological cluster states.