Using CZ states in largescale quantumcomputing architectures
Table of Contents
Magic states are distilled to complete a universal set of faulttolerant logic gates (see Extended Data Fig. 1 for an overview of the details of a generic magicstate distillation protocol). In any such protocol, input magic states with some inherent error are encoded on quantum errorcorrecting codes. The encoded magic states are then used in distillation circuits to produce better magic states with higher fidelity. We can use magic states with nearperfect fidelity to perform faulttolerant logic gates.
We choose different magicstate distillation protocols depending on the magic states we prepare. In the next section, we review details on how we can use CZ states in largescale faulttolerant quantum computing. Specifically, we can convert CZ states into Toffoli states using Pauli measurements and Clifford operations^{28}, such that we can adopt wellknown magicstate distillation protocols for further rounds of distillation^{11}. This conversion technique is probabilistic, as it depends on obtaining the correct outcome from a Pauli measurement. In addition to these results, we show how we can recover a CZ state from the output state, assuming we get the incorrect outcome of the Pauli measurement, thereby conserving the available resource states.
We also provide some examples of how we can inject small codes into larger codes in the section ‘Injecting small codes into larger codes’, as it will be required to take the encoded state we prepared in the main text and use it in subsequent rounds of magicstate distillation. Specifically, we show how to take distance2 codes and encode their state on the surface code, the heavyhex code and the colour code with a higher distance. Notably, the heavyhex code is readily implemented on the heavyhex lattice geometry on which we conducted the experiment. For each of these injection schemes, we argue that we can detect any single error that may occur. This is important to maintain the error suppression obtained when preparing the CZ state.
In the case of the colourcode stateinjection protocol, we inject the errordetecting code described in the main text directly into the larger code. In the case of the surface code and heavyhex code, however, we inject a related code, that we call the [[4, 1, 2]] code. To complete these injection protocols, we need to take the CZ state prepared on the errordetecting code and copy its logical state onto two copies of the [[4, 1, 2]] code. We give a faulttolerant procedure for this transformation in the section ‘Encoding the CZ state on two [[4, 1, 2]] codes using the heavyhex lattice geometry’.
Magicstate distillation with the CZ state
Although magicstate distillation for the CZ state has not been wellstudied in the literature, it is known that two copies of the state can be probabilistically converted into a Toffoli state using Pauli measurements and Clifford operations^{28}. Given there are known methods for distilling Toffoli states^{11}, let us review how the Toffoli state is produced from the copies of the CZ state. In the following sections, we show how to inject the CZ state into larger quantum errorcorrecting codes that are capable of performing faulttolerant Clifford operations^{17,18,45} to complete these circuits.
The Toffoli state is defined as follows:
$$ {\rm{TOF}}\rangle \propto \sum _{j,k} \,j\rangle  k\rangle  \,jk\rangle = 000\rangle + 010\rangle + 100\rangle + 111\rangle ,$$
(3)
where we sum over the bitwise values j, k = 0, 1.
Given two copies of the CZ state, \({\leftCZ\right\rangle }_{1,2}{\leftCZ\right\rangle }_{3,4}\), if we project qubits 2 and 3 onto the Z_{2}Z_{3} = −1 eigenspace, then we obtain the intermediate state
$$\left\xi \right\rangle =(\left0010\right\rangle +\left1010\right\rangle +\left0100\right\rangle +\left0101\right\rangle )/2.$$
(4)
We then obtain \(1\rangle {\rm{T}}{\rm{O}}{\rm{F}}\rangle \) with the following unitary circuit
$$\left1\right\rangle \left{\rm{TOF}}\right\rangle =C{X}_{4,3}C{X}_{3,1}C{X}_{2,1}C{X}_{1,3}\left\xi \right\rangle ,$$
(5)
where indices C and T of the controllednot gate CX_{C,T} denote the control and target qubit, respectively.
We obtain the −1 outcome by measuring Z_{2}Z_{3} of state \(\leftCZ\right\rangle \leftCZ\right\rangle \) with probability 4/9. Beyond the work in ref. ^{28}, we find that we can recover a single copy of the CZ state given the Z_{2}Z_{3} = +1 outcome at this step, thereby saving magic resource states. In the event that we obtain this measurement outcome, we produce the state
$$\left\chi \right\rangle =\left0000\right\rangle +\left0001\right\rangle +\left1000\right\rangle +\left1001\right\rangle +\left0110\right\rangle .$$
(6)
Applying the unitary operation \(C{X}_{2,3}C{X}_{2,4}\left\chi \right\rangle \) and obtaining the twoqubit parity measurement outcome Z_{3}Z_{4} = −1, we obtain the state \(\leftCZ\right\rangle \left01\right\rangle \). We obtain this state with probability 3/5, assuming we obtained the Z_{2}Z_{3} = +1 outcome previously.
Injecting small codes into larger codes
Magicstate distillation takes encoded magic states, and then processes these input states to probabilistically prepare a magic state with better fidelity. As such, it is necessary to encode magic states into quantum errorcorrecting codes. This process is commonly known as state injection.
Ideally, the injection process will introduce a minimal amount of noise to the logical state that is encoded, as this will reduce the noise of the output magic state. To this end, we look for ways to inject the magic state prepared on the fourqubit errordetecting code in larger quantumerrorcorrecting codes in such a way that local errors can be detected.
In what follows, we show how to inject the state encoded on the errordetecting code onto the surface code, the heavyhex code and the colour code, thereby increasing the distance of the code that supports the magic state. Furthermore, we argue that we can detect any single error that may occur during the injection procedure. This enables us to maintain the error suppression we demonstrated experimentally in the main text.
In the main text, we showed how to prepare the CZ state on a fourqubit errordetecting code shown in Extended Data Fig. 2 (left). As we show later, states on this code can be injected directly onto the colour code. Two of the injection schemes, encoding onto the surface code, or the heavyhex code, assume that the two logical qubits of the CZ state are encoded on two copies of the [[4, 1, 2]] code, shown in Extended Data Fig. 2 (right). In the following section, we show how to encode the magic state prepared on the errordetecting code onto two copies of the [[4, 1, 2]] code, in a faulttolerant way such that any single error can be detected. For the remainder of this section, we assume the magic state has been prepared over two copies of the [[4, 1, 2]] code.
To distinguish the two small errordetecting codes of interest consistently, throughout the Methods we will refer to the errordetecting code used in the main text as the [[4, 2, 2]] code to contrast this code with the [[4, 1, 2]] code. Specifically, we label the codes by their encoding parameters [[n, k, d]]. Both of these codes have a distance d = 2 using n = 4 physical qubits. The two codes differ by the number of logical qubits they each encode. The [[4, 2, 2]] code encodes k = 2 logical qubits and the [[4, 1, 2]] code encodes k = 1 logical qubit.
The theory of code deformations
We inject a state into a larger code^{11,19,20,21,22,23,24,25,26,41,52} using code deformation^{19,46,53}. In what follows, we describe the theory of code deformations using the stabilizer formalism. We remark that more general theories of code deformations can be found elsewhere in the literature^{46,53}. The theory we present is sufficient to describe the stateinjection operations of interest.
We describe code deformations using the stabilizer formalism^{54}. Quantum errorcorrecting codes can be described with an Abelian subgroup of Pauli operators called the stabilizer group \({\mathcal{S}}\). The encoded state lies in the common +1 eigenvalue eigenspace of the elements of the stabilizer group. We call this subspace the code space. Stabilizer codes also have associated logical operators \({\mathcal{L}}\) that can be generated by a set of mutually anticommuting pairs \({\overline{X}}_{j},{\overline{Z}}_{j}\in {\mathcal{L}}\) with 1 ≤ j ≤ k. These Pauli operators commute with the stabilizer group but are not themselves stabilizer operators. The distance of the code d is the weight of the leastweight logical operator. We can detect any single error if the code has a distance of at least d = 2. We give examples of small stabilizer codes, together with their logical operators in Extended Data Fig. 2. These examples will be relevant for the following discussion on state injection.
We measure the stabilizer operators to identify the errors. As the encoded state is specified by specific eigenstates of a list of commuting Pauli operators, finding a measurement of one or more of these operators in the incorrect eigenspace indicates that an error has occurred. By arguing that we can detect any single error, we must have a distance of at least d = 2.
A code deformation is where we perform a measurement that projects a stabilizer code onto another. Specifically, we assume we have prepared an initial code in which, once prepared, we start measuring the stabilizer operators of a second code that we call the final code. This projects the initial code onto the final code. Let us denote these two codes by their stabilizer group \({{\mathcal{S}}}_{{\rm{init}}}\) and \({{\mathcal{S}}}_{{\rm{fin}}}\), respectively. We assume errors may have occurred on the qubits of the initial state that must be detected by measuring the stabilizers of the final code. As such, this operation has an associated code distance, according to the number of local error events that must occur for an undetectable logical error to affect the encoded space.
We detect the errors by comparing repeated readings of stabilizer measurements. Specifically, once we measure the stabilizers \({{\mathcal{S}}}_{{\rm{fin}}}\), we look to compare their outcomes to stabilizers prepared in the initial code \({{\mathcal{S}}}_{{\rm{init}}}\). Variations in the values of these stabilizer measurements indicate that an error has occurred. As such we are interested in codedeformation stabilizers
$${{\mathcal{S}}}_{{\rm{def}}}={{\mathcal{S}}}_{{\rm{init}}}\cap {{\mathcal{S}}}_{{\rm{fin}}},$$
(7)
that is, stabilizers that are prepared in the initial system and checked again after the code deformation is made, when we measure the stabilizer group \({{\mathcal{S}}}_{{\rm{fin}}}\).
Logical information that is preserved over the code deformation has coinciding logical operators associated with both \({{\mathcal{S}}}_{{\rm{init}}}\) and \({{\mathcal{S}}}_{{\rm{fin}}}\). Specifically, the logical operators that are preserved over the code deformation \({\mathcal{L}}\) are of the form
$${\mathcal{L}}={{\mathcal{L}}}_{{\rm{init}}}\cap {{\mathcal{L}}}_{{\rm{fin}}},$$
(8)
where \({{\mathcal{L}}}_{{\rm{init}}}\) and \({{\mathcal{L}}}_{{\rm{fin}}}\) are the logical operators for \({{\mathcal{S}}}_{{\rm{init}}}\) and \({{\mathcal{S}}}_{{\rm{fin}}}\), respectively.
Ideally, we should maximize the number of stabilizers that coincide in the initial and final codes to maximize the number of errors we detect. In practice, physical constraints imposed by hardware may not allow us to maximize the intersection between \({{\mathcal{S}}}_{{\rm{init}}}\) and \({{\mathcal{S}}}_{{\rm{fin}}}\). Here we concentrate on very simple initialization procedures in which the initial stabilizer code is prepared in a product state, or a product state of Bell pairs, together with the small fourqubit codes that initially maintain the encoded magic state.
Error correction for state injection
In what follows, we will show state injection into the surface code, the heavyhex code and the colour code. We will also argue that all of these stateinjection protocols are tolerant to a single error, thereby maintaining the error suppression achieved in the experiment presented in the main text.
We are interested in the general error model, in which a single error occurs on a circuit element in the stabilizer readout circuit as we deform the initial code onto the final code. However, we argue that for each individual example, we need to study only singlequbit errors that occur immediately before the code deformation takes place.
In addition to the errors that occur on data qubits, we are also interested in errors that occur on the auxiliary measurement qubits we use to perform parity measurements. In essence, these can lead to two types of error: (1) readout errors, in which we obtain the incorrect measurement outcome; and (2) hook errors, in which an error during a stabilizer readout circuit is copied to several other qubits, thereby creating a correlated error. Let us mention how we treat these types of error in the following discussion.
First of all, we neglect to discuss hook errors, as we assume that measures can be taken to mitigate their effects, by either flag qubits or an appropriate choice of stabilizer readout circuit. These measures are well developed for the codes of interest, see, for example, refs. ^{27,55,56,57}. We completed the experiment presented in the main text using a device that is tailored to realize the heavyhex code using additional flag qubits to mitigate the effects of hook errors.
We can detect a measurement error using a generic method, namely, the repetition of measurements. By repeating the measurements at least once, we can identify a single measurement error if the outcomes of two repetitions of the same measurement do not agree. As this method is applicable to all of the following injection schemes, we will not discuss this errordetection method case by case. Rather, we argue now that by measuring the stabilizer generators of \({{\mathcal{S}}}_{{\rm{fin}}}\) twice we can detect any single error. If the measurements of the two rounds of \({{\mathcal{S}}}_{{\rm{fin}}}\) do not agree, we discard the state we have prepared and repeat the statepreparation procedure. Otherwise, assuming the two rounds of measurement for \({{\mathcal{S}}}_{{\rm{fin}}}\) do agree, we check the outcomes to determine whether any Pauli errors occurred during the preparation of \({{\mathcal{S}}}_{{\rm{init}}}\), or immediately before the \({{\mathcal{S}}}_{{\rm{fin}}}\) stabilizer generators are measured. Assuming no error is detected, we continue to conduct standard error correction with the final code.
Surface code
Let us start by discussing the example of the surface code^{58} (Extended Data Fig. 3). The stabilizers of the code are shown by the faces in Extended Data Fig. 3 (left), in which the light faces mark the support of PauliXtype stabilizers and the dark faces mark the support of PauliZtype stabilizers. We also show the support of a PauliX logical operator in green and a PauliZ logical operator in blue. In the theory for code deformation given above, this is the stabilizer group for \({{\mathcal{S}}}_{{\rm{fin}}}\).
In Extended Data Fig. 3 (right), we show \({{\mathcal{S}}}_{{\rm{init}}}\). The figure shows the [[4, 1, 2]] code outlined in red in the bottomleft corner of the lattice. The remaining qubits are prepared in a product state, such that the blue qubits are initialized in the 0〉 state and the green qubits are initialized in the +〉 state. These disentangled qubits can be regarded as being in the stabilizer state Z_{v} or X_{v}. The logical operator of the initial state can be supported entirely on the [[4, 1, 2]] code. However, the initial code shares the logical operators of the final code if we multiply the logical operators of the [[4, 1, 2]] code by the product state stabilizers.
Importantly, all the qubits support at least one stabilizer operator of \({{\mathcal{S}}}_{{\rm{def}}}\) such that a single error can be detected. We note that the qubits that are initialized in a product state need to detect only one type of error, because the other type of error acts trivially on the initial state. For example, a PauliX error acts trivially on a green qubit and a PauliZ error acts trivially on a blue qubit, whereas, respectively, a PauliZ or PauliX error on the same qubit will be detected by a stabilizer of \({{\mathcal{S}}}_{{\rm{def}}}\). Finally, all qubits of the [[4, 1, 2]] code support one of each type of stabilizer of \({{\mathcal{S}}}_{{\rm{def}}}\) and as such can also detect both types of Pauli error. By inspection then, we see that we can detect any singlequbit error that occurs at the initialization step.
Heavyhex code
We can also inject the [[4, 1, 2]] code into the heavyhex code. This is particularly relevant with respect to the experiment presented in the main text, as the experiment is implemented on hardware that is tailored to realize the heavyhex code. The heavyhex code is a subsystem code closely related to the surface code. However, as the code is a subsystem code, stabilizers are not measured directly. Rather, we have a group of check operators, known as the gauge group, that we measure to infer the values of the stabilizer operators. Nevertheless, we find the arguments given above are sufficient to show that a state can be injected while detecting a single error.
To review, the gauge group of the heavyhex code includes weight2 PauliZ terms on adjacent pairs of qubits that share a row. We show one such term in Extended Data Fig. 4 (left). The code also has PauliXtype checks. These are identical to the PauliXtype stabilizer operators of the surface code (Extended Data Fig. 3). These checks are used to infer PauliX and PauliZtype stabilizer operators. The PauliXtype stabilizer operators are the product of PauliX terms on all of the qubits on two adjacent rows (Extended Data Fig. 4, left). The PauliZ stabilizer operators are the same as those of the surface code (Extended Data Fig. 3). We also show the support of logical PauliX and PauliZ stabilizer operators in Extended Data Fig. 4 (left) in green and blue, respectively. Once again, this stabilizer group can be regarded as \({{\mathcal{S}}}_{{\rm{fin}}}\) with respect to the simplified codedeformation theory we have presented. Although we infer their values from measuring the gauge checks, the basic theory of state injection holds for our discussion on error correction.
We show \({{\mathcal{S}}}_{{\rm{init}}}\) for the heavyhex code in Extended Data Fig. 4 (right), in which the [[4, 1, 2]] code, highlighted in red, is prepared on qubits in the bottomleft corner of the lattice, and the green qubits are prepared in the +〉_{v} state and the blue qubits are prepared in the 0〉_{v} state. These qubits have an associated stabilizer X_{v} or Z_{v}. Once again, similar to the case of surface code, the logical operators that are completely supported on the [[4, 1, 2]] code can be multiplied by elements of the stabilizer group of \({{\mathcal{S}}}_{{\rm{init}}}\) such that they are equivalent to those of \({{\mathcal{S}}}_{{\rm{fin}}}\) shown in Extended Data Fig. 4 (left). As such, the encoded logical information is preserved over the stateinjection procedure, as these logical operators are members of \({{\mathcal{L}}}_{{\rm{def}}}\).
As with the case of the surface code, we argue that we can tolerate any singlequbit error during the injection procedure. Every single green qubit supports at least one PauliXtype stabilizer and every single blue qubit supports at least one PauliZtype stabilizer of \({{\mathcal{S}}}_{{\rm{def}}}\). As such, we can detect a single PauliZ error on the green qubits and a single PauliX error on the blue qubits that occurs up to the point the code deformation takes place. We are not concerned with PauliX errors acting on the green qubits and the PauliZ errors acting on the blue qubits as these errors act trivially on the initial state. Finally, all of the qubits of the [[4, 1, 2]] code support both a PauliX and a PauliZtype stabilizer of \({{\mathcal{S}}}_{{\rm{def}}}\), and as such, they can all detect both types of error. This accounts for singlequbit errors occurring on all of the qubits of the system during the stateinjection process with the heavyhex code.
Colour code
Let us finally discuss the colour code^{59}. This is a particularly interesting example as the [[4, 2, 2]] code can be injected directly into the colour code. We show the colourcode lattice in Extended Data Fig. 5. For \({{\mathcal{S}}}_{{\rm{fin}}}\), each lattice face supports both a PauliX and PauliZtype stabilizer. The code supports two logical operators, where \({\overline{X}}_{A}\) is the product of PauliX terms supported on all the qubits along the bottom boundary of the lattice and \({\overline{Z}}_{A}\) is the product of PauliZ terms supported on all the qubits along the left boundary of the lattice. Likewise \({\overline{X}}_{B}\) is the product of PauliX terms supported on all the qubits along the left boundary of the lattice and \({\overline{Z}}_{B}\) is the product of PauliZ terms supported on all the qubits along the bottom boundary of the lattice. We highlight the support of the logical operators on the left and bottom boundaries in blue and green, respectively, in Extended Data Fig. 5.
We define the stabilizer group for \({{\mathcal{S}}}_{{\rm{init}}}\) in the caption of Extended Data Fig. 5, in which the [[4, 2, 2]] code is placed on a fourqubit face of the lattice, and all of the other qubits are prepared in Bell pairs, with stabilizer operators X_{a}X_{b} and Z_{a}Z_{b}, marked by highlighted edges in the figure. We colour the edges either blue or green according to the colouring convention for edges used in ref. ^{59}. Nevertheless, all highlighted edges, of both colours, support the same Bell pair.
We can multiply the logical operators of the [[4, 2, 2]] code by elements of \({{\mathcal{S}}}_{{\rm{init}}}\) such that we obtain the logical operators of \({{\mathcal{S}}}_{{\rm{fin}}}\). As such, the logical qubits encoded on the errordetecting code are preserved over the stateinjection process.
We finally argue that we can detect any singlequbit error during the state injection process. Extended Data Fig. 5 shows the support of the stabilizer operators of \({{\mathcal{S}}}_{{\rm{def}}}\) with coloured faces. Specifically, there is both a PauliX and PauliZtype stabilizer on each of the coloured faces. By inspection, we see that every qubit supports at least one coloured face and, therefore, supports both a PauliX and a PauliZtype stabilizer. We note also that the errordetecting code also supports both a PauliX and a PauliZtype stabilizer on its respective face. As such, we can detect any singlequbit error over the stateinjection process.
Some remarks on stateinjection procedures
We have presented stateinjection protocols for several different codes for the errorsuppressed magic state we discussed in the main text. We argued that we can detect a single error that may occur in any of these protocols, such that we maintain the error suppression we have demonstrated in our experiment. The injection protocols we have presented can be improved by combining them with other methods presented in the literature to improve the performance and yield of state injection. For instance, in refs. ^{20,24}, twostep preparation procedures are proposed, in which a magic state is injected onto an intermediatesized code, where error detection is used to suppress errors, before injecting the intermediatesized code onto a larger code. This method is compatible with the injection protocols we have presented here. We might also adopt the method presented in ref. ^{25}, in which the authors propose estimating the logical error on the injected state in the decoding step of state injection.
It is worth remarking that these errordetection protocols can be improved by increasing the fraction of error events that can be detected. We might, for example, consider better choices of \({{\mathcal{S}}}_{{\rm{init}}}\) that can be prepared before the stateinjection procedure begins. In the case of subsystem codes, we might also look for additional errordetection checks that can be made between intermediate gauge measurements we make to infer the values of the stabilizers, and the stabilizers of the initial code, during the preparation procedure.
Encoding the CZ state on two [[4, 1, 2]] codes using the heavyhex lattice geometry
Two of our stateinjection protocols described above require that the CZ state is encoded on copies of the [[4, 1, 2]] code. Here we show how to transform the encoded CZ state prepared on the [[4, 2, 2]] code as we have described in the main text onto two copies of the [[4, 1, 2]] code. This transformation is made using measurements. In this sense, it can be understood as a code deformation similar to that discussed in the previous section. We argue that we can detect any one single error over the code deformation process, thereby maintaining the error suppression obtained in the main text. We also show how this process can be mapped onto the heavyhex lattice geometry. The protocol is outlined in Extended Data Fig. 6, and we show how the outline is mapped onto the heavyhex geometry in Extended Data Fig. 7.
Before discussing the transformation, we first briefly review the ideas behind state teleportation abstractly. We can view the transformation as a small instance of a lattice surgery operation^{38} in which the gates are performed between logical qubits by measuring appropriate logical degrees of freedom. Furthermore, in this particular instance, we can view the operation as a lattice surgery operation between a small colour code and a small surface code^{48,60,61}, in which we interpret the [[4, 2, 2]] code and the [[4, 1, 2]] code as a small colour code and surface code, respectively. After performing a logical parity measurement between the two codes, the transformation is completed with a partial condensation operation of the small colour code, as described in ref. ^{48}.
To explain the operation, we consider the evolution of the stabilizers and logical operators of the code at each step of the measurement pattern shown in Extended Data Fig. 6 independently from the implementation of the code. We have three logical qubits indexed A, B and C, where, initially, A and B are encoded on the [[4, 2, 2]] code and C is encoded on the [[4, 1, 2]] code. In essence, the operation teleports the logical state encoded on qubit B onto qubit C, up to a Clifford operation. Logical qubit A is not involved in the operation, so we concentrate on qubits B and C.
The teleportation operation proceeds as follows:

