alphaFeedback

WorksPhysics and Astronomy

Fast verification of fault tolerant magic state preparation circuits with the CNOT + T gate set

AI contributions
Not recorded for this paper
View details

Abstract

Magic state preparation is often among the most expensive operations in a fault tolerant quantum computation. One obstacle to coming up with better magic state preparation circuits lies in verifying their fault tolerance properties, as it is difficult to verify either by hand or in software that a very large number of combinations of faults do not give rise to high-weight or logical errors, especially in a non-Clifford circuit. In this work, we propose the use of the CNOT + T gate set to fault-tolerantly prepare a large class of magic states. We consider the propagation of Pauli faults within CNOT + T circuits and derive properties similar to those of Pauli faults within Clifford circuits, with a view to verifying fault tolerance as efficiently as possible. We present Comb, a library that can verify the fault tolerance of CNOT + T magic state preparation circuits, and demonstrate its use in verifying the fault tolerance of distance three and distance five magic state preparation circuits in minutes on a laptop. We present a distance five magic state preparation circuit that was discovered using Comb. As an independent confirmation of Comb's correctness we compare its findings to circuit-level noisy simulations for several magic state preparation circuits.

Introduction

Fault-tolerant quantum computation is now an experimental reality with much recent work demonstrating some or all of the required ingredients to perform a universal computation, such as state preparation [1], single qubit gates [1, 2] and entangling gates [3]. However, since the Eastin-Knill theorem [4] states that it is not possible to carry out a universal gate set transversally, some of these operations must consume considerable quantum resources, which leads to a performance bottleneck in fault tolerant quantum computing.

One popular approach is to choose a code in which the Clifford group can be implemented transversally, and carry out a single non-Clifford gate such as T or CCZ by injecting a magic state into the code, which is sufficient for universality [5]. When magic states [5] were introduced, it was proposed to prepare magic states fault tolerantly by means of magic state distillation, in which multiple noisy copies of magic states are prepared and then ‘distilled’ to produce a single magic state with a lower error rate. Since the introduction of magic state distillation [5], many improvements and alternative methods have been proposed [6, 7, 8], leading to lower estimates of the resources that these methods consume, in some cases giving improvements in the resources consumed of orders of magnitude. These results have greatly improved the outlook of fault tolerant quantum computing.

However, these methods mostly concern magic state preparation in the asymptotic regime, often limited to the surface code. In the near term, one is often interested in fixed codes of small size, such as small instances of the colour code [9], as these have high rates compared to surface codes of similar size, allowing for more interesting demonstrations to be performed with them on contemporary quantum computers [1, 3]. With such codes, the prospect exists of preparing the magic states directly without distillation, which is to say without the requirement of preparing several magic states at once. Preparing magic states this way naturally reduces the spatial overhead associated with magic state preparation [10, 11, 12] and, in some cases, makes the number of gates required comparable to that of syndrome extraction [13].

It is challenging to construct circuits that prepare magic states fault tolerantly, owing to the fact that within non-Clifford circuits, Pauli faults do not necessarily result in output errors that are also Pauli, which leads to a more complicated analysis than is the case for Clifford circuits [14].

One popular approach is to ‘Cliffordise’ the circuit, which is to say replacing T gates with S gates [12, 14, 15]. While this can lead to a great reduction in computational effort when simulating, it can potentially lead us to miss problematic faults and come to the wrong conclusion about a circuit’s fault tolerance, as we discuss in Appendix A.

Additionally, it is hard to reason analytically and computationally about the fault tolerance of circuits beyond distance three owing to the potentially very large number of combinations of faults in a circuit, each of which must be checked so that it does not cause an error that violates the requirements of fault tolerance.

In this work, we aim to make this task easier by noting that the CNOT + T gate set is capable of preparing a wide range of magic states fault-tolerantly, and showing that it is easier to verify the fault tolerance of circuits that are restricted to the CNOT + T gate set than those that are Clifford + T. We develop a library called Comb that verifies the fault tolerance of a magic state preparation circuit by iterating over the set of combinations of faults that appear in such circuits as efficiently as possible. We illustrate the workflow of checking the fault-tolerance of a CNOT + T circuit in Figure 1. By verifying the fault tolerance of a magic state preparation circuit quickly in software, we aim to facilitate the iterative design of such circuits, which is important as few (if any) analytic or software tools satisfying a similar function exist for any gate set that is not Clifford.

Workflow for checking the fault-tolerance of a CNOT + T circuit

Figure 1. Workflow for checking the fault-tolerance of a CNOT + T circuit. (1) We begin by generating a complete set of Pauli circuit faults. (2) Each Pauli fault is propagated through the circuit. In general this will produce errors that are linear combinations of Paulis, however because of the structure of the CNOT + T gate set these errors remain efficiently describable as Diagonal Clifford and Pauli (DCP) errors. We show an example of propagating a Pauli fault into a DCP error in a CNOT + T circuit for fault-tolerantly preparing T∣+⟩T|+\rangle in the ⟦7,1,3⟧\llbracket7,1,3\rrbracket code. Post-selecting on flag measurements detects any Pauli errors that anti-commute with the measurement basis. However, for DCP errors some of their Pauli components can anti-commute with the measurement basis while others commute with it and so can persist after post-selection. This situation is illustrated here: post-selecting on the measurements of either qubits 10 and 14 would detect this error, however if we only post-selected on qubit 8 part of the error would not be caught. (3) To check the circuit is fault-tolerant Comb considers all combinations of s≤⌊d/2⌋s \le\lfloor d/2\rfloor faults, where dd is the distance of the code, and checks that none of the propagated errors contain an undetected Pauli string of weight greater than ss. By carefully exploiting the structure of DCP errors we avoid the exponential memory cost of naively expanding them into Pauli strings.

In Section II, we will define some mathematical preliminaries. In § 1.2, we review the properties of the CNOT + T gate set with a view to preparing magic states fault-tolerantly, and discuss how faults propagate through circuits composed of this gate set. In Section IV, we discuss in detail how to computationally verify the fault tolerance of CNOT + T circuits. In § 1.4, we demonstrate the performance of Comb, a library that implements the results of Section IV, on a test suite of circuits, and show that it is feasible to verify the fault tolerance of magic state preparation circuits of reasonable size, including a novel circuit that was discovered using Comb which prepares a magic state fault-tolerantly to distance five. Additionally, we simulate some of the test suite circuits with circuit-level noise and check that these simulations are in agreement with Comb.

Preliminaries

We will consider the Pauli group that contains the Pauli matrices X,Y,ZX,Y,Z together with phase,

P=⟨i,X,Z⟩,(1)\mathcal{P} = \langle i,X,Z\rangle, \tag*{(1)}

and the Pauli group on nn qubits Pn\mathcal{P}_n to be the nn-fold product

Pn=⟨i,X,Z⟩⊗n(2)\mathcal{P}_n = \langle i,X,Z\rangle^{\otimes n} \tag*{(2)}

of the Pauli group. Subsequently, we will often use the term ‘Pauli’ to refer to an element of this Pauli group Pn\mathcal{P}_n on nn qubits, and not just elements of the single qubit group P\mathcal{P}. We will refer to Paulis as phaseless or lacking phase if they do not possess a leading non-trivial phase when written out as products of XX, YY, ZZ and phase. For example, the Pauli XZXZ is phaseless while the Pauli iXYiXY is not. We also define Paulis of XX type, or XX Paulis for short, to be those that are products of the identity or the Pauli XX, together with phase,

PnX=⟨i,X⟩⊗n.(3)\mathcal{P}_n^X = \langle i,X\rangle^{\otimes n}. \tag*{(3)}

We define Paulis of ZZ type similarly.

Since Y=iXZY=iXZ, we note that it is always possible to write a Pauli PP as a product of a Pauli of XX type PXP^X and a Pauli of ZZ type PZP^Z,

P=PXPZ,(4)P=P^X P^Z, \tag*{(4)}

a decomposition that we will sometimes make use of. It is possible to assume that either PXP^X or PZP^Z is phaseless, or reverse their order in the product, without loss of generality. We will quotient out phase in defining the Clifford group Cn\mathcal{C}_n,

Cn={U:U†PnU=Pn}/{eiθ1n:θ∈R},(5)\mathcal{C}_n=\{U:U^\dagger P_nU=P_n\}/\{e^{i\theta}1_n:\theta\in\mathbb{R}\}, \tag*{(5)}

so that in particular it is finite, and elements of it can be stored in memory on a computer. We refer the interested reader to [16] for a treatment of how to store and manipulate Paulis and Cliffords computationally.

We will also define the S=diag⁡(1,i)S=\operatorname{diag}(1,i) and T=diag⁡(1,eiπ/4)T=\operatorname{diag}(1,e^{i\pi/4}) gates to avoid confusion with definitions in other works. We note that S=T2S=T^2 and T†=T7T^\dagger=T^7, meaning that SS, TT and their inverses are all generated by TT.

We will also make use of the CNOT gate, which is

CNOT⁡=∣0⟩⟨0∣⊗1+∣1⟩⟨1∣⊗X,(6)\operatorname{CNOT}=|0\rangle\langle0|\otimes1+|1\rangle\langle1|\otimes X, \tag*{(6)}

adding subscripts when appropriate to make clear what the indices of the control and target qubits are. When we refer to measurements, they will be assumed to be Pauli measurements in either the XX or the ZZ basis, making clear which one is intended when necessary.

The CNOT + T gate set

Applicability

The CNOT + T gate set is already widely used to prepare magic states fault-tolerantly though this fact is rarely noted explicitly. Example are the flagged fault-tolerant construction of [10], magic state cultivation [12] and distillation [17]. It also has been studied in the context of reducing the T count of a logical circuit [18], and polynomial-time simulation [19].

An illustration of fault tolerantly preparing a magic states in the CNOT + T gate set is shown schematically in Figure 2, based on the flagged fault-tolerant construction of [10]. The sketched circuit prepares a magic state T‾∣+⟩\overline{T}|+\rangle in an [[n,1,d]][[n,1,d]] code. In this circuit, as in all CNOT + T circuits that we consider in this paper, qubits are initialised in either the XX or ZZ eigenstates ∣0⟩|0\rangle and ∣+⟩|+\rangle and any measurements that are postselected on are made in the XX or ZZ bases.

Schematic illustration of a fault-tolerant $\overline{T}|+\rangle$ magic state preparation circuit

Figure 2. Schematic illustration of a fault-tolerant T‾∣+⟩\overline{T}|+\rangle magic state preparation circuit in the CNOT + T gate set for an [[n,1,d]][[n,1,d]] code, based on the construction of [10, 11]. An initial encoder circuit non-fault-tolerantly encodes the physical T∣+⟩T|+\rangle state into the code space. This is followed by ⌊d/2⌋\lfloor d/2\rfloor rounds of measurements of the logical stabiliser e−iπ/4SXe^{-i\pi/4 S_X} and the stabiliser generators of the code SiS_i. We call this operator the logical stabiliser in the sense that (e−iπ/4SX)T∣+⟩=T∣+⟩(e^{-i\pi/4 S_X})T|+\rangle=T|+\rangle. The outcomes of these measurements will be post-selected on, meaning if any of them return a (−1)(-1) the state preparation is rejected. To make these measurements fault-tolerant they will typically be flagged, indicated by the hatched boxes involving additional flag ancillas. Qubits are initialised and measured in either the XX or ZZ basis, all other gates are CNOT or T.

DCP operators

We now state and prove some results concerning the propagation of faults through magic state preparation circuits, which will be useful in verifying the fault tolerance of such circuits.

The CNOT + T gate set preserves a set of operators under conjugation. We define a Diagonal Clifford and Pauli (DCP) operator CDCPC_{\mathrm{DCP}} to be the product of a diagonal Clifford CDC_{\mathrm{D}} and a Pauli PP,

