Abstract
Leakage outside of the qubit computational subspace, present in many leading experimental platforms, constitutes a threatening error for quantum error correction (QEC) for qubits. We develop a leakagedetection scheme via Hidden Markov models (HMMs) for transmonbased implementations of the surface code. By performing realistic densitymatrix simulations of the distance3 surface code (Surface17), we observe that leakage is sharply projected and leads to an increase in the surfacecode defect probability of neighboring stabilizers. Together with the analog readout of the ancilla qubits, this increase enables the accurate detection of the time and location of leakage. We restore the logical error rate below the memory breakeven point by postselecting out leakage, discarding less than half of the data for the given noise parameters. Leakage detection via HMMs opens the prospect for nearterm QEC demonstrations, targeted leakage reduction and leakageaware decoding and is applicable to other experimental platforms.
Introduction
Recent advances in qubit numbers^{1,2,3,4}, as well as operational^{5,6,7,8,9,10,11,12,13}, and measurement^{14,15,16} fidelities have enabled leading quantum computing platforms, such as superconducting and trappedion processors, to target demonstrations of quantum error correction (QEC)^{17,18,19,20,21,22,23} and quantum advantage^{2,24,25,26}. In particular, twodimensional stabilizer codes, such as the surface code, are a promising approach^{23,27} towards achieving quantum fault tolerance and, ultimately, largescale quantum computation^{28}. One of the central assumptions of textbook QEC is that any error can be decomposed into a set of Pauli errors that act within the computational space of the qubit. In practice, many qubits such as weaklyanharmonic transmons, as well as hyperfinelevel trapped ions, are manylevel systems which function as qubits by restricting the interactions with the other excited states. Due to imprecise control^{12,29,30} or the explicit use of noncomputational states for operations^{5,6,9,11,31,32,33,34,35}, there exists a finite probability for information to leak from the computational subspace. Thus, leakage constitutes an error that falls outside of the domain of the qubit stabilizer formalism. Furthermore, leakage can last over many QEC cycles, despite having a finite duration set by the relaxation time^{36}. Hence, leakage represents a menacing error source in the context of quantum error correction^{17,36,37,38,39,40,41,42,43}, despite leakage probabilities per operation being smaller than readout, control or decoherence error probabilities^{6,8,9,44}.
The presence of leakage errors has motivated investigations of its effect on the code performance and of strategies to mitigate it. A number of previous studies have focused on a stochastic depolarizing model of leakage^{38,40,41,42,43}, allowing to explore largedistance surface codes and the reduction of the code threshold using simulations. These models, however, do not capture the full details of leakage, even though a specific adaptation has been used in the case of trappedion qubits^{41,42,43}. Complementary studies have considered a physically realistic leakage model for transmons^{36,39}, which was only applied to a small paritycheck unit due to the computational cost of manyqutrit densitymatrix simulations. In either case, leakage was found to have a strong impact on the performance of the code, resulting in the propagation of errors, in the increase of the logical error rate and in a reduction of the effective code distance. In order to mitigate these effects, there have been proposals for the introduction of leakage reduction units (LRUs)^{37,39,40,45} beyond the natural relaxation channel, for modifications to the decoding algorithms^{17,38,40}, as well as for the use of different codes altogether^{42}. Many of these approaches rely on the detection of leakage or introduce an overhead in the execution of the code. Recently, the indirect detection of leakage in a 3qubit paritycheck experiment^{20} was realized via a Hidden Markov Model (HMM), allowing for subsequent mitigation via postselection. Given that current experimental platforms are within reach of quantummemory demonstrations, detailed simulations employing realistic leakage models are vital for a comprehensive understanding of the effect of leakage on the code performance, as well as for the development of a strategy to detect leakage without additional overhead.
In this work we demonstrate the use of computationally efficient HMMs to detect leakage in a transmon implementation of the distance3 surface code (Surface17)^{46}. Using fulldensitymatrix simulations^{27} (The quantumsim package can be found at https://quantumsim.gitlab.io/) we first show that repeated stabilizer measurements sharply project data qubits into the leakage subspace, justifying the use of classical HMMs with only two hidden states (computational or leaked) for leakage detection. We observe a considerable increase in the surfacecode defect probability of neighboring stabilizers while a data or ancilla qubit is leaked, a clear signal that may be detected by the HMMs. For ancilla qubits, we further consider the information available in the analog measurement outcomes, even when the leaked state \(\left2\right\rangle\) can be discriminated from the computational states \(\left0\right\rangle\) and \(\left1\right\rangle\) with limited fidelity. We demonstrate that a set of twostate HMMs, one HMM for each qubit, can accurately detect both the time and the location of a leakage event in the surface code. By postselecting on the detected leakage, we restore the logical performance of Surface17 below the memory breakeven point, while discarding less than half of the data for the given errormodel parameters. Finally, we outline a minimal set of conditions for our leakagedetection scheme to apply to other quantumcomputing platforms. Although postselection is not scalable due to an exponential overhead in the number of required experiments, these results open the prospect for nearterm demonstrations of fault tolerance even in the presence of leakage. Furthermore, HMMbased leakage detection enables the possibility of scalable leakageaware decoding^{17,40} and realtime targeted application of LRUs^{37,39,40}.
Results
Leakage error model
We develop an error model for leakage in superconducting transmons, for which twoqubit gates constitute the dominant source of leakage^{5,6,9,11,12,29,30,31,32,33,34}, while singlequbit gates have negligible leakage probabilities^{8,44}. We thus focus on the former, while the latter is assumed to induce no leakage at all. We assume that singlequbit gates act on a leaked state as the identity. Measurementinduced leakage is also assumed to be negligible.
We use fulltrajectory simulations to characterize leakage in the NetZero implementation^{9} of the controlledphase gate (CZ), considered as the native twoqubit gate in a transmonbased Surface17, with experimentally targeted parameters (see Table 1 and Supplementary Table 1). This gate uses a flux pulse such that the higher frequency qubit (Q_{flux}) is fluxed down from its sweetspot frequency \({\omega }_{\max }\) to the vicinity of the interaction frequency ω_{int} = ω_{stat} − α, where ω_{stat} is the frequency of the other qubit (Q_{stat}), which remains static, and α is the transmon anharmonicity. The inset in Fig. 1a shows a schematic diagram of the frequency excursion taken by Q_{flux}. A (bipolar) 30 ns pulse tunes twice the qubit on resonance with the \(\left11\right\rangle \leftrightarrow \left02\right\rangle\) avoided crossing, corresponding to the interaction frequency ω_{int}. This pulse is followed by a pair of 10 ns singlequbit phasecorrection pulses. The relevant crossings around ω_{int} are shown in Fig. 1a and are all taken into account in the fulltrajectory simulations. The twoqubit interactions give rise to population exchanges towards and within the leakage subspace and to the phases acquired during gates with leaked qubits, which we model as follows.
The model in Fig. 1b considers a general CZ rotation, characterized by the twoqubit phase ϕ_{11} for state \(\left11\right\rangle\) and ϕ = 0 for the other three computational states. The singlequbit relative phases ϕ_{01} and ϕ_{10} result from imperfections in the phase corrections. The conditional phase is defined as ϕ_{CZ} = ϕ_{11} − ϕ_{01} − ϕ_{10} + ϕ_{00}, which for an ideal CZ is ϕ_{CZ} = π. In this work, we assume ϕ_{00} = ϕ_{01} = ϕ_{10} = 0 and ϕ_{CZ} = ϕ_{11} = π. We set ϕ_{02} = − ϕ_{11} in the rotating frame of the qutrit, as it holds for fluxbased gates^{35}.
Interactions between leaked and nonleaked qubits lead to extra phases, which we call leakage conditional phases. We consider first the interaction between a leaked Q_{flux} and a nonleaked Q_{stat}. In this case the gate restricted to the \(\left\{\left02\right\rangle ,\left12\right\rangle \right\}\) subspace has the effect \({\mathrm{diag}}\left({e}^{{\rm{i}}{\phi }_{{\rm{02}}}},{e}^{{\rm{i}}{\phi }_{{\rm{12}}}}\right)\), which up to a global phase corresponds to a Z rotation on Q_{stat} with an angle given by the leakage conditional phase \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}:= {\phi }_{{\rm{02}}}{\phi }_{{\rm{12}}}\). Similarly, if Q_{stat} is leaked, then Q_{flux} acquires a leakage conditional phase \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}:= {\phi }_{{\rm{20}}}{\phi }_{{\rm{21}}}\). These rotations are generally nontrivial, i.e., \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\,\ne \,\pi\) and \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}\,\ne \,0\), due to the interactions in the 3excitation manifold which cause a shift in the energy of \(\left12\right\rangle\) and \(\left21\right\rangle\) (see section “Secondorder leakage effects” of Supplementary Methods). If the only interaction leading to nontrivial \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\), \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}\) is the interaction between \(\left12\right\rangle\) and \(\left21\right\rangle\), then it can be expected that ϕ_{12} = −ϕ_{21} in the rotating frame of the qutrit, leading to \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}=\pi {\phi }_{{\rm{flux}}}^{{\mathcal{L}}}\).
Leakage is modeled as an exchange between \(\left11\right\rangle\) and \(\left02\right\rangle\), i.e., \(\left11\right\rangle\, \mapsto \,\sqrt{14{L}_{1}}\left11\right\rangle +{e}^{{\rm{i}}\phi }\sqrt{4{L}_{1}}\left02\right\rangle\) and \(\left02\right\rangle\, \mapsto \,\!{e}^{{\rm{i}}\phi }\sqrt{4{L}_{1}}\left11\right\rangle +\sqrt{14{L}_{1}}\left02\right\rangle\), with L_{1} the leakage probability^{47}. We observe that the phase ϕ and the offdiagonal elements \(\left11\right\rangle \left\langle 02\right\) and \(\left02\right\rangle \left\langle 11\right\) do not affect the results presented in this work, so we set them to 0 for computational efficiency (see section “Error model and parameters”). The SWAPlike exchange between \(\left12\right\rangle\) and \(\left21\right\rangle\) with probability L_{m}, which we call leakage mobility, as well as the possibility of further leaking to \(\left3\right\rangle\), are analyzed in Supplementary Fig. 1 and in section “Secondorder leakage effects” of Supplementary Methods.
The described operations are implemented as instantaneous in the quantumsim package (introduced in “The quantumsim package can be found at https://quantumsim.gitlab.io/”), while the amplitude and phase damping experienced by the transmon during the application of the gate are symmetrically introduced around them, indicated by lightorange arrows in Fig. 1b. The darkorange arrows indicate the increased dephasing rate of Q_{flux} far away from \({\omega }_{\max }\) during the NetZero pulse. The error parameters considered in this work are summarized in section “Error model and parameters”. In particular, unless otherwise stated, L_{1} is set to 0.125% and \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\) are randomized for each qubit pair across different batches consisting of 2 × 10^{4} or 4 × 10^{4} runs of 20 or 50 QEC cycles, respectively. This choice is motivated by our expectation that these phases are determined by the frequencies and anharmonicities of the two transmons, as well as by the parameterization of the flux pulse implementing each CZ between the pair, which is fixed when tuning the gate experimentally. Since \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\) have not been characterized in experiment, we instead choose to randomized them in order to capture an average behavior.
Some potential errors are found to be small from the fulltrajectory simulations of the CZ gate and thus are not included in the parametrized error model. The population exchange between \(\left01\right\rangle \leftrightarrow \left10\right\rangle\), with coupling J_{1}, is suppressed (<0.5%) since this avoided crossing is offresonant by one anharmonicity α with respect to ω_{int}. While \(\left12\right\rangle \leftrightarrow \left21\right\rangle\) is also offresonant by α, the coupling between these two levels is stronger by a factor of 2, hence potentially leading to a larger population exchange (see section “Secondorder leakage effects” of Supplementary Methods). The \(\left11\right\rangle \leftrightarrow \left20\right\rangle\) crossing is 2α away from ω_{int} and it thus does not give any substantial phase accumulation or population exchange (<0.1%). We have compared the average gate fidelity of CZ gates simulated with the two methods and found differences below ±0.1%, demonstrating the accuracy of the parametrized model.
Effect of leakage on the code performance
We implement densitymatrix simulations (The quantumsim package can be found at https://quantumsim.gitlab.io/) to study the effect of leakage in Surface17 (Fig. 2). We follow the frequency arrangement and operation scheduling proposed in ref. ^{46}, which employs three qubit frequencies for the surfacecode lattice, arranged as shown in Fig. 2a. The CZ gates are performed between the highmid and midlow qubit pairs, with the higher frequency qubit of the pair taking the role of Q_{flux} (see Fig. 1). Based on the leakage model in section “Leakage error model”, only the high and mid frequency qubits are prone to leakage (assuming no leakage mobility). Thus, in the simulation those qubits are included as threelevel systems, while the lowfrequency ones are kept as qubits. Ancillaqubit measurements are modeled as projective in the \(\left\{\left0\right\rangle ,\left1\right\rangle ,\left2\right\rangle \right\}\) basis and ancilla qubits are not reset between QEC cycles. As a consequence, given the ancillaqubit measurement \(m\left[n\right]\) at QEC cycle n, the syndrome is given by \(m\left[n\right]\oplus m\left[n1\right]\) and the surfacecode defect \(d\left[n\right]\) by \(d\left[n\right]=m\left[n\right]\oplus m\left[n2\right]\). For the computation of the syndrome and defect bits we assume that a measurement outcome \(m\left[n\right]=2\) is declared as \(m\left[n\right]=1\). The occurrence of an error is signaled by \(d\left[n\right]=1\). To pair defects we use a minimumweight perfectmatching (MWPM) decoder, whose weights are trained on simulated data without leakage^{27,48} and we benchmark its logical performance in the presence of leakage errors. The logical qubit is initialized in \({\left0\right\rangle }_{{\rm{L}}}\) and the logical fidelity is calculated at each QEC cycle, from which the logical error rate ε_{L} can be extracted^{27}.
Figure 2b shows that the logical error rate ε_{L} is sharply pushed above the memory breakeven point by leakage. We compare the MWPM decoder to the decoding upper bound (UB), which uses the complete densitymatrix information to infer a logical error. A strong increase in ε_{L} is observed for this decoder as well. Furthermore, the logical error rate has a dependence on the leakage conditional phases for both decoders, as shown in Fig. 2c, d. While not included in these simulations, we do not expect the inclusion of leakage mobility or the possibility of further leaking to \(\left3\right\rangle\) to have a considerable effect on the logical performance (see section “Effects of leakage mobility and superleakage on leakage detection and code performance” of Supplementary Methods).
Projection and signatures of leakage
We now characterize leakage in Surface17 and the effect that a leaked qubit has on its neighboring qubits. From the density matrix (DM), we extract the probability \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)={\mathbb{P}}(Q\in {\mathcal{L}})=\left\langle 2 {\rho }_{Q} 2\right\rangle\) of a qubit Q being in the leakage subspace \({\mathcal{L}}\) at the end of a QEC cycle, after the ancillaqubit measurements, where ρ_{Q} is the reduced density matrix of Q.
In the case of dataqubit leakage, \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\) sharply rises to values near unity, where it remains for a finite number of QEC cycles (on average 16 QEC cycles for the considered parameters, given in Table 1). We refer to this sharp increase of \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\) as projection of leakage. An example showing this projective behavior (in the case of qubit D_{4}), as observed from the densitymatrix simulations, is reported in Fig. 3a. This is the typical behavior of leakage, as shown in Fig. 3b by the bimodal density distribution of the probabilities \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\) for all the highfrequency data qubits Q. As dataqubit leakage is associated with defects on the neighboring ancilla qubits (due to the use of the \(\left02\right\rangle \leftrightarrow \left11\right\rangle\) crossing by the CZ gates) and with the further propagation of defects in the following QEC cycles (as shown below), we attribute the observed projection to a backaction effect of the repetitive stabilizer measurements (see Supplementary Fig. 2 and section “Projection of dataqubit leakage by stabilizermeasurement backaction” of Supplementary Methods). Given this projective behavior, we identify individual events by introducing a threshold \({p}_{{\rm{th}}}^{{\mathcal{L}}}\left(Q\right)\), above which a qubit is considered as leaked. Here we focus on leakage on D_{4}, sketched in Fig. 3c. Based on a threshold \({p}_{{\rm{th}}}^{{\mathcal{L}}}\left({D}_{{\rm{4}}}\right)=0.5\), we select leakage events and extract the average dynamics shown in Fig. 3d. Leakage grows over roughly 3 QEC cycles following a logistic function, reaching a maximum probability of approximately 0.8. We observe this behavior for all three highfrequency data qubits D_{3}, D_{4}, D_{5}. Each of the highfrequency data qubits equilibrates towards a steadystate population (extracted by averaging \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\) over all runs without selecting individual events) after many QEC cycles (see Supplementary Fig. 3 and section “Leakage steady state in the surface code” of Supplementary Methods).
We observe an increase in the defect probability of the neighboring ancilla qubits during dataqubit leakage. We extract the probability p^{d} of observing a defect d = 1 on the neighboring stabilizers during the selected dataqubit leakage events, as shown in Fig. 3e. As \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left({D}_{{\rm{4}}}\right)\) reaches its maximum, p^{d} goes to a constant value of approximately 0.5. This can be explained by dataqubit leakage reducing the stabilizer checks it is involved in to effective weight3 anticommuting checks, illustrated in Fig. 3c and as observed in ref. ^{20}. This anticommutation leads to some of the increase in ε_{L} for the MWPM and UB decoders in Fig. 2b. Furthermore, we attribute the observed sharp projection of leakage (see Fig. 3d) to a backaction effect of the measurements of the neighboring stabilizers, whose outcomes are nearly randomized when the qubit is leaked (see sections “Leakageinduced anticommutation” and “Projection of dataqubit leakage by stabilizermeasurement backaction” of Supplementary Methods). The weight3 checks can also be interpreted as gauge operators, whose pairwise product results in weight6 stabilizer checks, which can be used for decoding^{49,50,51,52}, effectively reducing the code distance from 3 to 2.
We also find a local increase in the defect probability during ancillaqubit leakage. For ancilla qubits, \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\) is defined as the leakage probability after the ancilla projection during measurement. Since in the simulations ancilla qubits are fully projected, \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)=0,1\) for an ancilla qubit Q, allowing to directly obtain the individual leakage events, as shown in Fig. 3g. We note that an ancilla qubit remains leaked for 17 QEC cycles on average for the considered parameters (given in Table 1). We extract p^{d} during the selected events, as shown in Fig. 3h. In the QEC cycle after the ancilla qubit leaks, p^{d} abruptly rises to a high constant value. We attribute this to the Z rotations acquired by the neighboring data qubits during interactions with the leaked ancilla qubit, as sketched in Fig. 3f and described in section “Leakage error model”. The angle of rotation is determined by \({\phi }_{{\rm{flus}}}^{{\mathcal{L}}}\) or \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\), depending on whether the leaked ancilla qubit takes the roles of Q_{stat} or Q_{flux}, respectively (see section “Simulation protocol” for the scheduling of operations). In the case of Ztype parity checks, these phase errors are detected by the Xtype stabilizers. In the case of Xtype checks, the phase errors on data qubits are converted to bitflip errors by the Hadamard gates applied on the data qubits, making them detectable by the Ztype stabilizers. Furthermore, while the ancilla qubit is leaked, the corresponding stabilizer measurement does not detect any errors on the neighboring data qubits, effectively disabling the stabilizer, as sketched in Fig. 3f. This, combined with the spread of errors, defines the signature of ancillaqubit leakage and explains part of the observed increase in ε_{L} for the MWPM and UB decoders in Fig. 2b.
For both data and ancilla qubits, a leakage event is correlated with a local increase in the defect rate, albeit due to different mechanisms. However, interpreting the spread of defects as signatures of leakage suggests the possible inversion of the problem, allowing for effective leakage detection.
Hidden Markov models
We use a set of HMMs, one HMM for each leakageprone qubit, to detect leakage. This approach is similar to what was recently demonstrated in a 3qubit paritycheck experiment^{20}, but we use simpler HMMs to make them computationally efficient. In general, an HMM (see Fig. 4 and section “HMM formalism”) models the time evolution of a discrete set of hidden states, the transitions between which are assumed to be Markovian. At each time step a set of observable bits is generated with statedependent emission probabilities. Depending on the observed outcomes, the HMM performs a Bayesian update of the predicted probability distribution over the hidden states.
We apply the concept of HMMs to leakage inference and outline their applicability for an accurate, scalable and runtime executable leakagedetection scheme. This is made possible by two observations. The first is that both dataqubit and ancillaqubit leakage are sharply projected (see section “Projection and signatures of leakage”) to high \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\). This justifies the use of classical HMMs with only two hidden states, corresponding to the qubit being in the computational or leakage subspace.
The second observation is the sharp local increase in p^{d} associated with leakage (see section “Projection and signatures of leakage”), which we identify as the signature of leakage. This allows us to consider only the defects on the neighboring stabilizers as relevant observables and to neglect correlations between pairs of defects associated with qubit errors. In the case of ancillaqubit leakage, in addition to the defects, we consider the state information obtained from the analog measurement as input to the HMMs. Each transmon is dispersively coupled to a dedicated readout resonator. The statedependent shift in the singleshot readout produces an output voltage signal, with inphase and quadrature components (see section “Transmon measurements in experiment” of Supplementary Methods).
The transition probabilities between the two hidden states are determined by the leakage and seepage probabilities per QEC cycle, which are, to lowest order, a function only of the leakage probability L_{1} per CZ gate and of the relaxation time T_{1} (see section “HMM formalism”). We extract the statedependent emission probabilities from simulation. When a qubit is not leaked, the probability of observing a defect on each of the neighboring stabilizers is determined by regular errors. When a data qubit is leaked, the defect probability is fixed to a nearly constant value by the stabilizer anticommutation, while when an ancilla qubit is leaked, this probability depends on \({\phi }_{{\rm{flus}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\). Furthermore, the analog measurement outcome can be used to extract a probability of the transmon being in \(\left0\right\rangle ,\,\left1\right\rangle\), or \(\left2\right\rangle\) using a calibrated measurement (see sections “Ancillaqubit leakage detection” and “Transmon measurements in experiment” of Supplementary Methods).
Dataqubit leakage detection
We assess the ability of the dataqubit HMMs to accurately detect both the time and the location of a leakage event. We recall that these HMMs take the defects on neighboring stabilizers as input. The average temporal response \({p}_{{\rm{HMM}}}^{{\mathcal{L}}}\left(Q\right)\) of the HMMs to an event is shown in Fig. 5 and compared to the leakage probabilities \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\) extracted from the densitymatrix simulation. Events are selected when crossing a threshold \({p}_{{\rm{th}}}^{{\mathcal{L}}}\), as described in section “Projection and signatures of leakage”, and the response is averaged over these events. For the dataqubit HMMs, the response \({p}_{{\rm{HMM}}}^{{\mathcal{L}}}\left(Q\right)\) closely follows the probability \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\) from the density matrix, reaching the same maximum leakage probability but with a smaller logistic growth rate. This slightly slower response is expected to translate to an average delay of about 1 QEC cycles in the detection of leakage.
We now explore the leakagedetection capability of the HMMs. The precision \({\mathcal{P}}\) of an HMM tracking leakage on a qubit Q is defined as
and can be computed as
where i runs over all runs and QEC cycles and θ is the Heaviside step function. The precision is then the fraction of correctly identified leakage events (occurring with probability given by the density matrix), over all of the HMM detections of leakage. The recall \({\mathcal{R}}\) of an HMM for a qubit Q is defined as
and can be computed as
The recall is the fraction of detected leakage by the HMM over all leakage events (occurring with probability given by the density matrix). The precisionrecall (PR) of an HMM (see Fig. 5b) is a parametric curve obtained by sweeping \({p}_{{\rm{th}}}^{{\mathcal{L}}}\left(Q\right)\) and plotting the value of \({\mathcal{P}}\) and \({\mathcal{R}}\). Since the PR curve is constructed from \({p}_{{\rm{HMM}}}^{{\mathcal{L}}}\left(Q\right)\) over all QEC cycles and runs, it quantifies the detection ability in both time and space. The detection ability of an HMM manifests itself as a shift of the PR curve towards higher values of \({\mathcal{P}}\) and \({\mathcal{R}}\) simultaneously. We define the optimality \({\mathcal{O}}\left(Q\right)\) of the HMM corresponding to qubit Q as
where \({{\rm{AUC}}}_{{\rm{HMM}}}\left(Q\right)\) is the area under the PR curve of the HMM and \({{\rm{AUC}}}_{{\rm{DM}}}\left(Q\right)\) is the area for the optimal model that predicts leakage with probability \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left(Q\right)\), achieving the best possible \({{\mathcal{P}}}_{{\rm{DM}}}\) and \({{\mathcal{R}}}_{{\rm{DM}}}\). An average optimality of \({\mathcal{O}}\left(Q\right)\approx 67.0 \%\) is extracted for the dataqubit HMMs. Given the few QECcycle delay in the dataqubit HMM response to leakage, the main limitation to the observed HMM optimality \({\mathcal{O}}\left(Q\right)\) is false detection when a neighboring qubit is leaked (see Supplementary Fig. 4 and section “HMM error budget” of Supplementary Methods).
Ancillaqubit leakage detection
We now assess the ability of the ancillaqubit HMMs to accurately detect both the time and the location of a leakage event. These HMMs take as observables the defects on the neighboring stabilizers at each QEC cycle, as well as the analog measurement outcome of the ancilla qubit itself.
We first consider the case when the HMMs rely only on the increase in the defect probability p^{d} and show their PR curves in Fig. 6a, b. Given that projective measurements are used in the simulations, \({{\rm{AUC}}}_{{\rm{DM}}}\left(Q\right)=1\) for ancilla qubits. Bulk ancilla qubits have a moderate \({\mathcal{O}}\left(Q\right)\approx 47 \%\), while boundary ancilla qubits possess nearly no ability to detect leakage. We attribute this to the boundary ancilla qubits having only a single neighboring stabilizer, compared to bulk ancilla qubits having 3 in Surface17. The HMMs corresponding to pairs of sametype (X or Z) bulk ancilla qubits exhibit visibly different PR curves (see Fig. 6a, b), despite the apparent symmetry of Surface17. This symmetry is broken by the use of highfrequency and lowfrequency transmons as data qubits, leading to differences in the order in which an ancilla qubit interacts with its neighboring data qubits (see ref. ^{46} and Fig. 8), together with the fact that CZs with L_{1} ≠ 0 do not commute in general. In addition to a low \({\mathcal{O}}\left(Q\right)\), the errors propagated by the leaked ancilla qubits (and hence the signatures of ancillaqubit leakage) depend on \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}\) (randomized in the simulations). The values of these phases generally lead to different p^{d} than the ones parameterizing the HMM. The latter is extracted based on the average p^{d} observed over the runs (see section “HMM formalism”). In the worstcase (for leakage detection), these phases can lead to no errors being propagated onto the neighboring data qubits, resulting in the undetectability of leakage. The mismatch between the fluctuating p^{d} (over \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}\)) and the average value hinders the ability of the ancillaqubit HMMs to detect leakage. Even if these phases were individually controllable, tuning them to maximize the detection capability of the HMMs would also lead to an undesirable increase in ε_{L} of a (leakageunaware) decoder (see Fig. 2).
To alleviate these issues, we consider the statedependent information obtained from the analog measurement outcome. The discrimination fidelity between \(\left1\right\rangle\) and \(\left2\right\rangle\) is defined as
where \({\mathbb{P}}\left({{i} {j}}\right)\) is the conditional probability of declaring the measurement outcome i given that the qubit has been prepared in state \(\leftj\right\rangle\), assuming that no excitation or relaxation occur during the measurement (accounted for in postprocessing). Here, we assume that \({\mathbb{P}}\left({{0} {2}}\right)={\mathbb{P}}\left({{2} {0}}\right)={0}\), as observed in experiment (see Supplementary Fig. 5). We focus on the discrimination fidelity as in our simulations relaxation is already accounted for in the measurement outcomes (see section “Error model and parameters”). We extract \({F}^{{\mathcal{L}}}\) from recent experimental data^{20}, where the readout pulse was only optimized to discriminate between the computational states. By taking the inphase component of the analog measurement, for each state \(\leftj\right\rangle\) a Gaussian distribution \({{\mathcal{N}}}_{j}\) is obtained, from which we get \({F}^{{\mathcal{L}}}=88.4 \%\) (see section “Transmon measurements in experiment” of Supplementary Methods).
In order to emulate the analog measurement in simulation, given an ancillaqubit measurement outcome \(m\in \left\{0,1,2\right\}\), we sample the inphase response I_{m} from the corresponding distribution \({{\mathcal{N}}}_{m}\). The probability of the ancilla qubit being leaked given I_{m} is computed as
The ancillaqubit HMMs use the sampled responses I_{m}, in combination with the observed defects, to detect leakage.
The PR curves of the HMMs using the analog readout are shown in Fig. 6c, d, from which an average \({\mathcal{O}}\left(Q\right)\approx 97 \%\) can be extracted for the ancillaqubit HMMs. The temporal responses of the HMMs to leakage are compared to the leakage probabilities extracted from measurement in Fig. 6e, f, showing a relatively sharp response to a leakage event, with an expected delay in the detection of at most 2 QEC cycles. While \({F}^{{\mathcal{L}}}=88.4 \%\) might suggest an even sharper response, this is not the case as the HMM update depends on both the prior \({p}_{{\rm{HMM}}}^{{\mathcal{L}}}\) (which is low when the qubit is not leaked) and on the likelihood of the sampled I_{m} together with the observed defects on the neighboring ancilla qubits (see section “HMM formalism”). While the initial response is not immediately high, given a (not too) low threshold, corresponding to a high \({\mathcal{R}}\), the HMMs still achieve a high \({\mathcal{P}}\), leading to the high \({\mathcal{O}}\) observed (see Fig. 6c, d). A further benefit of the inclusion of the analogmeasurement information is that the detection capability of the HMMs is now largely insensitive to the fluctuations in \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{flus}}}^{{\mathcal{L}}}\).
We explore \({\mathcal{O}}\left(Q\right)\) as a function of \({F}^{{\mathcal{L}}}\), as shown in the inset of Fig. 6c, d. To do this, we model \({{\mathcal{N}}}_{j}\) for each state as symmetric and having the same standard deviation, in which case \({F}^{{\mathcal{L}}}\) is a function of their signaltonoise ratio only (see section “Transmon measurements in experiment” of Supplementary Methods). At low \({F}^{{\mathcal{L}}}\)\(\left(\lesssim 60 \% \right)\) the detection of leakage is possible but limited, especially for the boundary ancilla qubits. On the other hand, even at moderate values of \({F}^{{\mathcal{L}}}\)\(\left(\approx 80 \% \right)\), corresponding to experimentally achievable values, ancillaqubit leakage can be accurately identified for both bulk and boundary ancilla qubits. Furthermore, relying solely on the analog measurements would allow for the potential minimization of the error spread associated with ancillaqubit leakage, given controllability over \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{flus}}}^{{\mathcal{L}}}\), without compromising the capability of the HMMs to detect leakage. In section “An alternative scheme for enhancing ancillaqubit leakage detection” of Supplementary Methods we explore an alternative scheme for increasing the performance of the ancillaqubit HMMs without using the analog measurements, which comes at the cost of a lower optimality for dataqubit HMMs.
Improving code performance via postselection
We use the detection of leakage to reduce the logical error rate ε_{L} via postselection on leakage detection, with the selection criterion defined as
We thus postselect any run for which the leakage probability of any qubit exceeds the defined threshold in any of the QEC cycles. We note that postselection is not scalable for largerscale QEC, due to an exponential overhead in the number of required experiments, however, it can be useful for a relatively small code such as Surface17. Furthermore, note that, while the criterion above is insensitive to overestimation of the leakage probability due to a leaked neighboring qubit (see section “HMM error budget” of Supplementary Methods), it is sensitive to the correct detection of leakage in the first place and to the HMM response in time (especially for shortlived leakage events).
We perform the multiobjective optimization
where f is the fraction of discarded data. The inequality constraint on the feasible space is helpful for the fitting procedure, required to estimate ε_{L}. This optimization uses an evolutionary algorithm (NGSAII), suitable for conflicting objectives, for which the outcome is the set of lowest possible ε_{L} for a given f. This set is known as the Pareto front and is shown in Fig. 7 for both the MWPM and UB decoders. In Fig. 7 we also compare postselection based on the HMMs against postselection based on the densitymatrix simulation. Here we use the predictions of the HMMs which include the analog measurement outcome with the experimentally extracted \({F}^{{\mathcal{L}}}\) (see section “Ancillaqubit leakage detection”). The observed agreement between the two postselection methods proves that the performance gain is due to discarding runs with leakage instead of runs with only regular errors. The performance of the MWPM decoder is restored below the quantum memory breakeven point by discarding f ≈ 28%. The logical error rates extracted from simulations without leakage are achieved by postselection of f ≈ 44% of the data for both the MWPM and UB decoders, when leakage is included.
Discussion
We have investigated the effects of leakage and its detectability using densitymatrix simulations of a transmonbased implementation of Surface17. Data and ancilla qubits tend to be sharply projected onto the leakage subspace, either indirectly by a backaction effect of stabilizer measurements for data qubits or by the measurement itself for ancilla qubits. During leakage, a large, but local, increase in the defect rate of neighboring qubits is observed. For data qubits we attribute this to the anticommutation of the involved stabilizer checks, while for ancilla qubits we find that it is due to an interactiondependent spread of errors to the neighboring qubits. We have developed a lowcost and scalable approach based on HMMs, which use the observed signatures together with the analog measurements of the ancilla qubits to accurately detect the time and location of leakage events. The HMM predictions are used to postselect out leakage, allowing for the restoration of the performance of the logical qubit below the memory breakeven point by discarding less than half of the data (for such a relatively small code and for the given noise parameters), opening the prospect of nearterm QEC demonstrations even in the absence of a dedicated leakagereduction mechanism.
A few noise sources have not been included in the simulations. First, we have not included readoutdeclaration errors, corresponding to the declared measurement outcome being different from the state in which the ancilla qubit is projected by the measurement itself. These errors are expected to have an effect on the performance of the MWPM decoder, as well as a small effect on the observed optimality of the HMMs. We have also ignored any crosstalk effects, such as residual couplings, crossdriving or dephasing induced by measurements on other qubits. While the presence of these crosstalk mechanisms is expected to increase the error rate of the code, it is not expected to affect the HMM leakagedetection capability. We have assumed measurements to be perfectly projective. However, for small deviations, we do not expect a significant effect on the projection of leakage and on the observation of the characteristic signatures.
We now discuss the applicability of HMMs to other quantumcomputing platforms subject to leakage and determine a set of conditions under which leakage can be efficiently detected. First, we assume singlequbit and twoqubit gates to have low leakage probabilities, otherwise QEC would not be possible in general. In this way, singlequbit and twoqubit leakage probabilities can be treated as perturbations to blockdiagonal gates, with one block for the computational subspace \({\mathcal{C}}\) and one for the leakage subspace \({\mathcal{L}}\). We focus on the gates used in the surface code, i.e., CZ and Hadamard H (or R_{Y}(π/2) rotations or equivalent gates). We consider dataqubit leakage first. We have observed that it is made detectable by the leakageinduced anticommutation of neighboring stabilizers. The only condition ensuring this anticommutation is that H acts as the identity in \({\mathcal{L}}\) or that it commutes with the action of CZ within the leakage block (see section “Leakageinduced anticommutation” of Supplementary Methods), regardless of the specifics of such action. Thus, dataqubit leakage is detectable via HMMs if this condition is satisfied. In particular, it is automatically satisfied if \({\mathcal{L}}\) is 1dimensional. We now consider ancillaqubit leakage. Clearly, ancillaqubit leakage detection is possible if the readout discriminates computational and leakage states perfectly or with high fidelity. If this is not the case, the required condition is that leaked ancilla qubits spread errors according to nontrivial leakage conditional phases, constituting signatures that can be used by an HMM. If even a limitedfidelity readout is available, it can still be used to strengthen this signal, as demonstrated in section “Ancillaqubit leakage detection”. An issue is the possibility of the readout to project onto a superposition of computational and leakage subspaces. In that case, the significance of ancillaqubit leakage is even unclear. However, for nontrivial leakage conditional phases, we expect a projection effect to the leakage subspace by a backaction of the stabilizer measurements, due to leakageinduced errors being detected onto other qubits, similarly to what observed for data qubits.
The capability to detect the time and location of a leakage event demonstrated by the HMMs could be used in conjunction with leakagereductions units (LRUs)^{37}. These are of fundamental importance for fault tolerance in the presence of leakage, since in ref. ^{40} a threshold for the surface code was not found if dedicated LRUs are not used to reduce the leakage lifetime beyond the one set by the relaxation time. While the latter constitutes a natural LRU by itself, we do not expect it to ensure a threshold since, together with a reduction in the leakage lifetime, it leads to an increase in the regular errors due to relaxation. A few options for LRUs in superconducting qubits are the swap scheme introduced in ref. ^{36}, or the use of the readout resonator to reset a leaked dataqubit into the computational subspace, similarly to refs. ^{53,54}. An alternative is to use the \(\left02\right\rangle \leftrightarrow \left11\right\rangle\) crossing to realize a “leakagereversal” gate that exchanges the leakage population in \(\left02\right\rangle\) to \(\left11\right\rangle\). An even simpler gate would be a singlequbit π pulse targeting the \(\left1\right\rangle \leftrightarrow \left2\right\rangle\) transition. All these schemes introduce a considerable overhead either in hardware (swap, readout resonator), or time (swap, readout resonator, leakagereversal gate), or they produce leakage when they are applied in the absence of it (leakagereversal gate, π pulse). Thus, all these schemes would benefit from the accurate identification of leakage, allowing for their targeted application, reducing the average circuit depth and minimizing the probability of inadvertently inducing leakage. We also note that the swap scheme, in conjunction with a good discrimination fidelity for \(\left2\right\rangle\), could be used for detecting leakage not only on ancilla qubits but also on data qubits by alternatively measuring them. Still, this scheme would require 5 extra qubits for Surface17 and would make the QECcycle time at least ~ 50% longer, together with more gate and idling errors, thus requiring much better physical error rates to achieve the same logical error rate in nearterm experiments.
We discuss how decoders might benefit from the detection of leakage. Modifications to MWPM decoders have been developed for the case when ancillaqubit leakage is directly measured^{17,40}, and when dataqubit leakage is measured in the LRU circuits^{40}. Further decoder modifications might be developed to achieve a lower logical error rate relative to a leakageunaware decoder, by taking into account the detected leakage and the probability of leakageinduced errors, as well as the stabilizer information that can still be extracted from the superchecks (see section “Leakageinduced anticommutation” of Supplementary Methods). In the latter case, a decoder could switch back and forth from standard surfacecode decoding to e.g., the partial subsystemcode decoding in refs. ^{49,50,51}. Given control of the leakage conditional phases, the performance of this decoder can be optimized by setting \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}=\pi\) and \({\phi }_{{\rm{flux}}}^{{\mathcal{L}}}=0\), minimizing the spread of phase errors on the neighboring data qubits by a leaked ancilla qubit, as well as the noise on the weight6 stabilizer extraction in the case of a leaked data qubit (see Supplementary Fig. 6 and section “Leakageinduced anticommutation” of Supplementary Methods). Given a moderate discrimination fidelity of the leaked state, this is not expected to compromise the detectability of leakage, as discussed in section “Ancillaqubit leakage detection”. At the same time, for such a decoder we expect the improvement in the logical error rate to be limited in the case of lowdistance codes such as Surface17, as singlequbit errors can result in a logical error. This is because leakage effectively reduces the code distance, either because a leaked data qubit is effectively removed from the code, or because of the fact that a leaked ancilla qubit is effectively disabled and in addition spreads errors onto neighboring data qubits. Large codes, for which leakage could be well tolerated (depending on the distribution of leakage events), cannot be studied with densitymatrix simulations, as done in this work for Surface17. However, the observed sharp projection of leakage and the probabilistic spread of errors justify the stochastic treatment of this error^{40}. Under the assumption that amplitude and phase damping can be modeled stochastically as well, we expect that the performance of decoders and LRUs in large surface codes can be well approximated in the presence of leakage.
Methods
Simulation protocol
For the Surface17 simulations we use the opensource densitymatrix simulation package quantumsim^{27}, available at “The quantumsim package can be found at https://quantumsim.gitlab.io/”. For decoding we use a MWPM decoder^{27}, for which the weights of the possible error pairings are extracted from Surface17 simulations via adaptive estimation^{48} without leakage (L_{1} = 0) and an otherwise identical error model (described in section “Error model and parameters”).
The logical performance of the surface code as a quantum memory is the ability to maintain a logical state over a number of QEC cycles. We focus on the Zbasis logical \({\left0\right\rangle }_{{\rm{L}}}\), but we have observed nearly identical performance for \({\left1\right\rangle }_{{\rm{L}}}\). We have not performed simulations for the Xbasis logical states \({\left\pm \right\rangle }_{{\rm{L}}}=\frac{1}{\sqrt{2}}\left({\left0\right\rangle }_{{\rm{L}}}\pm {\left1\right\rangle }_{{\rm{L}}}\right)\), as previous studies did not observe a significant difference between the two bases^{27}. The state \({\left0\right\rangle }_{{\rm{L}}}\) is prepared by initializing all data qubits in \(\left0\right\rangle\), after which it is maintained for a fixed number of QEC cycles (maximum 20 or 50 in this work), with the quantum circuit given in Fig. 8. The first QEC cycle projects the logical qubit into a simultaneous eigenstate of the Xtype and Ztype stabilizers^{28}, with the Z measurement outcomes being +1 in the absence of errors, while the X outcomes are random. The information about the occurred errors is provided by the stabilizer measurement outcomes from each QEC cycle, as well as by a Ztype stabilizer measurements obtained by measuring the data qubits in the computational basis at the end of the run. This information is provided to the MWPM decoder, which estimates the logical state at the end of the experiment by tracking the Pauli frame. For decoding, we assume that the \(\left2\right\rangle\) state is measured as a \(\left1\right\rangle\), as in most current experiments. In section “Ancillaqubit leakage detection” we considered the discrimination of \(\left2\right\rangle\) in readout, which can be used for leakage detection. While this information can be also useful for decoding, we do not consider a leakageaware decoder in this work.
The logical fidelity \({F}_{{\rm{L}}}\left(n\right)\) at a final QEC cycle n is defined as the probability that the decoder guess for the final logical state matches the initially prepared one. The logical error rate ε_{L} is extracted by fitting the decay as
where n_{0} is a fitting parameter (usually close to 0)^{27}.
Error model and parameters
In the simulations we include qubit decoherence via amplitudedamping and phasedamping channels. The time evolution of a single qubit is given by the Lindblad equation
where H is the transmon Hamiltonian
with a the annihilation operator, ω and α the qubit frequency and anharmonicity, respectively, and L_{i} the Lindblad operators. Assuming weak anharmonicity, we model amplitude damping for a qutrit by
The \(\left2\right\rangle\) lifetime is then characterized by a relaxation time T_{1}/2. Dephasing is described by
leading to a dephasing time T_{ϕ} between \(\left0\right\rangle\) (resp. \(\left1\right\rangle\)) and \(\left1\right\rangle\) (\(\left2\right\rangle\)), and to a dephasing time T_{ϕ}/2 between \(\left0\right\rangle\) and \(\left2\right\rangle\)^{9}. The Lindblad equation is integrated for a time t to obtain an amplitudedamping and phasedamping superoperator R_{↓,t}, expressed in the Pauli Transfer Matrix representation. For a gate R_{gate} of duration t_{gate}, decoherence is accounted by applying \({R}_{\downarrow ,{t}_{{\rm{gate}}}/2}{R}_{{\rm{gate}}}{R}_{\downarrow ,{t}_{{\rm{gate}}}/2}\). For idling periods of duration t_{idle}, \({R}_{\downarrow ,{t}_{{\rm{idle}}}}\) is applied.
For singlequbit gates we only include the amplitude and phase damping experienced over the duration t_{single} of the gate. These gates are assumed to not induce any leakage, motivated by the low leakage probabilities achieved^{8,44}, and to act trivially in the leakage subspace. For twoqubit gates, namely the CZ, we further consider the increased dephasing rate experienced by qubits when fluxed away from their sweetspot. In superconducting qubits, flux noise shows a typical power spectral density S_{f} = A/f, where f is the frequency and \(\sqrt{A}\) is a constant. In this work we consider \(\sqrt{A}=4\,\mu {\Phi }_{{\rm{0}}}\), where Φ_{0} is the flux quantum. Both lowfrequency and highfrequency components are contained in S_{f}, which we define relative to the CZ gate duration t_{CZ}. Away from the sweetspot frequency \({\omega }_{\max }\), a fluxtunable transmon has firstorder fluxnoise sensitivity \({D}_{\phi }=\frac{1}{2\pi }\left\frac{\partial \omega }{\partial \Phi }\right\). The highfrequency components are included as an increase in the dephasing rate Γ_{ϕ} = 1/T_{ϕ} (compared to the sweetspot), given by \({\Gamma }_{\phi }=2\pi \sqrt{\mathrm{ln}\,2A}{D}_{\phi }\)^{55}, while the lowfrequency components are not included due to the builtin echo effect of NetZero pulses^{9}. Highfrequency and midfrequency qubits are fluxed away to different frequencies, with dephasing rates computed with the given formula. Furthermore, during a few gates lowfrequency qubits are fluxed away to a “parking” frequency in order to avoid unwanted interactions^{46}. The computed dephasing times at the interaction point are given in Table 1. For the CZ gates, we include this increased dephasing during the time t_{int} spent at the interaction point, while for the phasecorrection pulses of duration t_{cor} we consider the same dephasing time as at the sweetspot. We do not include deviations in the ideal singlequbit phases of the CZ gate ϕ_{01} = 0 and ϕ_{10} = 0 and the twoqubit phase ϕ_{11} = π, under the assumption that gates are well tuned and that the lowfrequency components of the flux noise are echoed out^{9}.
We now consider the coherence of leakage in the CZ gates, which in the rotating frame of the qutrit is modeled as the exchanges
with L_{1} the leakage probability^{47}. The phase ϕ can lead to an interference effect between consecutive applications of the CZ gate across pairs of data and ancilla qubits. In terms of the full density matrix, the dynamics of Eqs. (17) and (18) leads to a coherent superposition of computational and leaked states
where \({\rho }^{{\mathcal{C}}}\) (resp. \({\rho }^{{\mathcal{L}}}\)) is the density matrix restricted to the computational (leakage) subspace, while ρ^{coh} are the offdiagonal elements between these subspaces. We observe that varying the phase ϕ does not have an effect on the dynamics of leakage or on the logical error rate. We attribute this to the fact that each ancilla qubit interacts with a given data qubit only once during a QEC cycle and it is measured at the end of it (and as such it is dephased). Thus, the ancillaqubit measurement between consecutive CZ gates between the same pair prevents any interference effect. Furthermore, setting ρ^{coh} = 0, does not affect the projection and signatures of leakage nor the logical error rate (at least for the logical state prepared in the Z basis), leading to an incoherent leakage model. We attribute this to the projection of leakage itself, which leaves the qubit into a mostly incoherent mixture between the computational and leakage subspaces. In the harmonic rotating frame, \(\left2\right\rangle\) is expected to acquire an additional phase during periods of idling, proportional to the anharmonicity. However, following the reasoning presented above, we also believe that this phase is irrelevant.
An incoherent leakage model offers significant computational advantage for densitymatrix simulations. For the case where ρ_{coh} ≠ 0, the size of the stored density matrix at any time is 4^{6} × 9^{4} (6 lowfrequency data qubits, 3 highfrequency data qutrits plus 1 ancilla qutrit currently performing the parity check). Setting ρ_{coh} = 0 reduces the size of the density matrix to 4^{6} × 5^{4}, since for each qutrit only the \(\left2\right\rangle \left\langle 2\right\) matrix element is stored in addition to the computational subspace. Thus, for the simulations in this work we rely on an incoherent model of leakage.
Measurements of duration t_{m} are modeled by applying \({R}_{\downarrow ,{t}_{{\rm{m}}}/2}{R}_{{\rm{proj}}}{R}_{\downarrow ,{t}_{{\rm{m}}}/2}\), where \({R}_{\downarrow ,{t}_{{\rm{m}}}/2}\) are periods of amplitude and phase damping and R_{proj} is a projection operator. This projector is chosen according to the Born rule and leaves the ancilla qubit in either \(\left0\right\rangle\), \(\left1\right\rangle\), or \(\left2\right\rangle\). We do not include any declaration errors, which are defined as the measurement outcome being different from the state of the ancilla qubit immediately after the projection. Furthermore, we do not include any measurementinduced leakage, any decrease in the relaxation time via the Purcell effect or any measurementinduced dephasing via broadband sources. We do not consider nonideal projective measurements (leaving the ancilla in a superposition of the computational states) due to the increased size of the stored density matrix that this would lead to.
HMM formalism
An HMM describes the time evolution of a set \(S=\left\{s\right\}\) of not directly observable states s (i.e., “hidden”), over a sequence of independent observables \(o=\left\{{o}_{i}\right\}\). At each time step n the states undergo a Markovian transition, such that the probability \({p}^{s}\left[n\right]\) of the system being in the state s is determined by the previous distribution \({p}^{s}\left[n1\right]\) over all s ∈ S. These transitions can be expressed via the transition matrix A, whose elements are the conditional probabilities \({A}_{s,s^{\prime} }:= {\mathbb{P}}{({s}[{n}]={s} {s}[{n}{1}]={s}^{\prime} )}\). A set of observables is then generated with statedependent probabilities \({{B}_{{o}_{i}[{n}],{s}}}:= {\mathbb{P}}{({o}_{i}[{n}]={o}_{i} {s}[{n}]={s})}\). Inverting this problem, the inference of the posterior state probabilities \({p}^{s}\left[n\right]\) from the realized observables is possible via
where \({p}_{{\rm{prior}}}^{s}\left[n\right]\) is the prior probability
We define \({B}_{o\left[n\right],s}={\prod }_{i}{B}_{{o}_{i}\left[n\right],s}\), which for discrete o_{i} constitute the entries of the emission matrix B. In addition to the transition and emission probabilities, the initial state probabilities \({p}^{s}\left[n=0\right]\) are needed for the computation of the evolution.
In the context of leakage detection, we consider only two hidden states, \(S=\left\{{\mathcal{C}},{\mathcal{L}}\right\}\), namely whether the qubit is in the computational (\({\mathcal{C}}\)) or the leakage subspace (\({\mathcal{L}}\)). The transition matrix is parameterized in terms of the leakage and seepage probabilities per QEC cycle. The leakage probability is estimated as \({\Gamma }_{{\mathcal{C}}\to {\mathcal{L}}}\approx {N}_{{\rm{flux}}}{L}_{1}\) (for low L_{1}), where N_{flux} is in how many CZ gates the qubit is fluxed during a QEC cycle and L_{1} is the leakage probability per CZ gate. The seepage probability is estimated by \({\Gamma }_{{\mathcal{L}}\to {\mathcal{C}}}\approx {N}_{{\rm{flux}}}{L}_{2}+\left(1{e}^{\frac{{t}_{{\rm{c}}}}{{T}_{1}/2}}\right)\), where t_{c} is the QEC cycle duration and T_{1} the relaxation time (see Table 1), while L_{2} is the seepage contribution from the gate, where L_{2} = 2L_{1} due to the dimensionality ratio between \({\mathcal{C}}\) and \({\mathcal{L}}\) for a qubitqutrit pair^{47}. The transition matrix A is then given by
We assume that all qubits are initialized in \({\mathcal{C}}\), which defines the initial state distribution \({p}^{{\mathcal{C}}}\left[n=0\right]=1\) used by the HMMs.
The HMMs consider the defects \(d\left({Q}_{i}\right)\equiv {d}_{i}\) on the neighboring ancilla qubits Q_{i} at each QEC cycle, occurring with probability \({p}^{{d}_{i}}\), as the observables for leakage detection. Explicitly, the emission probabilities are parameterized in terms of the conditional probabilities \({{B}_{{d}_{i}[{n}],{s}}}={\mathbb{P}}{({d}_{i}[{n}] {s})}\) of observing a defect when the modeled qubit is in \(s={\mathcal{C}}\) or \(s={\mathcal{L}}\). We extract \({B}_{{d}_{i}\left[n\right],{\mathcal{C}}}\) directly from simulation, by averaging over all runs and all QEC cycles, motivated by the possible extraction of this probability in experiment. While this includes runs when the modeled qubit was leaked, we observe no significant differences in the HMM performance when we instead postselect out these periods of leakage, which we attribute to the low L_{1} per CZ gate. We extract \({B}_{{d}_{i}\left[n\right],{\mathcal{L}}}\) from simulation over the QEC cycles when the leakage probability \({p}_{{\rm{DM}}}^{{\mathcal{L}}}\left({Q}_{i}\right)\) as observed from the density matrix is above a threshold of \({p}_{{\rm{th}}}^{{\mathcal{L}}}=0.5\). In the case of ancillaqubit leakage, \({B}_{{d}_{i}\left[n\right],{\mathcal{L}}}\) depends on the values of the leakage conditional phases \({\phi }_{{\rm{stat}}}^{{\mathcal{L}}}\) and \({\phi }_{{\rm{flus}}}^{{\mathcal{L}}}\). Thus, in the case of randomized leakage conditional phases, the HMMs are parameterized by the average \({B}_{{d}_{i}\left[n\right],{\mathcal{L}}}\). In the case of dataqubit leakage, the extracted \({B}_{{d}_{i}\left[n\right],{\mathcal{L}}}\) is ≈0.5 regardless of the leakage conditional phases, as expected from the anticommuting stabilizers (see section "Projection and signatures of leakage").
For ancillaqubit leakage detection, the analog measurement outcome I_{m} can be additionally considered as an observable, in which case \(o=\left\{{d}_{i},{I}_{m}\right\}\). In this case, the statedependent probability is further parametrized by \({B}_{{I}_{m}}\left[n\right],{\mathcal{C}}={\mathbb{P}}\left({I}_{m}\left[{n}\right] {\mathcal{C}}\right)={{\mathcal{N}}_{0}}\left({I}_{m}\left[{n}\right]\right)+{{\mathcal{N}}}_{1}\left({I}_{m}\left[{n}\right]\right)\) and by \({B}_{{I}_{m}}\left[n\right],{\mathcal{L}}={\mathbb{P}}\left({I}_{m}\left[{n}\right] {\mathcal{L}}\right)={\mathcal{N}}_{2}\left({I}_{m}\left[{n}\right]\right)\), where \({\mathcal{N}}_{i}\) are the Gaussian distributions of the analog responses in the IQ plane, projected along a rotated inphase axis I, following the same treatment as in section “Transmon measurements in experiment” of Supplementary Methods.
Data availability
The data that support the plots within this paper and other findings of this study are available from the corresponding author (b.m.varbanov@tudelft.nl) upon request.
Code availability
The computer code used to generate these results is available from the corresponding author (b.m.varbanov@tudelft.nl) upon request.
References
C’orcoles, A. D. et al. Challenges and opportunities of nearterm quantum computing systems. Proc. IEEE 108, 1338–1352 (2020).
Arute, F. et al. Quantum supremacy using a programmable superconducting processor. Nature 574, 505–510 (2019).
Otterbach, J. S. et al. Unsupervised Machine Learning on a Hybrid Quantum Computer. Preprint at https://arxiv.org/abs/1712.05771 (2017).
Landsman, K. A. et al. Twoqubit entangling gates within arbitrarily long chains of trapped ions. Phys. Rev. A 100, 022332 (2019).
Barends, R. et al. Superconducting quantum circuits at the surface code threshold for fault tolerance. Nature 508, 500–503 (2014).
Barends, R. et al. Diabatic gates for frequencytunable superconducting qubits. Phys. Rev. Lett. 123, 210501 (2019).
Rol, M. A. et al. Restless tuneup of highfidelity qubit gates. Phys. Rev. Appl. 7, 041001 (2017).
Chen, Z. et al. Measuring and suppressing quantum state leakage in a superconducting qubit. Phys. Rev. Lett. 116, 020501 (2016).
Rol, M. A. et al. Fast, highfidelity conditionalphase gate exploiting leakage interference in weakly anharmonic superconducting qubits. Phys. Rev. Lett. 123, 120502 (2019).
Foxen, B. et al. Demonstrating a continuous set of twoqubit gates for nearterm quantum algorithms. Phys. Rev. Lett. 125, 120504 (2020).
Hong, S. S. et al. Demonstration of a parametrically activated entangling gate protected from flux noise. Phys. Rev. A 101, 012302 (2020).
Sheldon, S., Magesan, E., Chow, J. M. & Gambetta, J. M. Procedure for systematically tuning up crosstalk in the crossresonance gate. Phys. Rev. A 93, 060302 (2016).
Harty, T. P. et al. Highfidelity preparation, gates, memory, and readout of a trappedion quantum bit. Phys. Rev. Lett. 113, 220501 (2014).
Jeffrey, E. et al. Fast accurate state measurement with superconducting qubits. Phys. Rev. Lett. 112, 190504 (2014).
Bultink, C. C. et al. Active resonator reset in the nonlinear dispersive regime of circuit QED. Phys. Rev. Appl. 6, 034008 (2016).
Heinsoo, J. et al. Rapid highfidelity multiplexed readout of superconducting qubits. Phys. Rev. Appl. 10, 034040 (2018).
Kelly, J. et al. State preservation by repetitive error detection in a superconducting quantum circuit. Nature 519, 66–69 (2015).
Ristè, D. et al. Detecting bitflip errors in a logical qubit using stabilizer measurements. Nat. Commun. 6, 6983 (2015).
Takita, M. et al. Demonstration of weightfour parity measurements in the surface code architecture. Phys. Rev. Lett. 117, 210505 (2016).
Bultink, C. C. et al. Protecting quantum entanglement from leakage and qubit errors via repetitive parity measurements. Sci. Adv. 6, eaay3050 (2020).
Andersen, C. K. et al. Entanglement stabilization using ancillabased parity detection and realtime feedback in superconducting circuits. npj Quantum Inf. 5, 69 (2019).
Negnevitsky, V. et al. Repeated multiqubit readout and feedback with a mixedspecies trappedion register. Nature 563, 527–531 (2018).
Andersen, C. K. et al. Repeated quantum error detection in a surface code. Nat. Phys. 16, 875–880 (2020).
Boixo, S. et al. Characterizing quantum supremacy in nearterm devices. Nat. Phys. 14, 595–600 (2018).
Neill, C. et al. A blueprint for demonstrating quantum supremacy with superconducting qubits. Science 360, 195–199 (2018).
Bravyi, S., Gosset, D. & König, R. Quantum advantage with shallow circuits. Science 362, 308–311 (2018).
O’Brien, T., Tarasinski, B. & DiCarlo, L. Densitymatrix simulation of small surface codes under current and projected experimental noise. npj Quantum Inf. 3, 39 (2017).
Fowler, A. G., Mariantoni, M., Martinis, J. M. & Cleland, A. N. Surface codes: towards practical largescale quantum computation. Phys. Rev. A 86, 032324 (2012).
Chow, J. M. et al. Simple allmicrowave entangling gate for fixedfrequency superconducting qubits. Phys. Rev. Lett. 107, 080502 (2011).
Tripathi, V., Khezri, M. & Korotkov, A. N. Operation and intrinsic error budget of a twoqubit crossresonance gate. Phys. Rev. A 100, 012301 (2019).
Strauch, F. W. et al. Quantum logic gates for coupled superconducting phase qubits. Phys. Rev. Lett. 91, 167005 (2003).
DiCarlo, L. et al. Demonstration of twoqubit algorithms with a superconducting quantum processor. Nature 460, 240–244 (2009).
Martinis, J. M. & Geller, M. R. Fast adiabatic qubit gates using only σ_{z} control. Phys. Rev. A 90, 022307 (2014).
Caldwell, S. A. et al. Parametrically activated entangling gates using transmon qubits. Phys. Rev. Appl. 10, 034050 (2018).
Ghosh, J. et al. Highfidelity controlledσ^{Z} gate for resonatorbased superconducting quantum computers. Phys. Rev. A 87, 022309 (2013).
Ghosh, J., Fowler, A. G., Martinis, J. M. & Geller, M. R. Understanding the effects of leakage in superconducting quantumerrordetection circuits. Phys. Rev. A 88, 062329 (2013).
Aliferis, P. & Terhal, B. M. Faulttolerant quantum computation for local leakage faults. Quantum Inf. Comp. 7, 139–156 (2007).
Fowler, A. G. Coping with qubit leakage in topological codes. Phys. Rev. A 88, 042308 (2013).
Ghosh, J. & Fowler, A. G. Leakageresilient approach to faulttolerant quantum computing with superconducting elements. Phys. Rev. A 91, 020302 (2015).
Suchara, M., Cross, A. W. & Gambetta, J. M. Leakage suppression in the toric code. Quantum Inf. Comp. 15, 997–1016 (2015).
Brown, N. C. & Brown, K. R. Comparing zeeman qubits to hyperfine qubits in the context of the surface code: ^{174}Yb^{+} and ^{171}Yb^{+}. Phys. Rev. A 97, 052301 (2018).
Brown, N. C., Newman, M. & Brown, K. R. Handling leakage with subsystem codes. N. J. Phys. 21, 073055 (2019).
Brown, N. C. & Brown, K. R. Leakage mitigation for quantum error correction using a mixed qubit scheme. Phys. Rev. A 100, 032325 (2019).
Motzoi, F., Gambetta, J. M., Rebentrost, P. & Wilhelm, F. K. Simple pulses for elimination of leakage in weakly nonlinear qubits. Phys. Rev. Lett. 103, 110501 (2009).
Hayes, D. et al. Eliminating leakage errors in hyperfine qubits. Phys. Rev. Lett. 124, 170501 (2020).
Versluis, R. et al. Scalable quantum circuit and control for a superconducting surface code. Phys. Rev. Appl. 8, 034021 (2017).
Wood, C. J. & Gambetta, J. M. Quantification and characterization of leakage errors. Phys. Rev. A 97, 032306 (2018).
Spitz, S. T., Tarasinski, B., Beenakker, C. W. J. & O’Brien, T. E. Adaptive weight estimator for quantum error correction in a timedependent environment. Adv. Quantum Technol. 1, 1800012 (2018).
Auger, J. M., Anwar, H., GimenoSegovia, M., Stace, T. M. & Browne, D. E. Faulttolerance thresholds for the surface code with fabrication errors. Phys. Rev. A 96, 042316 (2017).
Nagayama, S., Fowler, A. G., Horsman, D., Devitt, S. J. & Meter, R. V. Surface code error correction on a defective lattice. N. J. Phys. 19, 023050 (2017).
Stace, T. M. & Barrett, S. D. Error correction and degeneracy in surface codes suffering loss. Phys. Rev. A 81, 022317 (2010).
Bravyi, S., DuclosCianci, G., Poulin, D. & Suchara, M. Subsystem surface codes with threequbit check operators. Quantum Inf. Comp. 13, 963–985 (2013).
Egger, D. et al. Pulsed reset protocol for fixedfrequency superconducting qubits. Phys. Rev. Appl. 10, 044030 (2018).
Magnard, P. et al. Fast and unconditional allmicrowave reset of a superconducting qubit. Phys. Rev. Lett. 121, 060502 (2018).
Luthi, F. et al. Evolution of nanowire transmon qubits and their coherence in a magnetic field. Phys. Rev. Lett. 120, 100502 (2018).
Acknowledgements
We thank M.A. Rol for useful discussions and C.C. Bultink for providing us readout data from experiment. B.M.V., F.B., and B.M.Te. are supported by ERC grant EQEC No. 682726, B.M.Ta., V.P.O., and L.D.C. by the Office of the Director of National Intelligence (ODNI) and Intelligence Advanced Research Projects Activity (IARPA), via the U.S. Army Research Office grant W911NF1610071, T.E.O. by the Netherlands Organization for Scientific Research (NWO/OCW) under the NanoFront and StartImpuls programs, and by Shell Global Solutions BV. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of the ODNI, IARPA, or the U.S. Government. Simulations were performed with computing resources granted by RWTH Aachen University under project rwth0566.
Author information
Affiliations
Contributions
All authors contributed to the development of the theoretical concepts presented. B.M.Ta. and V.P.O. extended the quantumsim simulation software to multilevel systems. B.M.V. performed the densitymatrix simulations, under supervision of B.M.Ta., and the HMM analysis, with input from T.E.O. F.B. performed fulltrajectory simulations and theoretical derivations. B.M.V. and F.B. contributed equally to the writing of the manuscript with feedback from all authors. B.M.Te. and L.D.C. supervised the project.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Supplementary information
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Varbanov, B.M., Battistel, F., Tarasinski, B.M. et al. Leakage detection for a transmonbased surface code. npj Quantum Inf 6, 102 (2020). https://doi.org/10.1038/s4153402000330w
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s4153402000330w
Further reading

Logicalqubit operations in an errordetecting surface code
Nature Physics (2022)

Variational preparation of finitetemperature states on a quantum computer
npj Quantum Information (2021)

Removing leakageinduced correlated errors in superconducting quantum error correction
Nature Communications (2021)

Experimental deterministic correction of qubit loss
Nature (2020)