1.
Prepare \({\left+\right\rangle }_{C}\),

2.
Measure X_{B}Z_{C},

3.
Measure Z_{B},

4.
Apply Pauli correction.
The operation functions with A and B prepared in some arbitrary logical state, but to illustrate the operation we assume they are in a product state with \({\left\psi \right\rangle }_{B}=a{\left+\right\rangle }_{B}+b{\left\right\rangle }_{B}\). We omit qubit A from the discussion, as it is unchanged by the transformation, and we leave it as an exercise to the reader to verify the general case.
Initially, an arbitrary state in the B subsystem along with a logical \(\left+\right\rangle \) state on the C subsystem can be described by the following vector state: \({(a\left+\right\rangle +b\left\right\rangle )}_{B}\otimes {\left+\right\rangle }_{C}\), in which we have chosen a convenient basis for the vectors on B. Upon measuring the joint logical operator X_{B}Z_{C} and obtaining measurement outcome m_{2}, the resulting state of the joint system is \(a{\left+\right\rangle }_{B}{\left{m}_{2}\right\rangle }_{C}+b{\left\right\rangle }_{B}{\left1\oplus {m}_{2}\right\rangle }_{C}\). Finally, upon measuring Z_{B} and obtaining the measurement outcome m_{3}, the resulting state is \({\left{m}_{3}\right\rangle }_{B}\otimes \left(a\right.{\left{m}_{2}\right\rangle }_{C}+{(1)}^{{m}_{3}}b{\left1\oplus {m}_{2}\right\rangle }_{C}\). An appropriate Pauli correction depending on the measurement outcomes m_{2} and m_{3} enables us to recover the state \({\left0\right\rangle }_{B}\otimes (a{\left0\right\rangle }_{C}+b{\left1\right\rangle }_{C})\). As such, we see the logical information that was originally encoded on the B subsystem in the form of the coefficients a and b now lies entirely on the C subsystem. Finally, we note that, with this operation, the basis of the logical information has been rotated by a Hadamard operation. This can be corrected at a later step. Extended Data Fig. 6 shows how this transformation is conducted between an encoded qubit of the [[4, 2, 2]] code and the logical qubit of the [[4, 1, 2]] code by performing logical measurements.
We now discuss how to implement the described state teleportation on a heavyhex lattice (Extended Data Fig. 7). We begin by preparing the encoded CZ state as explained in the main text, together with an encoded [[4, 1, 2]] code. The [[4, 1, 2]] code is prepared in the logical state +〉. We can prepare this state using qubits outlined in the orange box shown in Extended Data Fig. 7 (top), in which the four qubits, 4, 6, 15 and 17 are the data qubits of the code and qubits 5, 10 and 16 are used to perform weight4 parity checks with qubits 5 and 16 used as flag qubits. The [[4, 1, 2]] code is prepared in a faulttolerant manner by initializing the data qubits in the +〉 state and then measuring each of the PauliZtype stabilizer operators Z_{4}Z_{6} and Z_{15}Z_{17}. These measurements can be facilitated with the ancillary qubits 5 and 16, respectively. Each of these operators is measured twice such that we can detect a single measurement error during preparation (see also ref. ^{4}).
We transfer a single logical qubit of the [[4, 2, 2]] code onto the [[4, 1, 2]] code using logical measurements. In step 3, we perform a weight4 measurement that measures the parity of two logical qubits over the two codes. To do this using the heavyhexagonal lattice geometry, we first transport the codes. This can be performed in two rounds of swap gates or teleportation operations, as shown by the arrows in Extended Data Fig. 7 (top), in which the blue arrows are performed first, in parallel, and the green arrows are performed in parallel afterwards. It should be noted that these rounds of parallel swap gates are faulttolerant because all individual swap operations involve a single data qubit as well as an ancillary qubit. Thus, any potential twoqubit gate error is effectively a singlequbit error on the code that would be detected. After the swap operation, we facilitate the logical parity measurement with qubits 5, 10 and 16, shown in the green box in Extended Data Fig. 7. The logical measurement is performed twice to identify a measurement error that may occur in this step. The outcomes of both of these measurements should agree. An odd parity in measurement outcomes indicates that a measurement error has occurred.
Finally, we measure the logical operator \({\overline{Z}}_{B}\) to complete the teleportation operation. We measure this operator on both of its twoqubit supports. Specifically, these are \({\overline{Z}}_{B}={Z}_{2}{Z}_{4}\) and \({S}^{Z}{\overline{Z}}_{B}={Z}_{13}{Z}_{15}\), in which S^{Z} = Z_{2}Z_{4}Z_{13}Z_{15} is the weight4 PauliZ stabilizer of the [[4, 2, 2]] code. Measuring both of these weight2 logical operators enables us to detect a single error, as the product of their outcomes should agree with the value of the PauliZ stabilizer S^{Z}. This final measurement completes the teleportation operation and, moreover, projects the errordetecting code onto a second copy of the [[4, 1, 2]] code. Finally, we remark that projecting \({\overline{Z}}_{B}\) into a known eigenstate enables us to regard this logical operator as a weight2 stabilizer. As such, we can now regard the [[4, 2, 2]] code that we prepared initially as a [[4, 1, 2]] code. We, therefore, have the state \({\mathbb{1}}\otimes H\leftCZ\right\rangle \) encoded on the logical space of two [[4, 1, 2]] codes shown in the purple and orange boxes shown in Extended Data Fig. 7(bottom).
Analysis in terms of singlegate errors
All circuits considered, both for magicstate preparation and logical tomography, use redundancy to detect errors. For the midcircuit syndrome measurements, performed with the circuit shown in Fig. 1, this redundancy comes, in part, by using flag qubits. These yield an outcome of 0 unless an error has occurred. These outcomes are, therefore, errorsensitive events, allowing errors to be detected.
Additional errorsensitive events come from the results of the syndrome measurements themselves. For the circuit shown in Fig. 2b, these events are as follows:

1.
The results of the two \(\overline{W}\) measurements should agree.

2.
S^{X} should yield 0, because the system is prepared in a +1 eigenstate of this operator.

3.
Although the first S^{Z} will yield a random outcome, the following feedforward means that the resulting state is in the +1 eigenspace of S^{Z}. This will then be the expected outcome for the value of final S^{Z} measurement.
For concreteness, we will consider the measurement of logical ZZ, for which the final S^{Z} measurement is achieved through the final measurement of data qubits. The circuit, then, has eight flag results in addition to the above three conditions for syndrome measurements. This gives 11 errorsensitive events in all. To analyse how errors in the circuit are detected, we consider all the possible ways in which Pauli errors can be inserted around each gate. Specifically, we consider the insertion of X, Y and Z before any singlequbit gate, and all possible single and twoqubit Paulis before any twoqubit gate, on the qubits that support the gate. We then simulate each of these circuits to determine how the error is detected.
This analysis has two important uses. First, it can be used to verify the fault tolerance of the scheme, by confirming that all Pauli errors with nontrivial effect are in some way detected by the errorsensitive events. Second, it can be used to determine the specific combination of errorsensitive events, s, that detect each error. This information can then be used to infer the corresponding probabilities ε_{s} that such errors occurred, by looking at how often the corresponding error signature occurs within the outcomes measured.
After performing this analysis, it was found that the circuit is faulttolerant. The only cases in which an error was not detected are those where the system was in an eigenstate of the error operator, or where its application was immediately followed by a measurement in an eigenbasis of the Pauli error. In both of these cases, the error will have a trivial effect on the circuit output.
When calculating the ε_{s}, it is important to note that the error signatures, s, are not necessarily unique for each type of error. For example, X and Y Paulis inserted immediately before any measurement will yield the identical effect of a measurement error. We, therefore, also determine the degeneracy, N_{s}, for each error signature. This is the number of unique errors that gives rise to the same error signature. With this information, we can then analyse the syndrome outcomes from experimental data, looking for these signatures and determining the probabilities with which they occur^{32}.
Owing to the limited number of errorsensitive events used in this experiment, these probabilities can be calculated directly. The combined probability, ε_{s}, for all forms of error that lead to a particular signature is determined using the number of shots for which that signature occurs, n_{s}, and the number of shots for which no error is detected, n_{0}. The ratio of these numbers of shots will be the ratio of the probability that the error occurs with the probability that it does not:
$$\frac{{n}_{s}}{{n}_{0}}\approx \frac{{\varepsilon }_{s}}{1{\varepsilon }_{s}}.$$
(9)
Simply rearranging this relation gives us the value of ε_{s} (ref. ^{62}). We then use the degeneracy to obtain the average probability for each possible singlequbit Pauli error with this signature: ε_{s}/N_{s}.
Standard magicstate preparation circuits
Here we describe magicstate preparation circuits with no error suppression that are compared with our errorsuppressed scheme described in the main text.
In Extended Data Fig. 8a, we show a circuit that prepares an encoded CZ state by, first, preparing a CZ state on two physical qubits and, then, encoding the state such that the Pauli observables of the two qubits of the CZ state can be represented as logical operators of the errordetecting code we encode. Finally, we measure the stabilizer operators of the code to encode the state, assuming we obtain the correct stabilizer measurement outcomes. The circuit used for the preparation step is shown in Extended Data Fig. 8b.
We can make use of the stabilizer operators of the CZ state to simplify the preparation circuit shown in Extended Data Fig. 8b. We define a stabilizer operator U, with respect to state \(\left\psi \right\rangle \), as an operator for which the action is trivial on its respective state, that is, \(U\left\psi \right\rangle =\left\psi \right\rangle \). We can check that the CZ state is invariant under the action of a controllednot gate conditioned on the control qubit in the zero state
$$C{X}^{{\prime} }=\left1\right\rangle \left\langle 1\right\otimes {\mathbb{1}}+\left0\right\rangle \left\langle 0\right\otimes X.$$
This unitary gate is equivalent to a standard controllednot gate, \(CX=\left0\right\rangle \left\langle 0\right\otimes {\mathbb{1}}+\left1\right\rangle \left\langle 1\right\otimes X\), followed by a bit flip on the target qubit, that is,
$$C{X}^{{\prime} }=({\mathbb{1}}\otimes X)CX.$$
This observation enables us to simplify the preparation circuit. Once the CZ state is prepared, we add the \(C{X}^{{\prime} }\) gate in the dashed box in Extended Data Fig. 8, as the state we have prepared at this stage is invariant under this inclusion. The inclusion of this operator enables us to simplify the circuit, as the repeated application of the two PauliX rotations and the repeated application of two controllednot operations used in the circuit act like an identity operation. This trivial step in the circuit is marked on the figure between vertical dashed lines. We can, therefore, omit all of the controllednot operations and the bitflip operations from the circuit shown in our implementation of this method of state preparation. As such, this preparation step includes only two entangling gates: a controlled Hadamard gate and a swap gate. We perform logical tomography by appending the circuits shown in Fig. 2b,c to the end of the circuit shown in Extended Data Fig. 8a. Likewise, we can perform physical tomography on the output of the circuit shown in Extended Data Fig. 8a.
Moreover, we note that the CZ state is also stabilized by the swap gate:
$${\rm{swap}}=({\mathbb{1}}+X\otimes X+Y\otimes Y+Z\otimes Z)/2,$$
and CZ as defined in the main text. The CZ state is uniquely stabilized by the Abelian stabilizer group generated by the set \(\langle CZ,\,C{X}^{{\prime} }{\rm{swap}}\rangle \).
Finally, we also compare our errorsuppressed magicstate preparation scheme to a circuit that prepares the same magic state on two physical qubits (Extended Data Fig. 8c). We prepare the state on two physical qubits using a single entangling gate, together with singlequbit rotations, before measuring the state in varying singlequbit Pauli bases, P and Q, to conduct state tomography on the circuit output.
Device overview
Encoded state data collection on ibm_peekskill v.2.4.0 spanned several days over a single region. During this time, monitoring experiments were interleaved with tomography data collection trials. Device coherence times for all qubits exceed about 100 μs and twoqubit errors per gate was found to range from 0.35% to 0.59%. Detailed monitoring of readout errors are provided in Extended Data Fig. 9f,g and timeaveraged readout fidelities ranged from 98.1% to 99.6% for all qubits. Average device characterization data are summarized in Extended Data Tables 1 and 2. Unencoded magicstate data were collected over a single 24h period on ibm_peekskill v.2.5.4 on all physical pairs and the bestperforming edge is reported in Extended Data Table 2. Although the unencoded magicstate data were not interleaved with encodedstate tomography, the bestperforming pair of physical qubits was found to have a low twoqubit error per gate of 0.38%, and this error is comparable with the lowest twoqubit error per gate for edges used in the encoded magicstate experiments.
Realtime feedforward control of qubits
In the past decade, several experiments were performed that exploit fast feedback or realtime control within the execution of a quantum program. Fast feedback has been used for conditional reset^{63,64,65,66}, state and gate teleportation^{67,68,69} with low branching complexity and in more demanding algorithms such as the iterativephase estimation protocol^{70}, to name a few. More recently, there have been demonstrations of quantum error correction using realtime control in various systems^{2,6,71,72}. There have also been examples of work toward classicalcontrol microarchitectures that enable the seamless integration of qubits and classical operations with tens of qubits.
Our work was performed with the firstgeneration realtime control system of IBM Quantum, in which we use centralized processing of midcircuit measurement outcomes to classically condition a quantum circuit. The control system architecture is based on a hierarchical heterogeneous system of fieldprogrammable gate array controllers with computing elements for concurrent realtime processing, microwave control and qubit readout. These are synchronized through a global clock and linked with a realtime communication network to enable synchronized collective operations such as control flow. Branching incurs a constant latency penalty to execute the branch (of the order of 500 ns). Realtime computations will incur a variable latency overhead depending on the complexity of the decision. The system provides specialized fastpath controlflow capabilities for rapid and deterministic conditional reset operations. Collective control of the system requires orchestration through a proprietary heterogeneous hardware compiler and code generator. We use an openaccess platform that is programmable through Qiskit and OpenQASM 3—an opensource imperative Cstyle realtime quantum programming language^{73}. All experiments were performed through Qiskit and IBM Quantum Services^{74,75}.
Estimates for magicstate yield
Let us attempt to model the error rate of the components of the device using the yield we have evaluated experimentally. The yield is a helpful figure of merit as it tells us precisely how often a singleerror event occurs to leading order in the error rate. We first try to model the yield using simple threeparameter models that we derive below. We also compare the yield to numerical simulations of our circuits. We show the estimated yield for different experiments in Extended Data Table 3, in comparison with our analytical model and numerical results.
Both of our analyses have good agreement with the experiment if we assume a twoqubit gateerror rate and a measurement error rate of the order of 2%. This is a high error rate compared with those measured in Extended Data Tables 1 and 2. However, we remark that neither our analytical model nor our simulations account for common error processes such as leakage, cross talk, twolevel systems and idling errors that may occur during slowcircuit processes that will introduce additional noise to the system. We suggest discrepancies in our modelling, and the experimentally observed yields can be attributed to these details that are difficult to model analytically or numerically.
Let us present our analytical model to evaluate the yield. We can estimate the magicstate yield as QR, where Q is the probability that the random measurement outcomes we obtain throughout our experiment yield the values we need to complete the magicstate preparation scheme and R is the probability that the experiment does not experience a single error.
If we have that ε_{P} is the probability that a single parity measurement introduces an error and D is the number of parity measurements that are conducted in an experiment, that is, the depth, we can write \(R={(1{\varepsilon }_{P})}^{D}\), thereby giving the equation
$$\,{\rm{logical\; yield}}\,=Q{(1{\varepsilon }_{P})}^{D}.$$
(10)
We note that Q and D vary for different experiments.
For our rough calculation, we find reasonably good agreement with the experimental data if we take ε_{P} ≈ 22%. This equates, approximately, to a twoqubit gateerror rate and a measurement error rate of about 2%. Each parity measurement we perform uses eight entangling gates and three midcircuit measurements. Therefore, neglecting higherorder terms, we obtain the probability that a parity measurement introduces a single error is
$${\varepsilon }_{P}\approx 8{\varepsilon }_{2Q}+3{\varepsilon }_{M},$$
(11)
where ε_{2Q} is the twoqubit gateerror rate and ε_{M} is the probability of a measurement error. If we set ε_{2Q} = ε_{M} = 2%, we find that ε_{P} = 22%.
We also need to predict Q for different experiments. Let us begin with the errorsuppressed experiment in which we use feedforward. Here, in the noiseless case, we have one random measurement outcome, in which we initially measure \(\overline{W}\). It is readily checked that the probability that we project the ++⟩ state onto the +1 eigenvalue eigenspace of the CZ operator is Q_{FF} = ⟨++∣(1 + CZ)∣++⟩/2 = 3/4. In the case that we do not use feedforward, in addition to obtaining the correct outcome for the \(\overline{W}\) measurement, we must also postselect on obtaining the correct outcome of the initial measurement of S^{Z}. We obtain the +1 eigenvalue subspace of this operator with probability 1/2. We, therefore, have Q_{PS} = 3/4 × 1/2 = 3/8. Finally, in the standard preparation procedure, we measure both S^{Z} and S^{X}, and we require that both give the +1 outcome. Each measurement gives the correct outcome with probability 1/2. We, therefore, have Q_{STND} = 1/2 × 1/2 = 1/4.
Let us comment on the features of this model that agree with the experiment. First of all, we observe that the errorsuppressed scheme using feedforward has a consistently better yield than the other two schemes, both the errorsuppressed scheme using postselection and the standard preparation scheme. Furthermore, we observe that the errorsuppressed postselection scheme and the standard scheme have comparable yields, for both tomography circuits shown in Fig. 2.
Furthermore, our model explains the difference in yield between different tomography experiments conducted using the two different circuits shown in Fig. 2. The tomography circuit in Fig. 2c uses two additional parity measurements than that shown in Fig. 2b. As such the tomography circuit in Fig. 2c is inherently more noisy than that in Fig. 2b. This is reflected in Fig. 4 in which the yield for tomography circuits shown in Fig. 2b,c are shown in Fig. 4 (left, right).
Our rudimentary analytical model correctly predicts several qualitative features of our experimental data. However, it neglects many details of the circuit. As we might expect, we find better agreement with the experimentally observed yield if we simulate our circuit. We assume an error rate for each of the twoqubit entangling gates and a measurement error rate of 2%. These results are also shown in Extended Data Table 3. Again, the physical error rate of these circuit elements is considerably higher than the observed error rates of these components. As mentioned at the beginning of this section, we attribute this to noise processes that are not captured by either our analytical model or our numerical simulations. In practice, it is extremely difficult to capture all of the physical details that occur in an experiment.
State tomography with readout error mitigation using noisy positiveoperatorvalued measurements
The state tomography in the main text uses the Qiskit Experiments implementation of state tomography^{31}. A notable change from the previous works is that we do not use readout error mitigation in the main text. Instead, we perform tomographic fitting assuming ideal measurements, which attributes any undetectable measurement errors to errors in the reconstructed quantum state. For physical tomography, we use the cvxpy_gaussian_lstsq fitter with measurement data using the default Paulimeasurement basis on each physical qubit to obtain a weighted maximumlikelihood estimate, constrained to the space of positive, semidefinite, unit trace density matrices. For logical tomography, we use the cvxpy_linea_lstsq fitter with a custom measurement basis using Pauli expectation values, rather than Pauli eigenstate probabilities. In this case, the custom fitter weights are calculated from the inverse of the standard error in the Pauli expectation value estimates for each postselected logical Pauli operator measurement.
Susceptibility to measurement error is a common issue in tomographic methods. In general, tomographic tools are only as good as the noise model of the measurement apparatus, that is, our ability to calculate the likelihood representing the conditional probability of obtaining a dataset given some test density matrix. In this section, we discuss an alternative approach combining readout error characterization with tomographic reconstruction. Although the dominant measurement error source in tomography experiments is because of qubit readout, it is a common practice to assume local, uncorrelated readout errors in the Z basis. A set of noisy positive operatorvalued measurements (POVMs) on a singlequbit is,
$${Z}_{0}^{{\prime} }:=\left[\begin{array}{cc}1p & 0\\ 0 & q\end{array}\right],{Z}_{1}^{{\prime} }:=\left[\begin{array}{cc}p & 0\\ 0 & 1q\end{array}\right],$$
(12)
where p is the probability of assigning outcome 1 to a state initially prepared as 0⟩ and q is the probability of assigning outcome 0 to astate initially prepared as 1⟩; that is, p = P(1∣0) and q = P(0∣1). We can also construct noisy POVMs for measurements in the PauliX or PauliY eigenbases by rotating the noisy POVMs shown in equation (12) by an appropriate angle assuming ideal unitaries, because the measurement error is typically several orders of magnitude greater than the onequbit gate error.
By interleaving small batches of experimental data collection with readout calibration experiments, one can construct noisy POVMs for each data qubit applicable to a small duration of data collection to be used in fitting procedures discussed above. In Extended Data Fig. 9a, state infidelities from fitting with noisy POVMs can be compared with fitting with ideal projectors (p, q ≡ 0), in which the latter is reported in the main text. Using readout mitigation, the faulttolerant tomography routines far outperform both unencoded tomography and the physical tomography of the encoded state. As the terminating measurements in logical tomography are very similar to those in physical tomography, we would expect both of these experiments to demonstrate similar infidelities. Resolving this discrepancy remains an open research question.
Furthermore, it is unclear if our assumed construction of noisy POVMs, or the measured readout error calibrations, collectively reflect the true measurement errors experienced by data qubits. We, therefore, test the sensitivity of the outcomes of state tomography to the choice of measurement compensation in Extended Data Fig. 9b–d. State infidelity is calculated by fitting experimental tomography data to POVMs parameterized by p and q. To simplify, these readout error probabilities are set to be constant for all qubits and time. Darkblue regions of low infidelity (with the minima marked with a red star) do not coincide with the state infidelity calculated using the global average of experimentally measured readout calibrations (marked by a black dot). This disparity suggests that either the target experiments experienced initialization or measurement errors at a higher rate than measured by simpler calibrations and/or fitting with potentially incorrect Amatrices yields a highly nonpositive state that is mapped to a highfidelity physical state under constrained optimization.
Combining readout mitigation with tomography thus remains an open question for further work, and the results of the main text are limited by unaddressed readout error on terminal measurements. We expect that state tomography experiments in Extended Data Fig. 9b–e at p = q = 0 provide a reasonable upper bound on the error of the underlying magic state.