CDCP=CDP.(7)C_{\mathrm{DCP}}=C_{\mathrm{D}}P. \tag*{(7)}

We will assume, without loss of generality, that the Pauli PP is of XX type, as any ZZ Pauli can be absorbed into the definition of the diagonal Clifford CDC_{\mathrm{D}}. We can write the diagonal Clifford CDC_{\mathrm{D}} as the exponential of a linear combination of Paulis of ZZ type DiD_i, which are diagonal, so that

CDCP=exp⁡(iπ4∑l=1rDl)P.(8)C_{\mathrm{DCP}}=\exp\left(\frac{i\pi}{4}\sum_{l=1}^{r}D_l\right)P. \tag*{(8)}

Expanding the exponential would yield an expression for the DCP error as a sum of Pauli strings.

Under conjugation by CNOT or T, any DCP operator is mapped to another DCP operator. Using Equation (8) we see that conjugating CDCPC_{\mathrm{DCP}} by CNOTi,jCNOT_{i,j} to obtain CDCP′C'_{\mathrm{DCP}} gives

CDCP′=exp⁡(iπ4∑l=1rCNOTi,jDlCNOTi,j)⋅CNOTi,jPCNOTi,j.(9)C'_{\mathrm{DCP}}=\exp\left(\frac{i\pi}{4}\sum_{l=1}^{r}CNOT_{i,j}D_lCNOT_{i,j}\right)\cdot CNOT_{i,j}PCNOT_{i,j}. \tag*{(9)}

As the CNOT gate preserves the X or Z type of a Pauli under conjugation, the terms CNOTi,jDlCNOTi,jCNOT_{i,j}D_lCNOT_{i,j} that appear in the sum in the exponential are also Paulis of Z type. Therefore, the resulting operator CDCP′C'_{\mathrm{DCP}} is also DCP.

Now, conjugating CDCPC_{\mathrm{DCP}} by a T gate TiT_i to obtain CDCP′C'_{\mathrm{DCP}} gives that

CDCP′=exp⁡(iπ4∑l=1rDl)TiPTi†,(10)C'_{\mathrm{DCP}}=\exp\left(\frac{i\pi}{4}\sum_{l=1}^{r}D_l\right)T_iPT_i^\dagger, \tag*{(10)}

where we have used the fact that diagonal operators commute in order to push the TiT_i gate through the exponential. If the Pauli PP does not have support on the ii-th qubit, then it will commute with TiT_i and so CDCP=CDCP′C_{\mathrm{DCP}}=C'_{\mathrm{DCP}}, meaning that CDCP′C'_{\mathrm{DCP}} is also DCP. If the Pauli PP does have support on the ii-th qubit, then

TiPTi†=e−iπ4SiP,(11)T_iPT_i^\dagger=e^{-\frac{i\pi}{4}}S_iP, \tag*{(11)}

which again means that CDCP′C'_{\mathrm{DCP}} is DCP, as e−iπ4Sie^{-\frac{i\pi}{4}}S_i is a diagonal Clifford. Since CNOT and T gates take DCP operators to DCP operators under conjugation, so will any product of them.

The DCP operators of fixed size nn form a group, and they contain the nn-qubit Paulis PnP_n as a subgroup. They play the same role with respect to the CNOT + T gate set that the Pauli group does for the Clifford gate set, as both are preserved under conjugation by the respective gate set. Since Paulis are DCP, and CNOT + T preserves DCP operators, it follows that Pauli faults in a CNOT + T circuit will propagate to output errors which are DCP, which hints at the practical importance of the DCP group for fault tolerant analysis.

However, for the purposes of verifying fault tolerance, it is not the group-theoretic properties of the DCP group that are most relevant, but rather the representational properties of the group. As the DCP group lies inside the Clifford group, it can be represented up to phase in matrix form using O(n2)O(n^2) bits [16], and multiplication of DCP operators is roughly equivalent to multiplication of these matrices.

This is not much less efficient than the Pauli group, for which Paulis are often represented up to phase with 2n2n bits, and multiplication of Paulis is equivalent to addition mod 2, which is of complexity O(n)O(n). The efficient storage and manipulation of DCP operators will also prove useful for fault tolerant analysis.

The discussion so far neglects the role of phase. If one wanted to take into account the phases that result from multiplying Cliffords, this representation would not suffice, and the analysis would be more complicated [20]. However, when analysing the fault tolerance of a circuit, the phase of an output error can be neglected altogether as it cannot change the weight of the error or whether it is detected, so we will settle for representing DCP operators in the manner discussed.

Finally, we note that DCP operators are an example of Pauli-Square-Root Clifford (PSC) operators, also introduced in the context of magic state preparation [14]. We note that DCP operators naturally arise by considering Paulis propagating within CNOT + T circuits, whereas the more general class of PSC operators results from propagating Paulis through Clifford + T circuits that satisfy some technical conditions; for example, the only controlled-UU gates that can be performed must have that U2=1U^2=1 [14]. We posit that our working within the CNOT + T gate set precludes the need to explicitly derive and work around constraints on the circuits we must consider, while retaining sufficient expressive power to prepare magic states for many codes.

Verifying fault tolerance

Definition of fault tolerance

We refer to fault-tolerance in the sense given by Gottesman [21]. We decompose a circuit that prepares some state in terms of its circuit components. Any of these circuit components, which include bare wires, measurements, state preparation, and unitaries may fail, in which case a fault may occur immediately after the circuit component on the qubits where it acts. A combination of faults will cause some corresponding error at the output.

A CNOT + T state preparation circuit is fault-tolerant to distance dd if it obeys the condition:

(*) any combination of s≤t=⌊d2⌋s \leq t=\left\lfloor\frac{d}{2}\right\rfloor faults produces an output error that is either detected by a pattern of unexpected ancilla measurements or is a sum of Pauli strings each of weight at most ss.

The weight of the Pauli strings is taken modulo multiplication by the stabiliser group of the code that the state belongs to. This is because multiplying an error by a stabiliser gives an equivalent error which has precisely the same effect on the state. Consequently, an error that appears to be of high weight may be equivalent to one of weight less than or equal to ss upon multiplication by a stabiliser, and such errors are not problematic from the perspective of fault tolerance.

It is common to refer to combinations of faults, or the corresponding output errors that they give rise to, as ‘good’ if they satisfy this condition and ‘bad’ otherwise.

Only if all fault combinations are good can a circuit be fault-tolerant, and the existence of a single bad fault combination is sufficient to break fault tolerance.

The condition (⋆\star) extends the typical definition of fault-tolerance for Pauli errors to DCP errors, whose weight is less straightforward to define. It ensures that good output errors are still correctable, since the individual components of the error are correctable and hence by linearity the total output error is correctable.

In Appendix B we show that this definition is equivalent to the more traditional criteria that appear in e.g. [21].

Without loss of generality, we will henceforth take all faults to be Pauli, a common assumption which has the advantage that the set of possible faults associated to each circuit component becomes finite. These Pauli faults will propagate to DCP output errors.

It is apparent from the definition of fault tolerance that the number of combinations of faults that must be considered may be very large. Assuming that there are MM circuit components, and that each one has at least ff faults associated with it, then for each ss one must check that at least (Ms)fs=Θ(Msfs)\binom{M}{s}f^{s} = \Theta(M^{s}f^{s}) combinations of ss faults from distinct locations are good. This quantity grows very quickly with MM even if ff and ss are not too large.

Algorithm

We propose to verify fault tolerance simply by checking the definition, which is to say, given a circuit, we loop over all possible combinations of s≤ts \le t faults, and verify that each error is either detected by a measurement or its weight is lower than or equal to ss.

Although the number of fault combinations that must be considered is vast, there are many opportunities to save on computational time and space that we will take advantage of.

Storing output errors

First of all, we will address the issue of computing the output error that results from each combination of faults. Given ss faults P1,…,PsP_1,\ldots,P_s, we write U1,…,UsU_1,\ldots,U_s for the unitaries that result from the part of the circuit subsequent to each of the ss faults until any postselections on ancilla qubits, which are all postponed to the end of the circuit. The error EiE_i at the output immediately prior to any postselected measurements that results from considering the fault PiP_i individually is then

Ei=UiPiUi†.(12)E_i = U_i P_i U_i^\dagger. \tag*{(12)}

The output error EE that results from the combination of the faults is equal to the product of the output errors EiE_i that result from each fault. There is a subtlety that does not arise with Clifford circuits in that the time ordering of the faults becomes relevant. This is due to the fact that output errors are not necessarily Pauli and hence do not necessarily commute or anticommute with each other. Labelling the faults P1,…,PsP_1,\ldots,P_s so that when i<ji<j, the circuit component corresponding to PiP_i does not occur later than that of PjP_j, the combined output error EE is

E=UsPsUs†⋯U1P1U1†=Es⋯E1.(13)\begin{aligned} E &= U_s P_s U_s^\dagger\cdots U_1 P_1 U_1^\dagger\\ &= E_s \cdots E_1 . \tag*{(13)} \end{aligned}

Since PiP_i is Pauli, from the results of Section III B, the output error EiE_i is DCP. This means that it can be evaluated efficiently. Furthermore, each output error EiE_i that results from each fault need only be computed exactly once, and then subsequently saved for future reference. This means that computing each output error combination EE only involves multiplying together DCP operators that have already been computed, which, as discussed in Section III B, is efficient in time and space.

We note that if we were to work in a more general gate set such as Clifford + T, then each Pauli fault PiP_i would propagate to an output error EiE_i that would not necessarily be Pauli or DCP, in which case storing even one output error would take space exponential in the number of qubits, let alone the cost of multiplying such operators, which illustrates one computational advantage of limiting oneself to the CNOT + T gate set.

Postselecting an output error combination

In order to check fault tolerance, we must verify whether an output error combination EE is good or bad. There are two parts to checking the goodness of a fault combination. We must determine whether the output error is detected, and if it is not, then we must check whether the weight of the output error is below ss or not.

The first of these tasks, determining whether an output error is detected, is considerably more complicated than for Clifford circuits. Given a Clifford circuit, a fault PP results in an output error EE which is also Pauli. Such errors will either flip or leave invariant any ancilla measurements, depending on whether they commute or anticommute with the measurement operator. Consequently, when one postselects on the results of some ancilla measurements, a Pauli error is either always detected or always undetected, and its effect on the remaining qubits is known.

In a CNOT + T circuit, however, the errors that result from faults are DCPs, not Paulis. As a result, they do not have a deterministic effect on measurement outcomes, as DCPs do not necessarily either commute or anticommute with the measurement operators. Postselecting on ancilla measurements in the presence of a DCP error leads to a conditional error on the data qubits that may not be the same as the error prior to postselection.

We take advantage of the structure of a DCP operator to break the problem into two cases. A DCP operator CDCP=CDPC_{\mathrm{DCP}} = C_{\mathrm{D}}P can be written as the product of a diagonal Clifford CDC_{\mathrm{D}} and a Pauli PP of XX type. Consider first any ancilla measurements that are made in the ZZ basis. Since these measurement operators will commute with any diagonal operator, we have that a DCP error will flip the measurement deterministically depending on whether PP commutes or anticommutes with the measurement operator, just as is the case for Pauli errors, meaning that they can be dealt with the same way. Provided that PP is not detected, the conditional XX error EX′E'_X on the data qubits that results from postselecting on the ZZ basis measurements will be PP restricted to those qubits.

We then consider postselecting on ancilla measurements that are made in the XX basis. The Pauli PP will always commute with the measurement operators since it is of XX type, which means that it will have no effect on the measurement outcome and can be ignored when considering postselection in the XX basis. As a result, we can assume for the rest of this analysis of the effect of postselection that CDCP=CDC_{\mathrm{DCP}} = C_{\mathrm{D}} is strictly diagonal Clifford, with no Pauli XX component.

In Appendix C, we show that, given an error E=CDE = C_{\mathrm{D}} which is diagonal Clifford, the conditional error E′E' that results from postselecting on a Pauli measurement made in the XX basis is either another diagonal operator or vanishes (in which case the error is always detected), and can be computed efficiently. We can apply this result repeatedly to then postselect on the remaining XX basis ancilla measurements, and obtain the conditional diagonal error EZ′E'_Z that results on the data qubits due to the XX basis measurements. The resulting full conditional error E′=EX′EZ′E' = E'_X E'_Z is the product of the two conditional errors that result from considering the XX and ZZ basis measurements separately, and is also DCP.

Checking the weight of a conditional output error

Now that we have the conditional output error E′E' on the data qubits, provided that it does not vanish we must verify whether the weight of the error E′E' is below the number of faults ss or not in order to decide whether the fault combination is good or not. This is made complicated by the fact that E′E' is not necessarily Pauli. We make use of the fact that, if two errors AA and BB are correctable, then their coherent sum A+BA+B must be correctable also [21]. We show also in Appendix C that a diagonal Clifford CC may be expressed as a linear combination of 2r2^r Paulis of ZZ type that belong to the coset of some rr-dimensional vector space V=⟨P1Z,…,PrZ⟩V = \langle P^Z_1,\ldots,P^Z_r\rangle whose generators P1Z,…,PrZP^Z_1,\ldots,P^Z_r can be computed efficiently. This allows one to express the conditional output error E′=CDPE' = C_{\mathrm{D}}P as a linear combination of Paulis simply by multiplying that of the diagonal Clifford CDC_{\mathrm{D}} on the right by PP.

We then verify that the conditional output error E′E' is good by iterating over this sum and verifying that each element is low weight. We make use of lookup tables to compute the weight of each element in constant time, which we discuss in detail in Appendix § 1.11. Although each element can be checked in constant time, there are 2r2^r elements of the vector space, which is to say this operation takes time exponential in rr.

Although it is unfortunate to finally encounter an overhead that is not polynomial in some parameter of the problem, the situation is not as bad as it appears.

First of all, there exists the opportunity to iterate over the elements of the vector space in parallel, which reduces the overhead in time. Secondly, the parameter rr is not necessarily that large. Without loss of generality, we are able to place the generators of the vector space in canonical form, as detailed in Appendix § 1.112, which limits the size of rr. For the Golay code, a code which has a higher number of qubits and distance than the other codes considered in this paper, rr cannot exceed 12, as also shown in Appendix § 1.112, which is to say there is a factor of 212=40962^{12}=4096 in the worst case, which is not so prohibitively large as to make computation infeasible in realistic circumstances.

There is one final issue in that, as alluded to in Appendix B, in contrast to the preparation of Pauli eigenstates, magic states are usually stabilised by a set of Clifford operators that are not also Paulis. For example, the magic state T∣+⟩T|+\rangle is stabilised by the operator e−iπ4SXe^{-\frac{i\pi}{4}}SX. If the error combination E′=e−iπ4SXE' = e^{-\frac{i\pi}{4}}SX were to result in a circuit that purports to prepare this magic state ∣T⟩|T\rangle, then the procedure we have so far outlined would incorrectly conclude that the error combination E′E' is bad as the XX part of it is logical, whereas in reality the error combination E′E' is good because as it stabilises the magic state it has no effect on it and is thus indistinguishable from no error having taken place.

We resolve this issue by considering the product of the error combination with all possible Cliffords CiC_i that stabilise the magic state,

Ei′′=E′Ci=Es…E1Ci,(14)E''_i = E'C_i = E_s \ldots E_1C_i, \tag*{(14)}

and we consider the error combination E′E' to be good if Ei′′E''_i satisfies the procedure we have outlined for at least one choice of ii.

In the case of preparing the usual magic state T∣+⟩T|+\rangle on a code with a single logical qubit, then the only Cliffords to consider are the identity and the operator e−iπ4SXe^{-\frac{i\pi}{4}}SX. However, as the number of logical qubits kk increases, there will be more Cliffords to consider, which may lead to an unfavourable scaling with kk.

Demonstration

We use these theoretical insights to design and implement Comb [22], an open-source library that iterates over a set of fault combinations arising from some CNOT + T circuit that purports to prepare a magic state fault-tolerantly and verifies that each of the fault combinations is good. It is designed to be fast so as to aid in the iterative design of fault tolerant magic state preparation circuits of distance greater than three. It takes as input a set of fault locations, a set of DCP operators that correspond to the output error that results from propagating each Pauli fault through the circuit, as well as a description of the magic state that the circuit prepares, that includes lookup tables to verify that the weight of any output error is small.

NameCodeNo. of 2Q gatesNo. of faultst1t_1No. of combinations of two faultst2t_2tft_f
Steane[7,1,3][7, 1, 3]387880.006 s--13 s
d=5d = 5, unoptimised[17,1,5][17, 1, 5]29850400.747 s12 662 1128m 3s11m 17s
d=5d = 5, optimised[17,1,5][17, 1, 5]19634080.486 s5 781 6003m 42s4m 55s
d=3d = 3[17,1,5][17, 1, 5]16127120.260 s(100 292)4.05 s32.9 s
Non-fault tolerant[17,1,5][17, 1, 5]24(18)0.003 s--12 s

Table 1. Running times for Comb verifying the fault tolerance of circuits that prepare magic states T∣+⟩T|+\rangle to either distance three or distance five. The time t1t_1 is the time taken to check all single faults, t2t_2 is the time taken to check all combinations of two faults, and tft_f is the total wall time consumed by the program. The numbers in parentheses indicate the number of combinations of faults that were checked up to finding a bad combination. The time t2t_2 was omitted for the d=3d = 3 and the non-fault tolerant circuit as only single faults needed to be considered for these circuits. tft_f exceeds the sum of t1t_1 and t2t_2 owing to the time taken to perform other tasks such as propagating the faults through the circuits, which is not done in Comb but tft_f is included anyway to give an idea of general running times. The first two circuits prepare magic states in the Steane code and distance five colour code respectively using Chamberland’s construction [10]. The third circuit, reproduced in Figure 6, is obtained from the second by deleting flag ancillas from the circuit, and is hence much smaller, accounting for the reduced time taken to verify its fault tolerance. The time taken to generate the lookup tables for the codes in both cases was well under a second and does not contribute significantly to the total time tft_f.

Comb is intended solely to perform the iteration over combinations of faults very quickly, and verify that they are either detectable or low weight. Consequently, in order to use it for a particular circuit, one must choose an appropriate set of fault locations and faults and propagate them through the circuit to obtain the DCP errors, since Comb itself cannot propagate faults through a circuit, and then supply them to Comb. One must also calculate the lookup tables using the algorithm outlined in Appendix § 1.11.

We demonstrate the performance of Comb in Table I when it comes to verifying the fault tolerance of several magic state preparation circuits. All the circuits tested have the general structure shown in Figure 2, based on the construction of [10, 11]. For the [17,1,5][17, 1, 5] code we consider several versions of the construction. One that is non-fault-tolerant and includes no logical stabiliser measurements or error detection cycles. A second that has circuit fault distance d=3d = 3 meaning it can handle a single fault but not two, this is achieved by appending one cycle of the logical stabiliser measurement and error detection. Finally, we consider two circuits that achieve the same circuit fault distance as the distance of the code d=5d = 5 by including two cycles of logical stabiliser measurements and the error detection. A Dell Latitude 7430 laptop with a Intel(R) Core(TM) i7-1265U CPU and 16GB of RAM was used. However, as Comb is single-threaded at the time of writing the number of cores is not expected to have a bearing on the fraction of the running time spent in Comb, though the faults themselves were propagated in parallel to calculate the output errors.

For each circuit, the CNOT and T gates were assumed to be noisy two- and single-qubit gates respectively that are immediately followed by a fault location that may spawn faults equal to any Pauli on the support of the qubits involved in the gates. Comb was used to verify the fault tolerance criterion that each possible combination of ss faults (for appropriate s≤⌊d2⌋s \le\left\lfloor\frac{d}{2} \right\rfloor chosen according to the distance of the code), leads to either a detectable error or an error of weight less than or equal to ss at the output.

One important use case we envision for Comb is to help design fault-tolerant magic state preparation circuits with lower resource requirements, we give a simple illustrative example of that using the [17,1,5][17, 1, 5] colour code. In Table I we show the performance of Comb on two d=5d = 5 variants of the magic state preparation circuit for the [17,1,5][17, 1, 5] code. The smaller of these circuits was obtained from the first using a simple greedy iterative optimization process with Comb certifying at each step that the reduced circuit remained fault-tolerant. The final circuit, along with additional details of the optimisation, are given in Appendix E.

As an independent check of Comb’s correctness we perform noisy circuit simulations of all the [17,1,5][17, 1, 5] circuits tested with Comb and compute their logical error rates, plotted as a function of physical error rate pp in Figure 3. In each case we observe scaling of the logical error rates with the physical error rate that is consistent with the findings of Comb. We additionally plot the post-selection acceptance rates for each circuit. These simulations were carried out using SymFT [23]. Additional details of the simulations are given in Appendix F. It is interesting to note that in these simulations we see better logical error rate for the unoptimised distance 5 circuit than the optimised circuit. We attribute this to the simplicity of the error model used in the simulations, which does not include memory errors such as from coherent dephasing or qubit leakage. In experiments we would expect to see advantages from shorter depth resource state preparation circuits that are not captured in these simulations, including increased robustness to memory errors as well as decreased idling times for other logical qubits in the computation. The shorter circuit depths combined with improved acceptance rates has the potential to improve the rate of producing magic states while decreasing the number of ancilla qubits needed to manufacture them.

Numerically simulated logical error rates and post-selection acceptance rates

Figure 3. Numerically simulated logical error rates, LL, and post-selection acceptance rates as a function of physical error rate pp for the magic state preparation circuits for the [17, 1, 5] code tested by Comb in Table I. In each case we see scaling consistent with Comb’s findings: the non-fault-tolerant circuit has a logical error rate L∼pL \sim p, the d=3d = 3 variant has L∼p2L \sim p^{2} and the d=5d = 5 variants have L∼p3L \sim p^{3}.

Discussions and outlook

In this paper, we make the case to explicitly restrict magic state preparation circuits to the CNOT + T gate set, and present Comb, a library that implements our algorithm insights and is designed to verify the fault tolerance of such circuits.

One future direction is to use Comb to design new fault tolerant circuits, which is an area of active research. The distance-five magic state preparation circuit that is presented in Figure 6 achieves a reduction of over 30% in the number of CNOT gates over the circuit it was derived from, and the fact that it was obtained simply by greedily deleting ancillas from another fault tolerant state preparation circuit gives us hope that there exist many fault tolerant magic state preparation circuits with much lower resource consumption than currently known distillation- or cultivation-based circuits, that may be verified using Comb.

Figure 6. Fault tolerant preparation of T∣+⟩T\lvert+\rangle in the [17, 1, 5] colour code. This circuit is composed of a non-fault-tolerant state preparation, followed by a sequence of measurements of the logical stabiliser SXS_X and stabilisers of the [17, 1, 5] code.

Work is underway to analyse pytket [24] circuits with Comb, which will greatly reduce the barrier to entry of using Comb for QEC researchers.

We anticipate that an autonomous agent, perhaps powered by AI, may be able to propose new magic state preparation circuits and then use Comb to check them. This suggests the possibility of closed-loop generation of magic state preparation circuits, which may lead to novel circuits that a human designer would struggle to propose in reasonable time.

There have been a plethora of recent results [25, 26, 27, 28] concerning fault tolerant rewrites for the ZX calculus, which allow one to change a fault-tolerant circuit using local rewrites that do not destroy its fault tolerance properties. Such techniques, relying as they do on local operations, are inherently scalable and promise to realise a practical way to reduce the resources that a fault tolerant quantum computation consumes at larger distances. To our knowledge, such results have been done exclusively on Clifford circuits to date. Our results concerning the practicality of the CNOT + T gate set for fault tolerant magic state preparation motivate the investigation of fault tolerant rewrites for ZX diagrams that correspond to CNOT + T circuits.

There exist many potential performance improvements to Comb that have not yet been implemented, such as use of parallelism, with both multiple cores and SIMD. We expect such improvements to have a great impact on performance, as verifying fault tolerance is inherently a parallel problem, as different combinations of faults can be divided into groups and checked independently in parallel.

Such performance improvements will not only aid in the exploration of distance-three and distance-five magic state preparation circuits, but will plausibly, combined with the use of HPC, make possible the exploration of distance-seven magic state preparation circuits, which is an exciting prospect.

Acknowledgments

The authors are employed by Quantinuum. We would like to thank Asmae Benhamou, Serban Cercelescu, Ben Criger and Pablo Andrés-Martínez for productive discussions, Alec Edgington for invaluable help with C++, Marek Kochanowicz for useful insights regarding program optimisation, and Mateusz Kupper for assistance with the noisy simulations.

References

Counterexample to checking fault-tolerance by replacing TT gates with SS and ZZ

A trick that is sometimes used when designing and testing magic state preparation circuits is to replace the TT gates with SS or ZZ gates [12, 15]. For some circuits (though not generically) this will replace the preparation of T∣+⟩T|+\rangle with S∣+⟩S|+\rangle or Z∣+⟩Z|+\rangle, without changing the circuit structure. Checking whether these CNOT + SS or CNOT + ZZ circuits are fault-tolerant is much easier because they are Clifford circuits, though they are not preparing the desired magic state.

In this appendix we consider circuits C(Q)C(Q) with the property that there are a set of QQ type gates in the circuit such that setting Q=ZQ=Z, SS or TT prepares the logical state Q∣+⟩Q|+\rangle and we ask what, if any, links we can draw between the fault-tolerance of C(S)C(S), C(Z)C(Z) and C(T)C(T). An example of such a circuit is shown in Figure 4(a), for the [[7,1,3]][[7,1,3]] Steane code.

State preparation circuit and Pauli propagation diagram

Figure 4. (a) State preparation circuit for the Steane code C(Q)C(Q) that prepares the logical Q∣+⟩Q|+\rangle state when setting the highlighted gates to Q=ZQ = Z, SS or TT. The top 7 qubits are the code qubits and the bottom 2 qubits are ancillas. The ancillas are measured at the end and the circuit is post-selected on a +1+1 measurement outcome for both. The circuit is not fault-tolerant but can be made fault-tolerant for all QQ by measuring stabiliser elements at the end. (b) Visualization of the Pauli propagation of a problematic fault for the C(T)C(T) circuit, which is missed by considering C(S)C(S) and C(Z)C(Z). The error begins as a YIYI error after the CNOT gate highlighted (bold, red) in (a). Clifford propagation is indicated with horizontal lines. Up to phases, which we neglect here, the TT gate transforms the Pauli into a sum of two Paulis: one equivalent to the TT gate having been an SS and the other equivalent to it having been a ZZ. Here we indicate this by the Pauli branching into two branches. The C(S)C(S) and C(Z)C(Z) circuit variants are equivalent to the top and bottom highlighted paths. If we modify the circuit in (a) to C′(Q)C'(Q) by measuring final stabilisers such that C′(S)C'(S) and C′(Z)C'(Z) are fault-tolerant, problematic errors for C′(T)C'(T) can arise on other branches of the propagation, such as the final X1Z2Z3X_1Z_2Z_3 error here on the (S,Z)(S,Z) branch.

C(S)C(S) and C(Z)C(Z) FT ⇏C(T)\not\Rightarrow C(T) FT

We might hope that by finding a way to make C(S)C(S) and C(Z)C(Z) fault-tolerant we will discover circuits that will also be fault-tolerant for C(T)C(T).

Here we present a circuit C(Q)C(Q) where C(S)C(S) and C(Z)C(Z) are fault-tolerant preparations of S∣+⟩S\lvert+\rangle and Z∣+⟩Z\lvert+\rangle while C(T)C(T) is a non-fault-tolerant preparation of T∣+⟩T\lvert+\rangle. This demonstrates that C(S)C(S) and C(Z)C(Z) being fault-tolerant does not in general guarantee that C(T)C(T) is also. This agrees with [12], which found in small statevector simulations that the logical error rate for preparing T∣+⟩T\lvert+\rangle in a magic state cultivation scheme was about twice as high as S∣+⟩S\lvert+\rangle or Z∣+⟩Z\lvert+\rangle.

The circuit we consider is shown in Figure 4(a), it is a non-fault-tolerant state preparation circuit for the [[7,1,3]][[7,1,3]] Steane code. Setting the highlighted gates to Q=ZQ=Z, SS or TT prepares the logical state Q∣+⟩Q\lvert+\rangle. It is composed of two parts: a non-fault-tolerant encoding circuit, followed by a flagged fault-tolerant measurement of the logical stabiliser [10]. The logical stabiliser measurement catches logical errors. Nevertheless, it is non-fault-tolerant because there are single faults that propagate to errors on the output with weight 2 or higher.

We can identify minimal size sets of stabilisers that make the circuits fault-tolerant if we measure them at the end of the circuits. The Z∣+⟩Z\lvert+\rangle circuit can be made fault-tolerant by measuring a single stabilier element:

IXXIIXXIXXIIXX.

For the S∣+⟩S\lvert+\rangle circuit there are no single stabilisers that catch all bad errors, but there are pairs of stabilisers that will make the circuit fault-tolerant:

YYIYIIY,YIYYIYIYYIYIIY, YIYYIYI

YYIYIIY,IYYIIYYYYIYIIY, IYYIIYY

ZZIZIIZ,IYYIIYYZZIZIIZ, IYYIIYY

YIYYIYI,IYYIIYYYIYYIYI, IYYIIYY

ZIZZIZI,IYYIIYYZIZZIZI, IYYIIYY

IYYIIYY,YYIIYYIIYYIIYY, YYIIYYI

IYYIIYY,ZZIIZZIIYYIIYY, ZZIIZZI

IYYIIYY,YIYIYIYIYYIIYY, YIYIYIY

IYYIIYY,ZIZIZIZIYYIIYY, ZIZIZIZ

YYIIYYI,YIYIYIYYYIIYYI, YIYIYIY.

Finally, there are triples of stabilisers that can be appended to the T∣+⟩T\lvert+\rangle circuit to make it fault-tolerant:

ZZIZIIZ,IIIZZZZ,IXXIIXXZZIZIIZ, IIIZZZZ, IXXIIXX

ZZIZIIZ,IYYIIYY,XXIIXXIZZIZIIZ, IYYIIYY, XXIIXXI

ZZIZIIZ,ZZIIZZI,IXXIIXXZZIZIIZ, ZZIIZZI, IXXIIXX

IIIZZZZ,ZZIIZZI,IXXIIXXIIIZZZZ, ZZIIZZI, IXXIIXX.

These stabiliser elements can be measured fault-tolerantly at the end of the circuits using flag gadgets [29].

Appending three fault-tolerant measurement gadgets to the end of the circuits to measure the IXXIIXXIXXIIXX, YYIYIIYYYIYIIY & YIYYIYIYIYYIYI stabilisers yields a circuit C(Q)C(Q) such that C(S)C(S) and C(Z)C(Z) are fault-tolerant but C(T)C(T) is not.

Although there are triples of stabilisers that we can measure to make the circuit in Figure 4(a) a fault-tolerant preparation of T∣+⟩T\lvert+\rangle this choice made by considering the SS and ZZ variants is not sufficient.

An intuitive understanding of this failure can be gained by considering the Pauli propagation of a problematic fault, Figure 4(b). A YIYI error after the CNOT gate highlighted (bold, red) in Figure 4(a) propagates through the subsequent CNOT gates to become YZZIIIIYZZIIII before the first layer of TT gates. The TT gate on qubit 1 acts as a linear combination of an SS gate and a ZZ gate, which we draw as two paths leading to XZZIIIIXZZIIII and YZZIIIIYZZIIII. To see this, consider the conjugation of a Pauli PP that anticommutes with ZZ through a TT gate

TPT†=SP∝(1−iZ)P=−ZPZ−iSP†.TPT^\dagger=SP\propto(1-iZ)P=-ZPZ-iSP^\dagger.

For our purposes here we can neglect the phases on these terms. Through the CNOTs of the logical stabiliser measurement the second term gains a ZZ on the first ancilla to become YZZIIIIZYZZIIII Z, this term is a product of a ZZ logical and a single qubit XX error and so the logical stabiliser measurement has been triggered. This term splits again at the second layer of T†T^\dagger gates but this does not remove the support on the ancilla and so both are detected when we measure the ancillas. The XZZIIIIXZZIIII term, in contrast, does not trigger the logical stabiliser measurement and splits at the T†T^\dagger layer into two terms YZZIIIIYZZIIII and XZZIIIIXZZIIII. The first of these anti-commutes with our choice of final stabiliser measurements and is detected, but the second commutes with the stabilisers and so is undetected at the output of the circuit, becoming a high weight bad error. By inspecting what paths have given rise to detected and undetected errors it is clear what has happened: the (S,S†)(S,S^\dagger) branch is detected, we have guaranteed this when considering C(S)C(S). The problematic error has arisen from the (S,Z)(S,Z) branch, which is absent when considering C(S)C(S) and C(Z)C(Z).

Does C(S)C(S) and C(Z)C(Z) non-FT ⇒C(T)\Rightarrow C(T) non-FT?

If C(S)C(S) and C(Z)C(Z) being non-fault-tolerant guaranteed that C(T)C(T) also cannot be fault-tolerant this would still be a useful property as it would offer a fast rejection method for candidate circuits. Using the fact that C(S)C(S) and C(Z)C(Z) are Clifford circuits, their fault-tolerance can be checked with standard Pauli propagation and weight minimisation methods. We could quickly test C(S)C(S) and C(Z)C(Z), and only proceed to the more expensive testing of C(T)C(T) if they both pass.

We leave this as an open problem. We are not able to provide a counter example, but we cannot prove that it must always be true.

Fault tolerance condition

Here we show that the condition given for the fault-tolerance of CNOT + T state preparation circuits in section IV A is equivalent to those commonly given in the literature [10, 21]. We specifically compare to the definition given by Gottesman in [21].

For completeness, the condition we use is: a CNOT + T state preparation circuit is fault-tolerant to distance dd if it obeys:

(⋆)(\star) any combination of s≤t=⌊d2⌋s \leq t = \left\lfloor\frac{d}{2} \right\rfloor faults produces an output error that is either detected by a pattern of unexpected ancilla measurements or is a sum of Pauli strings each of weight at most ss.

The weight of a Pauli string must be taken modulo the stabilisers. This is achieved with a weight lookup table, as discussed in appendix § 1.11.

The fault-tolerance conditions for state preparation circuits presented in [21] make use of rr-filters and ideal decoders. This machinery is more general than we needed so we avoided it in our definition, opting instead for a simpler (but equivalent) condition based on Pauli weights.

An rr-filter for a QEC code projects onto the subspace of errors spanned by states E∣ψ⟩E|\psi\rangle where ∣ψ⟩|\psi\rangle is any code-word and EE is a Pauli error of weight at most rr. We use the terminology passing an rr-filter to mean that the state is unchanged by applying an rr-filter.

An ideal decoder is a quantum channel that takes an encoded state, noiselessly extracts the syndrome of any errors before correcting them and returning the decoded logical state. If the errors on the encoded state are un-correctable the ideal decoder will return a state with a logical error.

Fault-tolerance for a state-preparation circuit is defined in [21] by the two properties:

  1. Preparation Error Propagation: any combination of s≤ts \leq t faults passes an ss-filter,

  1. Preparation Correctness: the noisy output state will be decoded by an ideal decoder to the logical state that the noiseless circuit would prepare, provided s≤ts \leq t faults occur,

where t=⌊d2⌋t = \left\lfloor\frac{d}{2} \right\rfloor is the number of correctable errors.

We first show that if (⋆)(\star) is satisfied then (1) is satisfied. Let us write the output DCP error as

E=∑iciPi,(15)E = \sum_i c_i P_i, \tag*{(15)}

where the PiP_i are Pauli strings. The weight EE is taken modulo the stabilisers. To be explicit the weight is minimised with respect to the full stabiliser group of the code SS enlarged with the logical Clifford CC that the noiseless output state is the +1+1 eigenstate of, e.g. for the T∣+⟩T|+\rangle logical state C=T‾X‾T‾−1=S‾X‾C = \overline{T}\overline{X}\overline{T}^{-1} = \overline{S}\overline{X}. Consider the minimisation under SS first, each PiP_i can be written

Pi=QiSi(16)P_i = Q_i S_i \tag*{(16)}

where QiQ_i is the Pauli string with minimum weight and SiS_i is an element of the stabiliser group. The action of $E on the noiseless encoded output state ∣Ψ‾⟩|\overline{\Psi}\rangle is

E∣Ψ‾⟩=∑iciPi∣Ψ‾⟩=∑iciQiSi∣Ψ‾⟩=∑iciQi∣Ψ‾⟩,(17)E|\overline{\Psi}\rangle= \sum_i c_i P_i|\overline{\Psi}\rangle = \sum_i c_i Q_i S_i|\overline{\Psi}\rangle = \sum_i c_i Q_i|\overline{\Psi}\rangle, \tag*{(17)}

where we have used the fact that ∣Ψ‾⟩|\overline{\Psi}\rangle is stabilised by SiS_i. The noiseless state ∣Ψ‾⟩|\overline{\Psi}\rangle is also stabilised by CC so we can consider the alternative DCP error

E′=EC=∑jdjPj′,(18)E' = EC = \sum_j d_j P'_j, \tag*{(18)}

where the sum will generically contain a different number of Paulis. Minimising the weight of each Pj′P'_j under the stabilisers produces an alternative set of minimum weight Paulis {Qj′}\{Q'_j\}. Condition (⋆) requires that the weight of all the Paulis {Qi}\{Q_i\}, or all the {Qj′}\{Q'_j\}, is at most ss when s≤ts \leq t faults occur. If this condition holds then the output state Eqn. (B3) will pass an ss-filter, since ∣Ψ‾⟩|\overline{\Psi}\rangle is a codeword, hence condition (1) is satisfied.

Next we show that if (⋆) is satisfied then (2) is satisfied. If the weight of all the QiQ_i is at most s≤ts \leq t then all the QiQ_i are correctable errors [21]. In this case an ideal decoder is sure to decode the output state Eqn. (B3) to ∣Ψ‾⟩|\overline{\Psi}\rangle, the logical state of the noiseless circuit, and so (2) is satisfied.

Diagonal coherent error analysis

A great advantage of DCP errors is that they are able to compactly describe coherent errors which, when expressed as a sum of Paulis, may be very large.

In fault tolerant analysis, one is interested in whether errors are detected by ancilla measurements, and if not, what the residual conditional error on the remaining qubits is. It is known how to do this efficiently for errors that are Pauli. For a general coherent error, one is compelled to expand the coherent error as a sum of Paulis and check each term in the sum in turn. If the sum is very large, then even initially writing down the sum (or storing it memory on a computer) for a single coherent error will be infeasible, let alone considering a very large number of errors.

In this section, we will show that given a coherent error prior to any measurements that is DCP, it is possible to efficiently calculate and describe the conditional error that results from postselecting on the results of ancilla measurements, without having to expand any sums explicitly. This result is of great importance in ensuring that DCP errors can be verified to be good or bad in a reasonable timeframe.

Operator state duality

As it is possible to deal with the Pauli X part of a DCP error in much the same way as a Pauli error, we assume for the rest of this section, without loss of generality that the error EE that results immediately prior to any ancilla measurements is strictly diagonal Clifford.

As discussed, we are interested in dealing with the error EE without having to express it directly as a sum of Paulis. In order to do so, we will make use of a operator-state duality. We define the error state ∣ψE⟩|\psi_E\rangle to be the state

∣ψE⟩=E∣+⟩⊗n.(19)|\psi_E\rangle= E|+\rangle^{\otimes n}. \tag*{(19)}

The error state can be defined not only for the error EE that is diagonal Clifford, but for all diagonal operators. The error state contains all information about the error EE; it is possible to reconstruct the operator EE from the state ∣ψE⟩|\psi_E\rangle by observing that the coefficients of the state ∣ψE⟩|\psi_E\rangle in the computational basis form the diagonal of the operator EE in that basis.

It will turn out that many operations of interest that one would like to carry out on the coherent error EE, such as determining the conditional coherent error E′E' that results from postselecting on an ancilla measurement, are best expressed in terms of operations on the corresponding error state ∣ψE⟩|\psi_E\rangle.

Before turning to them, we will first note that since the error EE is diagonal Clifford, the error state ∣ψE⟩|\psi_E\rangle is a Pauli stabiliser state, as it is defined as the application of a Clifford EE to the state ∣+⟩⊗n|+\rangle^{\otimes n}, which is a Pauli stabiliser state. Furthermore, a choice of stabiliser generators for the error state ∣ψE⟩|\psi_E\rangle can be determined easily from a description of the diagonal Clifford EE, as they are simply the images of the Pauli operators XiX_i under conjugation by the error EE.

Postselection

In order to detect such diagonal coherent errors, one or more ancillas may be measured in the XX basis, and the state discarded if one of the measurement results, or a parity of them, is non-trivial. We denote PXP_X to be the Pauli of XX type corresponding to one such measurement.

Writing the error EE as a sum of diagonal Paulis,

E=∑i=1NciPi,(20)E = \sum_{i=1}^{N} c_i P_i, \tag*{(20)}

the error E′E' that results will be of the form

E′=∑i=1[Pi,PX]=0NciPi,(21)E' = \sum_{i=1 \left[P_i,P_X\right]=0}^{N} c_i P_i, \tag*{(21)}

which is to say that the errors that anticommute with the measurement operator are detected, while those that do not are undetected and survive to form the coherent error conditional on postselection.

Eliminating terms from EE in this drastic manner means that E′E' may not necessarily be Clifford; indeed it may vanish altogether. Despite this, it is certainly diagonal, which means that it possesses an error state ∣ψE′⟩|\psi_{E'}\rangle, and there exists a simple relation between the error states ∣ψE⟩|\psi_E\rangle and ∣ψE′⟩|\psi_{E'}\rangle.

Applying Equation (C2) and Equation (C3) to the state ∣+⟩⊗n|+\rangle^{\otimes n} gives that

∣ψE⟩=∑i=1NciPi∣+⟩⊗n,(22)|\psi_E\rangle= \sum_{i=1}^{N} c_i P_i |+\rangle^{\otimes n}, \tag*{(22)}

and

∣ψE′⟩=∑i=1[Pi,PX]=0NciPi∣+⟩⊗n.(23)|\psi_{E'}\rangle= \sum_{\substack{i=1\\ [P_i,P_X]=0}}^{N} c_i P_i |+\rangle^{\otimes n}. \tag*{(23)}

The terms Pi∣+⟩⊗nP_i|+\rangle^{\otimes n} that appear in Equation (C5) are those terms appearing in Equation (C4) for which PiP_i commutes with PXP_X. These terms are precisely the positive eigenstates of PXP_X, which means that they are preserved under the projector onto the positive eigenspace of PXP_X, while the unwanted terms are eliminated by this projector.

Concretely, we get that

∣ψE′⟩=I+PX2∣ψE⟩.(24)|\psi_{E'}\rangle= \frac{I+P_X}{2}|\psi_E\rangle. \tag*{(24)}

As previously discussed, the error state ∣ψE⟩|\psi_E\rangle is a Pauli stabiliser state. The above equation gives that the state ∣ψE′⟩|\psi_{E'}\rangle is equal to that which results from measuring the Pauli operator PXP_X to be +1+1 on the state ∣ψE⟩|\psi_E\rangle. But as the state ∣ψE⟩|\psi_E\rangle is a Pauli stabiliser state, a choice of stabiliser generators of the state ∣ψE′⟩|\psi_{E'}\rangle can be evaluated efficiently by updating those of the state ∣ψE⟩|\psi_E\rangle[21]. We note also that the resulting state may vanish, in which case the conditional error E′E' vanishes also. This case corresponds to the situation in which the error EE is completely detected by the measurement.

Although the error E′E' is not necessarily Clifford, its error state ∣ψE′⟩|\psi_{E'}\rangle is a Pauli stabiliser state just as the state ∣ψE⟩|\psi_E\rangle is. This means that we can apply the above technique again to ∣ψE′⟩|\psi_{E'}\rangle to evaluate the error state that results from postselecting on any number of ancilla measurements, not just one, simply by measuring the corresponding measurement operators in turn on the error state.

In this way, one can describe in terms of its error state the conditional coherent error ECE_C that results from all postselections made in the XX basis. Such a state will necessarily have much fewer terms in its expansion than the original error EE.

Canonicalisation

The conditional coherent error ECE_C, when expressed as a linear combination of diagonal Paulis, may contain distinct terms which are equal up to a stabiliser. It is important to eliminate such terms in the sum by stabiliser multiplication and cancellation in order to accurately evaluate whether the error is good (low weight) or not.

To illustrate this more clearly, we give a hypothetical example. A circuit that purports to prepare the magic state T∣+⟩T|+\rangle in the Steane code might have a coherent error, after postselection, of the form

EC=ZZZIIII−ZZZZZZZZ.(25)E_C = ZZZIIII - ZZZZZZZZ. \tag*{(25)}

Both of these terms are logical operators, and so they cannot be equivalent to a weight one error up to multiplication by any ZZ stabiliser, since the code is distance three. Consequently, they are both undetectable bad errors and a circuit that produced either of these errors in the presence of a single fault would have to be rejected as not fault tolerant.

However, they are both equal after multiplication by the stabiliser generator IIIZZZZZIIIZZZZZ. Consequently, the error ECE_C vanishes, which necessarily means that it is good, as a vanishing error is one that was already detected by postselecting on an ancilla measurement.

Consequently, when considering coherent errors, one must take care to ensure that errors that are equivalent up to multiplication by a stabiliser have already been cancelled out in the sum, otherwise checking each term in the sum in turn would lead to a spurious conclusion that some good coherent errors are bad.

Surprisingly, it is possible to perform such a cancellation by measuring the error state ∣ψEC⟩|\psi_{E_C}\rangle without having to expand the sum at all.

We note first that, following Appendix § 1.11, every Pauli operator has a unique canonical form that results from multiplying by a choice of stabiliser generators. Writing the operator

EC=∑i=1NciPi,(26)E_C = \sum_{i=1}^{N} c_i P_i, \tag*{(26)}

we note that if every operator PiP_i is replaced by its canonical form, then all cancellations in the sum will take place automatically, as operators that are equivalent up to a stabiliser will be mapped to the same canonical form.

Every term in the sum ECE_C can be canonicalised by multiplying on the left by ECE_C by an appropriate choice of operators. In order to help illustrate this, we will give a worked example. In order to canonicalise operators with respect to the Steane code, operators which have support on the first qubit must be multiplied by the stabiliser generator SZ=ZIZIZIZS_Z = ZIZIZIZ, and those that do not are left unchanged. Doing the same for subsequent stabiliser generators of the Steane code ensures that all operators have vanishing support on the first, second and fourth qubits, and are so left in canonical form.

Considering for now only the effect of canonicalising on the first qubit, we must separate the error ECE_C into a part EC+E_C^+ which has trivial support on the first qubit, and a part EC−E_C^- that doesn’t. It will prove simpler to discuss these operators in terms of their error states. The error states according to these operators can be obtained straightforwardly by projecting into the positive and negative eigenspaces of X1X_1 respectively,

∣ψEC+⟩=I+X12∣ψEC⟩,(27)|\psi_{E_C^+}\rangle= \frac{I+X_1}{2}|\psi_{E_C}\rangle, \tag*{(27)}
∣ψEC−⟩=I−X12∣ψEC⟩.(28)|\psi_{E_C^-}\rangle= \frac{I-X_1}{2}|\psi_{E_C}\rangle. \tag*{(28)}

The terms in EC+E_C^+ have vanishing support on the first qubit and do not need to be changed. However, all the terms in EC−E_C^- have support on the first qubit, and must all be multiplied by SZS_Z in order to canonicalise them. This can be accomplished by applying the operator SZS_Z to the error state ∣ψEC−⟩|\psi_{E_C^-}\rangle. Once this is done, both halves of the sum can be recombined. The error EC′E'_C that results is

∣ψEC′⟩=∣ψEC+⟩+SZ∣ψEC−⟩.(29)|\psi_{E'_C}\rangle= |\psi_{E_C^+}\rangle+ S_Z|\psi_{E_C^-}\rangle. \tag*{(29)}

Substituting (27) and (28) gives that

∣ψEC′⟩=(I+X12+SZI−X12)∣ψEC⟩.(30)|\psi_{E'_C}\rangle= \left(\frac{I+X_1}{2}+S_Z\frac{I-X_1}{2}\right)|\psi_{E_C}\rangle. \tag*{(30)}

This expression can be simplified by observing that SZS_Z anticommutes with X1X_1, as SZS_Z has support on the first qubit. One gets, after pushing SZS_Z past X1X_1 and factorising, that

∣ψEC′⟩=I+X12I+SZ2∣ψEC⟩.(31)|\psi_{E'_C}\rangle= \frac{I+X_1}{2}\frac{I+S_Z}{2}|\psi_{E_C}\rangle. \tag*{(31)}

This corresponds to measuring two Pauli operators to be +1+1 on the error state ∣ψEC⟩|\psi_{E_C}\rangle, and generalises to canonicalising on any qubit in any CSS code, not just the Steane code.

As the state ∣ψEC⟩|\psi_{E_C}\rangle is a Pauli stabiliser state, just as before the state ∣ψEC′⟩|\psi_{E'_C}\rangle that results from measuring Paulis on it is also a Pauli stabiliser state, and a description of it can be obtained efficiently.

Error states to cosets

In this way, one can efficiently determine the final coherent error EFE_F that results from postselecting on all relevant ancilla measurements and eliminating terms that are equal up to a stabiliser multiplication. The next step is to expand the error EFE_F as a linear combination of Paulis and ensure that each of them is low weight.

The previous results have shown how to efficiently obtain a description of the error EFE_F in terms of its error state ∣ψEF⟩|\psi_{E_F}\rangle. We now turn to the problem of obtaining an expansion of EFE_F in terms of Paulis from its error state. Although the number of terms in the sum will turn out to be exponential in some parameter, they all belong to the coset of a vector space which can be described and calculated efficiently.

Let us first relate the expansion of EFE_F to the error state. Writing the error

EF=∑i=1NciPi.(32)E_F = \sum_{i=1}^{N} c_iP_i. \tag*{(32)}

as a linear combination of distinct Paulis PiP_i of ZZ type, and applying both sides to the state ∣+⟩⊗n|+\rangle^{\otimes n}, we get that

∣ψEF⟩=∑i=1NciPi∣+⟩⊗n.(33)|\psi_{E_F}\rangle= \sum_{i=1}^{N} c_iP_i|+\rangle^{\otimes n}. \tag*{(33)}

Consider the states Pi∣+⟩⊗nP_i|+\rangle^{\otimes n}. The effect of PiP_i on the state ∣+⟩⊗n|+\rangle^{\otimes n} is to flip ∣+⟩|+\rangle to ∣−⟩|-\rangle on qubits on which PiP_i has support, and leave it invariant otherwise. Consequently, one can read off PiP_i from the patterns of ++ and −- on such states. This means that all the information about the sum - in particular the Pauli PiP_i that make up the sum - can be obtained by expressing the error state ∣ψEF⟩|\psi_{E_F}\rangle in the basis of X stabiliser states B={∣+⟩,∣−⟩}⊗nB=\{|+\rangle,|-\rangle\}^{\otimes n} and seeing which basis terms form the combination.

Since the error state ∣ψEF⟩|\psi_{E_F}\rangle is a Pauli stabiliser state, it is possible to compactly characterise the set of diagonal Paulis PiP_i.

We first fix a choice of stabiliser generators S1,…,SnS_1,\ldots,S_n for the state ∣ψEF⟩|\psi_{E_F}\rangle. In order to make contact with the basis BB, we will fix some X basis state ∣C⟩∈B|C\rangle\in B and write

∣ψEF⟩∝∏i=1nI+Si2∣C⟩,(34)|\psi_{E_F}\rangle\propto\prod_{i=1}^{n}\frac{I+S_i}{2}|C\rangle, \tag*{(34)}

where we have related the error state ∣ψEF⟩|\psi_{E_F}\rangle to an X computational basis state ∣C⟩|C\rangle by applying the projector onto the error state ∣ψEF⟩|\psi_{E_F}\rangle to the state ∣C⟩|C\rangle. As the X computational basis states are a basis, there must always exist at least one choice of state ∣C⟩|C\rangle such that the constant of proportionality is not zero i.e. at least one state ∣C⟩|C\rangle must have non-zero overlap with the error state ∣ψEF⟩|\psi_{E_F}\rangle. We will turn later to the question of how to choose the state ∣C⟩|C\rangle, and assume for now that it has been chosen appropriately by some means.

Let us now consider the effect of projecting the state ∣C⟩|C\rangle onto the positive eigenspace of the stabiliser generators SiS_i. In order to simplify the analysis, we will consider two special cases. If SiS_i is of Z type and not the identity, then one gets that

I+Si2∣C⟩=∣C⟩+Si∣C⟩2,(35)\frac{I+S_i}{2}|C\rangle= \frac{|C\rangle+S_i|C\rangle}{2}, \tag*{(35)}

where the state Si∣C⟩S_i|C\rangle is a X computational basis state that is distinct from ∣C⟩|C\rangle.

If SiS_i is of X type, then Si∣C⟩S_i|C\rangle will be equal to ∣C⟩|C\rangle up to a sign. Correspondingly, acting on ∣C⟩|C\rangle with the projector I+Si2\frac{I+S_i}{2} will either give zero or the state ∣C⟩|C\rangle, depending on the sign.

Of course, the stabiliser generators SiS_i are not known to be of either X or Z type, and are unlikely to be. However, armed with these observations, we can cast the stabiliser generators SiS_i into a different set Si′S'_i via Gaussian elimination, that will allow us to apply these observations.

Concretely, we perform Gaussian elimination on the Z parts of the stabiliser generators SiS_i. A new set of stabiliser generators Si′S'_i stabilising the same state is produced, such that for some known rr, for all i≤ri \le r the Z parts of the stabiliser generators Si′S'_i are linearly independent, and for all i>ri > r, the Z parts of the stabiliser generators Si′S'_i vanish.

Substituting the new set of stabiliser generators Si′S'_i into Equation (C16), we get

∣ψEF⟩∝(∏i=1rI+Si′2)(∏i=r+1nI+Si′2)∣C⟩.(36)|\psi_{E_F}\rangle\propto\left(\prod_{i=1}^{r}\frac{I+S'_i}{2}\right)\left(\prod_{i=r+1}^{n}\frac{I+S'_i}{2}\right)|C\rangle. \tag*{(36)}

First, we apply the projectors corresponding to i>ri > r to the state ∣C⟩|C\rangle. The stabiliser generators Si′S'_i are all of X type by construction, and so as discussed they either eliminate the state ∣C⟩|C\rangle or preserve it. It is always possible to choose the state ∣C⟩|C\rangle such that none of the projections eliminate the state by writing ∣C⟩=PC∣+⟩⊗n|C\rangle= P_C|+\rangle^{\otimes n}, where PCP_C is some Pauli of Z type, and choosing PCP_C to anticommute or commute with Si′S'_i as appropriate to ensure that the projections do not eliminate the state ∣C⟩|C\rangle. This can always be done efficiently by solving a linear system of equations over F2\mathbb{F}_2.

Once this has been done, the projections act trivially on the state ∣C⟩|C\rangle and we are left with

∣ψEF⟩∝(∏i=1rI+Si′2)∣C⟩(37)|\psi_{E_F}\rangle\propto\left(\prod_{i=1}^{r}\frac{I+S'_i}{2}\right)|C\rangle \tag*{(37)}
=12r∑a1,…,ar∈{0,1}S1′a1⋯Sr′ar∣C⟩.(38)= \frac{1}{2^r}\sum_{a_1,\ldots,a_r\in\{0,1\}} S_1'^{a_1}\cdots S_r'^{a_r}|C\rangle. \tag*{(38)}

The operators S1′a1⋯Sr′arS_1'^{a_1}\cdots S_r'^{a_r} that appear in the sum are not necessarily of either X or Z type, so when they act on the state ∣C⟩|C\rangle they can both flip the sign and take ∣C⟩|C\rangle to a different X computational basis state ∣Ca1,…,ar⟩|C_{a_1,\ldots,a_r}\rangle, depending on the Z parts of the operator S1′a1⋯Sr′arS_1'^{a_1}\cdots S_r'^{a_r}. However, as the Z parts of the operators Si′S'_i are all linearly independent by construction, the states ∣Ca1,…,ar⟩|C_{a_1,\ldots,a_r}\rangle are all unique, meaning that there can be no cancellations in the resulting sum. Furthermore, the states ∣Ca1,…,ar⟩|C_{a_1,\ldots,a_r}\rangle can be obtained by acting on the state ∣C⟩=PC∣+⟩⊗n|C\rangle= P_C|+\rangle^{\otimes n} by all the 2r2^r ways of forming products of the Z parts of the stabiliser generators Si′S'_i.

Consequently, one gets that the coherent error EFE_F can be expressed as a linear combination of 2r2^r Paulis that form the coset of a vector space

S=PC⟨S1′Z,…,Sr′Z⟩,(39)S = P_C\langle S_1^{\prime Z},\ldots,S_r^{\prime Z}\rangle, \tag*{(39)}

where the operator Si′ZS_i^{\prime Z} is the Z part of the stabiliser generator Si′S'_i.

We conclude by remarking that although the number of errors in the coherent sum is 2r2^r, it is at least possible to calculate and describe the set efficiently, and that the elements of the coset may be iterated over in constant memory via a Gray code for example.

Weight lookup tables

We make liberal use of lookup tables to fetch the weight of an operator up to multiplications by a stabiliser from some code. In this Appendix, we discuss novel theoretical and technical work related to lookup tables that is key to the performance of Comb and may be of general interest to those working with stabiliser codes.

For simplicity of discussion, we will limit ourselves to CSS codes as we do not consider non-CSS codes elsewhere in this work, though much of the discussion does generalise to non-CSS codes.

Lookup tables

A lookup table is a simple data structure that stores the result of some computation, so that it need not be computed more than once. Given a computable but expensive function ff that acts on a finite set RR of size NN, we produce a lookup table for ff by first labelling the members ri∈R:0≤i<Nr_i \in R : 0 \le i < N and then computing and storing the values f(ri)f(r_i) in an array of size NN. Subsequent evaluations of ff may be made by looking up the appropriate entry in the array, which is an operation that takes constant time.

This dramatic saving in time naturally comes at the cost of a great increase in space. If the set RR is too large, it may be too impractical to store it in memory. Furthermore, we must evaluate ff on every element of RR in order to form the lookup table. This will not be worthwhile unless the number of evaluations of ff is likely to exceed NN. Since by assumption ff is expensive to evaluate on individual elements, then evaluating ff on the entire set RR is likely to be very expensive indeed. However, if RR is known, then the lookup table only needs to be computed once, and depending on the details of evaluating ff, forming the lookup table may not be prohibitively expensive.

We argue that lookup tables are appropriate to compute the weight of operators modulo a stabiliser code of reasonable size. Firstly, determining the weight of an operator PP modulo a stabiliser code is a computationally costly problem. Given a code with ss stabiliser generators of a code, one way to compute the weight of PP is to form all possible products of PP with a stabiliser and find the minimum weight over the products. However, as there are 2s2^s different stabilisers, this is not very efficient, and prohibitive for codes of even moderate size. We note also that, for the purposes of checking fault tolerance, the number of output error combinations that must be considered is extremely large, and accordingly we expect to check the weight of a very large number of operators. Any potential saving in the cost of evaluating the weight of an operator must therefore be considered.

We present two results that greatly facilitate the use of tables to look up the weight of an operator; firstly, a trick to compress the size of a lookup table, and secondly an algorithm to compute lookup tables in reasonable time.

Compression trick

Given a [n,k,d][n,k,d] CSS code, we define the CSS weight lookup tables TiXT_i^X and TiZT_i^Z,

TiX(PX)={1if min⁡{h(PXSX):SX∈CX}≤i0otherwise,(40)T_i^X(P_X)= \begin{cases} 1 & \text{if }\min\{h(P_XS_X):S_X\in C_X\}\le i\\ 0 & \text{otherwise,} \end{cases} \tag*{(40)}
TiZ(PZ)={1if min⁡{h(PZSZ):SZ∈CZ}≤i,0otherwise,T_i^Z(P_Z)= \begin{cases} 1 & \text{if }\min\{h(P_ZS_Z):S_Z\in C_Z\}\le i,\\ 0 & \text{otherwise,} \end{cases}

where PXP_X and PZP_Z are Paulis of XX and ZZ type respectively, hh is the Hamming weight, CXC_X and CZC_Z are the spaces spanned by the XX and ZZ stabilisers of the code CC respectively. One can verify whether the weight of a Pauli PXP_X of XX type is of weight lower than or equal to ss by looking up the appropriate entry in the table TiX(PX)T_i^X(P_X), and similarly for a Pauli PZP_Z of ZZ type.

In practice, we will limit ourselves to the case i≤⌊d2⌋i\le\left\lfloor\frac{d}{2}\right\rfloor, since this is sufficient for verifying fault tolerance.

We define the weight lookup tables this way for two reasons: first of all, when we check whether a given output error combination is good, we are not interested so much in the weight of an output error combination as much as verifying that its weight is below some threshold ss. Consequently, the weight lookup tables will contain all the information - one bit per Pauli - that is required and no more, which is optimal from the perspective of storing information.

The Paulis PXP_X and PZP_Z can be put into correspondence with bit strings of length nn, which mean that each of these lookup tables are of size 2n2^n. Given a code of reasonable size such as the Golay code, with n=23n=23 and d=7d=7, each of the six lookup tables will occupy 1MiB of space. These can easily fit into memory, which illustrates the practicality of lookup tables for this problem.

However, one can compress the lookup tables by a considerable degree by casting the stabiliser generators of a code into a particular form.

To use the Golay code as an example, its stabiliser generators of ZZ type can be written,

ZIZIIZIIZZZZZIIIIIIIIII
ZZZZIZZIZIIIIZIIIIIIIII
IZZZZIZZIZIIIIZIIIIIIII
IIZZZZIZZIZIIIIZIIIIIII
IIIZZZZIZZIZIIIIZIIIIII
ZIZIZIZZZIIZIIIIIZIIIII
ZZZZIIIZIIZZIIIIIIZIIII
ZZIZZZIIIZZIIIIIIIIZIII
IZZIZZZIIIZZIIIIIIIIZII
ZIIZIIZZZZZIIIIIIIII...

where the tableau restricted to the final eleven qubits is the identity. We note that this can be done for any stabiliser code up to a qubit permutation by performing Gaussian elimination.

Given an operator PZP_Z on 23 qubits, one can multiply PZP_Z by these stabiliser generators as appropriate to eliminate any ZZ operators on the last eleven qubits, thus obtaining another operator PZ′P'_Z which acts non-trivially on at most the first twelve qubits. We will refer to PZ′P'_Z as the canonical form of PZP_Z.

Since multiplying an operator by a stabiliser preserves its weight modulo the stabiliser code, instead of using PZP_Z to index into the lookup table we can instead use PZ′P'_Z. This means that the lookup tables now each occupy 2122^{12} bits, or 512 bytes, which is a massive saving, and makes the use of lookup tables practical for larger codes.

This saving in space is in fact likely to deliver a saving in time. A lookup table of 512 bytes can fit into the L1 cache of many CPUs, which, assuming that the rest of the program does not occupy too much space, is likely to make memory accesses considerably faster.

Computing a weight lookup table

The compression trick discussed in the last section gives rise to an inductive algorithm for computing the lookup tables TiZ(PZ)T_i^Z(P_Z). Computing the tables TiX(PX)T_i^X(P_X) will follow by symmetry.

Considering the first base case i=0i=0, we observe that T0Z(PZ′)T_0^Z(P'_Z) is 1 if and only if PZ′P'_Z is the identity. This is because only stabilisers may have weight zero modulo the code, and all stabilisers have the identity as their canonical form.

We will proceed to generate the tables TiZ(PZ′)T_i^Z(P'_Z) inductively. Given tables T0Z,…,TiZT_0^Z,\ldots,T_i^Z, we will show how to generate table Ti+1ZT_{i+1}^Z.

Iterate over all elements PP such that TiZ(P)=1T_i^Z(P)=1 i.e. those that have weight less than or equal to ii modulo the code. For each 1≤j≤n1\le j\le n, we form the product PZjPZ_j. By construction, PZjPZ_j must have weight less than or equal to i+1i+1. We then check to see if TiZ(PZj)=0T_i^Z(PZ_j)=0, noting that this involves computing the canonical form of PZjPZ_j. If so, then we know that PZjPZ_j is of weight i+1i+1, so we add it to Ti+1ZT_{i+1}^Z and continue. Every operator of weight i+1i+1 must be of this form for some PP and jj, so we are guaranteed to reach all operators of weight i+1i+1 this way.

Consequently, once we have finished the iteration, Ti+1Z(P)T_{i+1}^Z(P) will contain all operators of weight exactly i+1i+1 modulo the code. We then set Ti+1Z(P)=1T_{i+1}^Z(P)=1 for all PP in TiZT_i^Z to ensure that TiZT_i^Z contains all operators of weight at most i+1i+1, which completes the induction.

Although this algorithm is not polynomial in time or space, it need only be evaluated once per code, and it does not take excessive time to evaluate it for many codes of reasonable size such as the aforementioned Golay code. It is to be hoped that it is practical to compute and use lookup tables for larger codes, though this will not scale indefinitely.

Greedy circuit optimisation of the distance five circuit for [ ⁣[17,1,5] ⁣][\![17,1,5]\!]

In Section V we use Comb to test the fault-tolerance of a set of magic state preparation circuits for the [ ⁣[17,1,5] ⁣][\![17,1,5]\!] colour code, including two variants that are fault-tolerant to the distance of the code d=5d=5. The second d=5d=5 circuit is obtained from the first by a circuit optimisation procedure. This optimisation is made possible by the high speed that Comb is able to test candidate circuits. In this appendix we describe that optimisation process in detail. The code definitions we adopt for [ ⁣[17,1,5] ⁣][\![17,1,5]\!] are shown in Figure 5.

Figure 5. Code definitions we use for the [ ⁣[17,1,5] ⁣][\![17,1,5]\!] colour code. Each plaquette is associated with an XX and ZZ type stabiliser acting on the qubits bordering the plaquette. We choose representatives of logical Xˉ\bar{X} and Zˉ\bar{Z} that act on all qubits.

As a starting point we begin with a circuit following the structure given in [10]. This is a circuit composed of (a) non-fault-tolerant preparation of T∣+⟩T|+\rangle, (b) flagged measurement of the logical stabiliser SXS_X, (c) full quantum error detection cycle. To make the circuit fault-tolerant (b) and (c) are repeated giving a final sequence (a)-(b)-(c)-(b)-(c). The quantum error detection cycle we employ measures each stabiliser generator of the code once, using a separate flag gadget for each. If any stabiliser measurement, or its flag, has a non-trivial outcome the circuit would be discarded. We first verify with Comb that this circuit is fault-tolerant, as expected.

The number of two-qubit gates in the circuit is reduced using a greedy approach that removes ancilla qubits. These ancillas correspond to the measurement of a stabiliser eigenvalue or a flag on that measurement. An ancilla is selected and removed from the circuit along with any gates that touch it. After each removal we use Comb to test if the remaining circuit is still fault-tolerant. If it is, the circuit is accepted, else it is rejected and that ancilla remains in the circuit. In either case we proceed to test subsequent ancillas until we have tested all of them.

Applying this procedure, we are able to reduce the number of two-qubit gates in the fault-tolerant T∣+⟩T|+\rangle magic state preparation for the [ ⁣[17,1,5] ⁣][\![17,1,5]\!] colour code from 298 to 193. The final circuit we find is shown in Figure 6.

Independent verification of the [ ⁣[17,1,5] ⁣][\![17,1,5]\!] circuits by simulation

To independently test Comb’s findings we simulate the magic state preparation circuits for the [ ⁣[17,1,5] ⁣][\![17,1,5]\!] code using SymFT [23] and compute the scaling of their logical error rates with physical error rate. In this appendix we give full details of these simulations. The code definitions we adopt for [ ⁣[17,1,5] ⁣][\![17,1,5]\!] are shown in Figure 5.

The simulation scheme we use is sketched in Figure 7(b). It begins by simulating the state preparation circuit with circuit level noise. The circuit noise makes all operations faulty with the same physical error rate pp: that is we insert bit-flip qubit initialisation and measurement errors, as well as single qubit and two qubit depolarising channels on gates, all with rate pp. Following this we apply a sequence of noiseless measurements and rotations that allows us to compute the logical fidelity.

Figure 7. Simulation scheme outline and numerical results for the optimised d=5d = 5 circuit for the [[17,1,5]][[17, 1, 5]] code. (a) Post-selection acceptance rate for the circuit. The acceptance rate drops exponentially with the physical error rate pp. (b) Simulation workflow executed in SymFT [23]. First, the magic state preparation circuit is simulated with circuit noise at rate pp. Following this we noiselessly extract the full syndrome of the output state and apply a noiseless logical T†T^\dagger rotation. Dependent on the syndrome we may now want to measure the logical Xˉ\bar{X} or Yˉ\bar{Y} operator in order to compute the logical error rate. To achieve this we repeat the simulation twice, once with a final measurement in the logical Xˉ\bar{X} basis and again in the logical Yˉ\bar{Y} basis. (c) Logical error rate is computed from measuring the output state in the {T∣+⟩,T∣−⟩}\{T\lvert+\rangle,T\lvert-\rangle\} basis. On a per-shot basis the syndrome determines whether measuring Xˉ\bar{X} or Yˉ\bar{Y} after the logical T†T^\dagger corresponds to measuring in the {T∣+⟩,T∣−⟩}\{T\lvert+\rangle,T\lvert-\rangle\} basis or the rotated {T∣+i⟩,T∣−i⟩}\{T\lvert+i\rangle,T\lvert-i\rangle\} basis. To fully characterise the output state we can additionally measure in logical Zˉ\bar{Z}. These three sets of measurement basis are indicated on the logical Bloch sphere. (d) Logical error rate LL as a function of physical error rate pp showing scaling L∼p3L \sim p^3 consistent with the circuit being fault-tolerant to d=5d = 5. Logical error rate is computed as the fraction of shots that return T∣−⟩T\lvert-\rangle during the measurement in the {T∣+⟩,T∣−⟩}\{T\lvert+\rangle,T\lvert-\rangle\} basis. (e) Expectation value of the measurements in the two other basis, we see these are consistent with zero as expected.

The logical fidelity is the overlap between the output state of the circuit and the ideal state T∣+⟩T|+\rangle. Characterising the logical fidelity by reconstructing the logical Bloch vector (⟨Xˉ⟩,⟨Yˉ⟩,⟨Zˉ⟩)(\langle\bar{X}\rangle,\langle\bar{Y}\rangle,\langle\bar{Z}\rangle) and computing its projection onto the T∣+⟩T|+\rangle state would require a very large number of samples: ∼1014\sim10^{14} for logical error rates ∼10−7\sim10^{-7}. To avoid this sampling cost we measure directly in the {T∣+⟩,T∣−⟩}\{T|+\rangle,T|-\rangle\} basis, Figure 7(c).

Measuring in the {T∣+⟩,T∣−⟩}\{T|+\rangle,T|-\rangle\} basis is achieved by adding the following noiseless operations to the end of the simulation, Figure 7(b): (1) extracting the full syndrome S⃗\vec{S}, (2) applying a logical T†T^\dagger rotation and (3) measuring in either the logical Xˉ\bar{X} or Yˉ\bar{Y} basis as determined by S⃗\vec{S}. We decode the syndrome S⃗\vec{S} with a code-capacity decoder (described below), this yields a physical Pauli error EE that we believe to be equivalent, up to stabilisers, to the error that is present on the state. If we encounter a syndrome that is not in the code-capacity decoder we reject the sample as an additional post-selection. If EE commutes with the logical Zˉ\bar{Z} then the logical T†T^\dagger acts correctly and T∣+⟩T|+\rangle is rotated back to ∣+⟩|+\rangle and so we measure in the Xˉ\bar{X} basis. However, if EE anti-commutes with Zˉ\bar{Z} then T†T^\dagger is flipped to TT and T∣+⟩T|+\rangle is rotated instead to ∣+i⟩|+i\rangle, in this case we measure in the Yˉ\bar{Y} basis. To avoid the need to dynamically choose the final measurement basis at runtime we run the simulation twice: once with the measurement in the Xˉ\bar{X} basis and again in the Yˉ\bar{Y} basis. When we post-

process the data, we use the syndrome of each sample to determine whether its measurement corresponds to the {T∣+⟩,T∣−⟩}\{T\lvert+\rangle,T\lvert-\rangle\} basis or the rotated {T∣+i⟩,T∣−i⟩}\{T\lvert+i\rangle,T\lvert-i\rangle\} basis and aggregate the statistics accordingly.

The code capacity decoder we use for the final noiseless decoding step is constructed as a lookup table over all the correctable Pauli errors of the code. The set of all correctable Pauli errors is taken to be all Paulis with CSS weight ≤2\le2, meaning that if we split them P=PXPZP = P^{X}P^{Z} as is Equation (4) we require the weight (the number of non-identity elements) of both PXP^{X} and PZP^{Z} to be ≤2\le2. To give a clarifying example the CSS weight of X1X4X5X_{1}X_{4}X_{5} would be 3 while X1Z4X5X_{1}Z_{4}X_{5} would only be 2. We iterate over all correctable errors and calculate their syndrome. If the syndrome is not already in the lookup table we add it, else we do nothing.

The logical error rate is the number of samples where we measure T∣−⟩T\lvert-\rangle when measuring in the {T∣+⟩,T∣−⟩}\{T\lvert+\rangle,T\lvert-\rangle\} basis. This is plotted versus physical error rate pp for the optimised d=5d=5 circuit in Figure 7(d), and for the full set of {17,1,5}\{17,1,5\} circuits in Figure 3. Error bars shown on the logical error rates are 95% Wilson confidence intervals. We plot the measurements in the two complementary basis of the optimised d=5d=5 circuit in Figure 7(e), with error bars showing the 95% Wald confidence intervals. Finally the acceptance rates of post-selection are plotted for the optimised d=5d=5 circuit in Figure 7(a), and for all circuits in Figure 3.

We simulate the circuits at error rates p=10−3p = 10^{-3}, 10−2.66610^{-2.666}, 10−2.33310^{-2.333}, 10−210^{-2} with the following numbers of samples: for the non-FT and d=3d=3 circuits 10710^{7}, 10610^{6}, 10610^{6}, 10610^{6}; for the d=5d=5 circuits 10810^{8}, 5×1075 \times10^{7}, 10710^{7}, 10710^{7}. The most expensive simulation, the d=5d=5 unoptimised circuit at p=10−3p = 10^{-3}, took 63 minutes on an Apple Macbook Pro with Apple M4 processor.

References

  1. [1]C. Ryan-Anderson, J. G. Bohnet, K. Lee, D. Gresh, A. Hankin, J. P. Gaebler, D. Francois, A. Chernoguzov, D. Lucchetti, N. C. Brown, T. M. Gatterman, S. K. Halit, K. Gilmore, J. A. Gerber, B. Neyenhuis, D. Hayes, and R. P. Stutz, Realization of real-time fault-tolerant quantum error correction, Phys. Rev. X 11, 041058 (2021).
  2. [2]S. Dasu, S. Burton, K. Mayer, D. Amaro, J. A. Gerber, K. Gilmore, D. Gresh, D. DelVento, A. C. Potter, and D. Hayes, Breaking even with magic: Demonstration of a high-fidelity logical non-Clifford gate (2025), arXiv:2506.14688 [quant-ph].arxiv.org/abs/2506.14688
  3. [3]C. Ryan-Anderson, N. C. Brown, M. S. Allman, B. Arkin, G. Asa-Attuah, C. Baldwin, J. Berg, J. G. Bohnet, S. Braxton, N. Burdick, J. P. Campora, A. Chernoguzov, J. Esposito, B. Evans, D. Francois, J. P. Gaebler, T. M. Gatterman, J. Gerber, K. Gilmore, D. Gresh, A. Hall, A. Hankin, J. Hostetter, D. Lucchetti, K. Mayer, J. Myers, B. Neyenhuis, J. Santiango, J. Sedlacek, T. Skripka, A. Slattery, R. P. Stutz, J. Tait, R. Tobey, G. Vittorini, J. Walker, and D. Hayes, Implementing Fault-tolerant Entangling Gates on the Five-qubit Code and the Color Code (2022), arXiv:2208.01863 [quant-ph].
  4. [4]B. Eastin and E. Knill, Restrictions on Transversal Encoded Quantum Gate Sets, Physical Review Letters 102, 110502 (2009).pubmed.ncbi.nlm.nih.gov/19392181
  5. [5]S. Bravyi and A. Kitaev, Universal quantum computation with ideal Clifford gates and noisy ancillas, Physical Review A 71, 022316 (2005).DOI
  6. [6]E. T. Campbell and M. Howard, Unified framework for magic state distillation and multiqubit gate synthesis with reduced resource cost, Physical Review A 95, 022316 (2017).DOI
  7. [7]D. Litinski, A Game of Surface Codes: Large-Scale Quantum Computing with Lattice Surgery, Quantum 3, 128 (2019).
  8. [8]C. Gidney and A. G. Fowler, Efficient magic state factories with a catalyzed |CCZ⟩ to 2|T⟩ transformation, Quantum 3, 135 (2019).DOI
  9. [9]H. Bombín, Topological codes, in Quantum Error Correction, edited by D. A. Lidar and T. A. Brun (Cambridge University Press, 2013) p. 455–481.DOI
  10. [10]C. Chamberland and A. W. Cross, Fault-tolerant magic state preparation with flag qubits, Quantum 3, 143 (2019).
  11. [11]C. Chamberland and K. Noh, Very low overhead fault-tolerant magic state preparation using redundant ancilla encoding and flag qubits, npj Quantum Information 6, 91 (2020).DOI
  12. [12]C. Gidney, N. Shutty, and C. Jones, Magic state cultivation: Growing T states as cheap as CNOT gates (2024), arXiv:2409.17595 [quant-ph].arxiv.org/abs/2409.17595
  13. [13]H. Goto, Minimizing resource overheads for fault-tolerant preparation of encoded states of the Steane code, Scientific Reports 6, 19578 (2016).DOI
  14. [14]S. Surti, L. Daguerre, and I. H. Kim, Efficient simulation of logical magic state preparation protocols, PRX Quantum 7, 020329 (2026).DOI
  15. [15]C. Gidney, Cleaner magic states with hook injection (2023), arXiv:2302.12292 [quant-ph].arxiv.org/abs/2302.12292
  16. [16]J. Dehaene and B. De Moor, The Clifford group, stabilizer states, and linear and quadratic operations over GF(2).
  17. [17]A. G. Fowler and C. Gidney, Low overhead quantum computation using lattice surgery (2019), arXiv:1808.06709 [quant-ph].arxiv.org/abs/1808.06709
  18. [18]L. E. Heyfron and E. T. Campbell, An efficient quantum compiler that reduces T count, Quantum Science and Technology 4, 015004 (2018).arxiv.org/abs/1712.01557
  19. [19]S. Cercelescu, M. Koch, and A. Pesah, Polynomial-time simulation of non-Clifford quantum error correction (2026), arXiv:2610.06811 [quant-ph].
  20. [20]M. Heinrich, On stabiliser techniques and their application to simulation and certification of quantum devices, Doctoral Thesis, Universität zu Köln (2021).
  21. [21]D. Gottesman, Surviving as a Quantum Computer in a Classical World (unpublished draft, 2026).
  22. [22]https://github.com/Quantinuum/comb.
  23. [23]W. Fang, H. Lou, and R. Li, SymFT: Universal Fault-Tolerant Quantum Circuit Simulation via Symbolic Clifford–Pauli Frames and Stabilizer Coordinates (2026), arXiv:2607.28600 [quant-ph].arxiv.org/abs/2607.28600
  24. [24]S. Sivarajah, S. Dilkes, A. Cowtan, W. Simmons, A. Edgington, and R. Duncan, T|ket⟩: A retargetable compiler for NISQ devices, Quantum Science and Technology 6, 014003 (2020).DOI
  25. [25]B. Rodatz, B. Poór, and A. Kissinger, Floquetifying stabiliser codes with distance-preserving rewrites, Quantum 10, 2202 (2026).DOI
  26. [26]B. Poór, B. Rodatz, and A. Kissinger, Ultra low overhead syndrome extraction for the Steane code, Quantum Science and Technology 11, 045009 (2026).DOI
  27. [27]B. Rodatz, B. Poór, and A. Kissinger, Fault Tolerance by Construction (2026), arXiv:2506.17181 [quant-ph].arxiv.org/abs/2506.17181
  28. [28]M. Rüsch, A. Kissinger, and B. Rodatz, Completeness for Fault Equivalence of Clifford ZX Diagrams (2026), arXiv:2510.08477 [quant-ph].arxiv.org/abs/2510.08477
  29. [29]B. W. Reichardt, Fault-tolerant quantum error correction for Steane’s seven-qubit color code with few or no extra qubits, Quantum Science and Technology 6, 015007 (2021).DOI

Paper details

vlnc:W_bpnb9zuc
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Physics and Astronomy

Not recorded for this paper · View statement →

Looking for related papers…
Contents