$\displaystyle=|\mathbf{x}\wedge\mathbf{y}\wedge\mathbf{z}|,$

where in the last line we have noted that the summation is exactly the triple
dot-product between these vectors. Substituting this back into Eq. 396 we have

$\displaystyle\text{CCZ}^{\otimes
n}|(\mathbf{x},\mathbf{u})G^{A}\rangle|(\mathbf{y},\mathbf{v})G^{B}\rangle|(\mathbf{z},\mathbf{w})G^{C}\rangle$
(401)
$\displaystyle=(-1)^{|\mathbf{x}\wedge\mathbf{y}\wedge\mathbf{z}|}|(\mathbf{x},\mathbf{u})G^{A}\rangle|(\mathbf{y},\mathbf{v})G^{B}\rangle|(\mathbf{z},\mathbf{w})G^{C}\rangle.$

Since the dependence on $\mathbf{u}$, $\mathbf{v}$ and $\mathbf{w}$ has
vanished, $\text{CCZ}^{\otimes n}$ acts identically on every term in the
superposition comprising the logical computation basis states so we have

$\displaystyle\text{CCZ}^{\otimes
n}|\mathbf{x}\rangle_{L}|\mathbf{y}\rangle_{L}|\mathbf{z}\rangle_{L}$
$\displaystyle=(-1)^{|\mathbf{x}\wedge\mathbf{y}\wedge\mathbf{z}|}|\mathbf{x}\rangle_{L}|\mathbf{y}\rangle_{L}|\mathbf{z}\rangle_{L}.$
(402)

This is precisely the phase expected from $\text{CCZ}^{\otimes
k}=\prod_{j}\text{CCZ}_{Lj}$ since each $\text{CCZ}_{Lj}$ contributes one term
$x_{j}y_{j}z_{j}$ to the phase exponent. ∎

We remark that the above proof closely follows previous work on 3D surface
codes [146] but generalised to arbitrary $k$. This approach could be further
extended using a proof technique similar to Refs. [142, 141] to cover cases
where: the logical unitary is not $\text{CCZ}^{\otimes k}$ but some other non-
Clifford unitary; and/or the full codespace is not necessarily divisible into
3 equal sized blocks. However, this more sophisticated approach is not
required for our present purposes.

Rather, we are interested in the special case

######  Lemma 2.

Consider a trio of $G$-matrices as follows

$G^{A}=\left(\begin{array}[]{c}\mathbf{u}_{1}\\\ \mathbf{u}_{2}\\\
\hline\cr\mathbf{1}\end{array}\right),G^{B}=\left(\begin{array}[]{c}\mathbf{u}_{2}\\\
\mathbf{u}_{3}\\\
\hline\cr\mathbf{1}\end{array}\right),G^{C}=\left(\begin{array}[]{c}\mathbf{u}_{3}\\\
\mathbf{u}_{1}\\\ \hline\cr\mathbf{1}\end{array}\right),$ (403)

where $\mathbf{1}=(1,1,\ldots,1)$. Assume that

  1. 1.

$\forall t$: $|\mathbf{u}_{t}|=\sum_{j=1}^{n}(\mathbf{u}_{t})_{j}\pmod{2}=0$ ;

  2. 2.

$\forall t,t^{\prime}$:
$|\mathbf{u}_{t}\wedge\mathbf{u}_{t^{\prime}}|=\sum_{j=1}^{n}(\mathbf{u}_{t})_{j}(\mathbf{u}_{t^{\prime}})_{j}\pmod{2}=0$
;

  3. 3.

$|\mathbf{u}_{1}\wedge\mathbf{u}_{2}\wedge\mathbf{u}_{3}|=1$.

Then the corresponding codes are $[[n,2,2]]$ codes with a tranversal logical
$\text{CCZ}^{\otimes n}=\text{CCZ}_{L}^{\otimes 2}$. For instance, these
conditions are met by setting

$\displaystyle\mathbf{u}_{1}$ $\displaystyle=(1,1,1,0,0,1,0,0),$ (404)
$\displaystyle\mathbf{u}_{2}$ $\displaystyle=(1,1,0,1,1,0,0,0),$ (405)
$\displaystyle\mathbf{u}_{3}$ $\displaystyle=(1,0,1,0,1,0,1,0),$ (406)

to produce a trio of $[[8,2,2]]$ codes with CCZ transversality as above.

The above lemma provides an example trio of $[[8,2,2]]$ codes with the desired
transversality property. To be more concrete, by combining Eq. 403 and Eqs.
404, 405 and 406 the trio of codes have $G$-matrix representation

$\displaystyle G^{A}$
$\displaystyle=\left(\begin{array}[]{cccccccc}1&1&1&0&0&1&0&0\\\
1&1&0&1&1&0&0&0\\\ \hline\cr 1&1&1&1&1&1&1&1\end{array}\right),$ (410)
$\displaystyle G^{B}$
$\displaystyle=\left(\begin{array}[]{cccccccc}1&1&0&1&1&0&0&0\\\
1&0&1&0&1&0&1&0\\\ \hline\cr 1&1&1&1&1&1&1&1\end{array}\right),$ (414)
$\displaystyle G^{C}$
$\displaystyle=\left(\begin{array}[]{cccccccc}1&0&1&0&1&0&1&0\\\
1&1&1&0&0&1&0&0\\\ \hline\cr 1&1&1&1&1&1&1&1\end{array}\right),$ (418)

By translating these matrices into $X$-stabilizers (all have the
$X[\mathbf{1}]=X^{\otimes 8}$ stabilizer) and logical $X$ operators (which
differ), we verify that these are the same codes as specified by the operators
given the main text (see e.g. Eq. 384). However, the lemma provides some
general conditions under which transversality is satisfied to provide a better
insight into the proof technique.

###### Proof.

The proof of Lemma 2 follows quickly from Lemma 1 by simply verifying all the
cases. For instance, for $p=q=r$ we have

$\displaystyle|\hat{\mathbf{o}}_{1}G^{A}\wedge\hat{\mathbf{o}}_{1}G^{B}\wedge\hat{\mathbf{o}}_{1}G^{C}|$
$\displaystyle=|\mathbf{u}_{1}\wedge\mathbf{u}_{2}\wedge\mathbf{u}_{3}|=1,$
(419)
$\displaystyle|\hat{\mathbf{o}}_{2}G^{A}\wedge\hat{\mathbf{o}}_{2}G^{B}\wedge\hat{\mathbf{o}}_{2}G^{C}|$
$\displaystyle=|\mathbf{u}_{2}\wedge\mathbf{u}_{3}\wedge\mathbf{u}_{1}|=1,$
$\displaystyle|\hat{\mathbf{o}}_{3}G^{A}\wedge\hat{\mathbf{o}}_{3}G^{B}\wedge\hat{\mathbf{o}}_{3}G^{C}|$
$\displaystyle=|\mathbf{1}\wedge\mathbf{1}\wedge\mathbf{1}|=0.$

In the second line, we have used that the triple dot product is invariant
under permutation of vectors, for instance
$|\mathbf{a}\wedge\mathbf{b}\wedge\mathbf{c}|=|\mathbf{b}\wedge\mathbf{c}\wedge\mathbf{a}|$.
The last equality in each line comes from the assumptions in Lemma 2. Since
$k=2$, we see that we indeed get unity when $p=q=r\leq k$ and zero for
$p=q=r>2$ (as required by Eq. 392). Let us consider a case when $p,q,r\leq k$
but $p\neq q$, such as

$\displaystyle|\hat{\mathbf{o}}_{2}G^{A}\wedge\hat{\mathbf{o}}_{1}G^{B}\wedge\hat{\mathbf{o}}_{1}G^{C}|$
$\displaystyle=|\mathbf{u}_{2}\wedge\mathbf{u}_{2}\wedge\mathbf{u}_{3}|$ (420)
$\displaystyle=|\mathbf{u}_{2}\wedge\mathbf{u}_{3}|=0.$

We have used the simple identity that in $\mathbb{F}_{2}$ we have $a^{2}b=ab$
and the natural extension to vectors that
$|\mathbf{a}\wedge\mathbf{a}\wedge\mathbf{b}|=|\mathbf{a}\wedge\mathbf{b}|$.
The last equality comes from the assumptions in Lemma 2 and gives the result
required by Eq. 392. By inspecting Eq. 403, we find that for any triple of
rows (except for the special case when $p=q=r$) from the upper block $G_{1}$,
two of the selected rows will be equal and so the triple dot product will
again give zero, therefore satisfying Eq. 392.

Next, let us consider a case when one row comes from $G_{0}$, for instance
$q=3$ and so

$\displaystyle|\hat{\mathbf{o}}_{1}G^{A}\wedge\hat{\mathbf{o}}_{2}G^{B}\wedge\hat{\mathbf{o}}_{3}G^{C}|$
$\displaystyle=|\mathbf{u}_{1}\wedge\mathbf{u}_{3}\wedge\mathbf{1}|$ (421)
$\displaystyle=|\mathbf{u}_{1}\wedge\mathbf{u}_{3}|$ $\displaystyle=0.$

In the second line, we have use that $a\cdot 1=a$ extends to vectors so that
in general
$|\mathbf{a}\wedge\mathbf{b}\wedge\mathbf{1}|=|\mathbf{a}\wedge\mathbf{b}|$.
The last line uses assumption 2 of Lemma 2. Indeed, whenever one (or more) of
the rows is $\mathbf{1}$, we will be able to deploy assumption 1 (or 2) of
Lemma 2. This enumerates all possible cases and confirms that Eq. 392 always
holds, therefore proving the main transversality statement of Lemma 2.

Lastly, that Eqs. 404, 405 and 406 satisfy assumptions 1-3 of Lemma 2 is
easily verified. For example,

$\displaystyle|\mathbf{u}_{1}\wedge\mathbf{u}_{2}\wedge\mathbf{u}_{3}|$
$\displaystyle=(\mathbf{u}_{1})_{1}(\mathbf{u}_{2})_{1}(\mathbf{u}_{3})_{1}+\sum_{j=2}^{8}(\mathbf{u}_{1})_{j}(\mathbf{u}_{2})_{j}(\mathbf{u}_{j})_{j}$
$\displaystyle=1+\sum_{j=2}^{8}0=1,$

where in the first line we split off the $j=1$ case from the rest of the
summation to highlight that this is the only non-zero term. A deeper
explanation is provided by noticing that the example vectors $\mathbf{u}_{t}$
correspond to generators of a Reed-Muller code for which these properties are
well-known [147].∎

Figure 60: A magic state distillation protocol for $8\text{CCZ}\rightarrow
2\text{CCZ}$ with the eight CCZ injections performed using Algorithm 2. Qubit
labels of form $(D,i)_{f}$ and $(D,j)_{BU}$ follow notation of Definition 2.
For each $j$, the triple of qubits $(A,1)_{BU}$, $(B,2)_{BU}$ and $(C,3)_{BU}$
are prepared in a noisy CCZ states (e.g. using BUTOF) but this preparation is
not shown. We show explicitly the CNOT gates for the first 2 steps and the
last step, but omit the middle steps for brevity. The full circuit is
reproducible using Eqs. 410, 414 and 418 to specify the CNOT pattern as
outlined in Algorithm 2.

###  O.3 Trading space and time

Here we construct a magic state distillation protocol from the $G$-matrix
representation of Section O.2 that minimizes space requirements. The intuition
is that one never encodes into the full codespace but rather converts the
$\text{CCZ}^{\otimes n}$ gate into a product of $n$ conjugated CCZ gates that
we can think of as being conjugated by some partial encoding unitary.

In particular, consider some $G^{D}$-matrix representing an $[[n,k,d]]$ code
and a unitary $V^{D}$ such that

$V^{D}|\mathbf{x}\rangle|\mathbf{u}\rangle|\mathbf{0}\rangle=|(\mathbf{x},\mathbf{u})G^{D}\rangle,$
(422)

where $\mathbf{x}$ is a length $k$ bit-string and $\mathbf{u}$ is length $m$
(recall $m$ the number of rows in $G_{0}^{D}$). Furthermore, it is known that
such a unitary $V^{D}$ can be found that is Clifford and composed solely of
CNOT gates [142]. It follows that

$\displaystyle V^{D}|\mathbf{x}\rangle|+^{\otimes m}\rangle|\mathbf{0}\rangle$
$\displaystyle=2^{m/2}\sum_{\mathbf{u}\in\mathbb{F}_{2}^{m}}V^{D}|\mathbf{x}\rangle|\mathbf{u}\rangle|\mathbf{0}\rangle$
(423)
$\displaystyle=2^{m/2}\sum_{\mathbf{u}\in\mathbb{F}_{2}^{m}}|(\mathbf{x},\mathbf{u})G^{D}\rangle$
$\displaystyle=|\mathbf{x}\rangle_{L},$

where the second line uses Eq. 422 and the last line uses Eq. 389. This
confirms that $V^{D}$ is an encoding unitary for the code associated with
$G^{D}$. To encode the logical state $|+^{\otimes k}\rangle_{L}$, we simply
use linearity so that

$\displaystyle V^{D}|+^{\otimes k}\rangle|+^{\otimes
m}\rangle|\mathbf{0}\rangle$ $\displaystyle=|+^{\otimes k}\rangle_{L}.$ (424)

Given three codeblocks, we can encode simultaneously with $V=(V^{A}\otimes
V^{B}\otimes V^{C})$. The all $|+\rangle$ state encoded across three
codeblocks is then

$\displaystyle V(|+^{\otimes k}\rangle|+^{\otimes
m}\rangle|\mathbf{0}\rangle)^{\otimes 3}$ $\displaystyle=|+^{\otimes
3k}\rangle_{L}.$ (425)

A standard recipe for magic state distillation protocols [40, 37, 141, 141] is
to encode into logical $|+\rangle$ states, perform tranversal non-Cliffords as
follows

$\displaystyle\text{CCZ}^{\otimes n}V(|+^{\otimes k}\rangle|+^{\otimes
m}\rangle|\mathbf{0}\rangle)^{\otimes 3}$
$\displaystyle=(\text{CCZ}|+^{\otimes 3}\rangle_{L})^{\otimes k}$
$\displaystyle=|\text{CCZ}\rangle_{L}^{\otimes k},$ (426)

which produces $k$ logical CCZ states. Decoding gives

$\displaystyle(V^{\dagger}\text{CCZ}^{\otimes n}V)(|+^{\otimes
k}\rangle|+^{\otimes m}\rangle|\mathbf{0}\rangle)^{\otimes 3}$ (427)
$\displaystyle=V^{\dagger}|\text{CCZ}\rangle_{L}^{\otimes k}$ (428)
$\displaystyle=|\text{CCZ}^{\otimes k}\rangle|+^{\otimes
3m}\rangle|\mathbf{0}^{\otimes 3}\rangle,$

where in the last line we have slightly abused qubit ordering to collect
together the physical $|\text{CCZ}\rangle$ state output. In the case of a
detectable error, at least one of the $|+^{\otimes 3m}\rangle$ qubits will be
phase flipped and detected by an $X$-measurement.

To reduce space overhead, we observe that the $|\mathbf{0}^{\otimes 3}\rangle$
qubits effectively play no role here. Furthermore, the unitary
$V^{\dagger}\text{CCZ}^{\otimes n}V$ acts non-trivially only on the first
$3(k+m)$ qubits, so that the $|\mathbf{0}^{\otimes 3}\rangle$ qubits (a total
of $3(n-m-k)$ qubits) are truly surplus to requirement. Using our earlier
notation $V^{\dagger}\text{CCZ}^{\otimes
n}V=\prod_{j}V^{\dagger}\text{CCZ}_{j}V$ where $\text{CCZ}_{j}$ acts on qubit
$j$ of each block, one then has that

$\displaystyle(V^{\dagger}\text{CCZ}_{j}V)|(\textbf{x},\textbf{u})\rangle|(\textbf{y},\textbf{v})\rangle|(\textbf{z},\textbf{w})\rangle$
(429)
$\displaystyle=(-1)^{[(\textbf{x},\textbf{u})G^{A}]_{j}[(\textbf{y},\textbf{v})G^{B}]_{j}(\textbf{z},\textbf{w})G^{C}]_{j}}|(\textbf{x},\textbf{u})\rangle|(\textbf{y},\textbf{v})\rangle|(\textbf{z},\textbf{w})\rangle$
$\displaystyle=(-1)^{(\textbf{x},\textbf{u})[G^{A}]_{j}\cdot(\textbf{y},\textbf{v})[G^{B}]_{j}\cdot(\textbf{z},\textbf{w})[G^{C}]_{j}}|(\textbf{x},\textbf{u})\rangle|(\textbf{y},\textbf{v})\rangle|(\textbf{z},\textbf{w})\rangle,$

where $[\ldots]_{j}$ denotes the $j^{\mathrm{th}}$ element of the vector
inside or the $j^{\mathrm{th}}$ column of a matrix. Notice, we have suppressed
the presence of the redundant $|\mathbf{0}\rangle$ qubits.

In Section O.4 we describe two concrete implementations of the
$V\text{CCZ}V^{\dagger}$ gates. Of course, it is crucial that the space
reduction and $V\text{CCZ}V^{\dagger}$ implementation does not distort the way
errors propagate and that error correction properties are retained, which is
proven from first principles in Section O.5.

###  O.4 Implementing Conjugated-CCZ gates

Here we give explicit implementations for the 8 conjugated-CCZ gates described
in Eq. 429. Any such gate can be realized using a single CCZ magic state and
we give further details for two different implementations: the first
implementation uses CNOT gates and single qubit measurements (Section O.4.1);
the second implementation uses only multi-qubit Pauli measurements via lattice
surgery (Section O.4.2).

Herein, we label qubits as follows.

######  Definition 2 (Qubit labels).

Consider a magic state distillation protocol using $n$ noisy CCZ magic states
and $G^{D}$ matrices with $k+m$ rows. We label each input magic states by
$(D,j)_{BU}$ where $j\in[1,n]$ labels which CCZ state the qubit is part of and
$D\in\\{A,B,C\\}$ distinguishes the 3-qubits within a CCZ state. The $BU$
subscript highlights that these are input noisy state qubits possibly produced
by BUTOF. We also have $3(m+k)$ qubits that we call factory qubits and label
$(D,i)_{f}$ with a subscript $f$ for factory and where $D\in\\{A,B,C\\}$ and
$i\in[1,m+k]$.

Notice that the qubit labels assume we have made a spacetime tradeoff, so the
factory qubits refer to the $3(m+k)$ qubits prepared in a $|+\rangle$ state.
The $3(n-m-k)$ qubits described earlier as being in the $|0\rangle$ state are
omitted as they are surplus to requirement. For the code of interest, (recall
Eqs. 410, 414 and 418 there are 9 factory qubits and 24 $BU$ qubits, though
the $BU$-qubits do not all need to be prepared at the same time and can be
encoded in smaller distance codeblocks.

A circuit using this labeling appears later in Fig. 60.

####  O.4.1 Injection with CNOT gates and single qubit measurements

To perform the required sequence of $n$ conjugated-CCZ gates from Eq. 429, we
may implement Algorithm 2.

  1. 1.

For each $j\in\\{1,\ldots,n\\}$

    1. (a)

For each $D\in\\{A,B,C\\}$ and each $i$ such that $[G^{D}]_{i,j}=1$ do a CNOT
with control $(D,i)_{f}$ and target $(D,j)_{BU}$.

    2. (b)

For each $D\in\\{A,B,C\\}$ measure magic state qubit $(D,j)_{BU}$ in the $Z$
basis and record the outcome as $m_{j}^{D}\in\\{0,1\\}$.

    3. (c)

For each pair $m_{j}^{D},m_{j}^{D^{\prime}}=1$, apply a $Z$ correction to
every qubit $(D^{\prime\prime},p)_{f}$ for which
$G^{D^{\prime\prime}}_{p,j}=1$.

    4. (d)

For each pair $m_{j}^{D},=1$, apply a $CZ$ correction to every pair of qubits
$(D^{\prime},p)_{f}$ and $(D^{\prime\prime},q)_{f}$ for which
$G^{D^{\prime}}_{p,j}=G^{D^{\prime}}_{q,j}1$.

Algorithm 2 A CNOT circuit realizing $V^{\dagger}\text{CCZ}^{\otimes n}V$ as
defined in Section O.3. Uses a trio of $G$ matrices with $n$ rows and $k+m$
columns. Qubit label convention given in Definition 2.

In Items 1b and 1c of Algorithm 2, the indices
$(D,D^{\prime},D^{\prime\prime})$ should be read as distinct triples from the
set $\\{A,B,C\\}$. For example, if $D=A$ and $D^{\prime}=C$ then one infers
$D^{\prime\prime}=B$. Furthermore, these adaptive Clifford corrections commute
with the rest of the circuits and so can all be postponed until later. We
illustrate some of the steps in Fig. 60.

Next, we calculate the action of the circuit described by Algorithm 2 for one
particular $j$ value. With respect to the factory qubit basis states, we have

$|\mathbf{a}\rangle|\mathbf{b}\rangle|\mathbf{c}\rangle=|(\mathbf{x},\mathbf{u})\rangle|(\mathbf{y},\mathbf{v})\rangle|(\mathbf{z},\mathbf{w})\rangle,$
(430)

where we have broken the state up into 3 blocks corresponding to indices $A$,
$B$ and $C$. For example, qubit $(A,i)_{f}$ is in state $a_{i}$. Furthermore,
$a_{i}$ equals $x_{i}$ when $i\leq k$ and $u_{i}$ when $i>k$. For each
$D=\\{A,B,C\\}$, we implement CNOT gates targeted on the magic state qubit
$(D,j)_{BU}$ and controlled on qubits $(D,i)_{BU}$ indicated by
$[G^{D}]_{i,j}=1$.

Therefore, for $D=A$ the target $(A,j)_{BU}$ qubit is flipped precisely when

$\sum_{i}[G^{A}]_{i,j}a_{i}=[\mathbf{a}G^{A}]_{j}=1\pmod{2},$ (431)

where the summation has been changed to matrix multiplication. Recall
$[\mathbf{a}G^{A}]_{j}$ just means the $j^{\mathrm{th}}$ element of vector
$\mathbf{a}G^{A}$. Similar expressions hold for $D=B,C$. The CCZ magic state
is given by

$|\text{CCZ}\rangle=2^{-3/2}\sum_{y_{D}\in\mathbb{F}_{2}}(-1)^{y_{A}y_{B}y_{C}}|y_{A}\rangle|y_{B}\rangle|y_{C}\rangle.$
(432)

Ignoring $2^{-3/2}$ for brevity, the CNOTs of Algorithm 2 act as follows on a
$|\text{CCZ}\rangle|\mathbf{a}\rangle|\mathbf{b}\rangle|\mathbf{c}\rangle$
state

$\displaystyle\sum_{y_{D}\in\mathbb{F}_{2}}(-1)^{y_{A}y_{B}y_{C}}|y_{A}\rangle|y_{B}\rangle|y_{C}\rangle|\mathbf{a}\rangle|\mathbf{b}\rangle|\mathbf{c}\rangle$
$\displaystyle\rightarrow\sum_{y_{D}\in\mathbb{F}_{2}}(-1)^{y_{A}y_{B}y_{C}}|y^{\prime}_{A}\rangle|y^{\prime}_{B}\rangle|y^{\prime}_{C}\rangle|\mathbf{a}\rangle|\mathbf{b}\rangle|\mathbf{c}\rangle,$

with

$\displaystyle y^{\prime}_{A}$ $\displaystyle=y_{A}+[\mathbf{a}G^{A}]_{j}$
(433) $\displaystyle y^{\prime}_{B}$
$\displaystyle=y_{B}+[\mathbf{b}G^{B}]_{j}$ $\displaystyle y^{\prime}_{C}$
$\displaystyle=y_{C}+[\mathbf{c}G^{C}]_{j}.$

We follow these CNOTs by measurement of the $BU$-qubits in the $Z$ basis,
which are afterwards discarded. Assuming measurement outcomes
$|m^{A}_{j}\rangle|m^{B}_{j}\rangle|m^{C}_{j}\rangle$ then the only non-
vanishing terms have $m^{D}_{j}=y^{\prime}_{D}$, so

$\displaystyle y_{A}$ $\displaystyle=m^{A}_{j}+[\mathbf{a}G^{A}]_{j}$ (434)
$\displaystyle y_{B}$ $\displaystyle=m^{B}_{j}+[\mathbf{b}G^{B}]_{j}$ (435)
$\displaystyle y_{C}$ $\displaystyle=m^{C}_{j}+[\mathbf{c}G^{C}]_{j}.$ (436)

Discarding the $BU$-qubits, we get

$\displaystyle|CZZ\rangle|\mathbf{a}\rangle|\mathbf{b}\rangle|\mathbf{c}\rangle$
$\displaystyle\rightarrow(-1)^{f(\mathbf{m})}|\mathbf{a}\rangle|\mathbf{b}\rangle|\mathbf{c}\rangle,$
(437)

where the phase exponent depends on the measurement outcomes
$\mathbf{m}=(m^{A}_{j},m^{B}_{j},m^{C}_{j})$ as follows

$f(\mathbf{m})=(m^{A}_{j}+[\mathbf{a}G^{A}]_{j})(m^{B}_{j}+[\mathbf{b}G^{B}]_{j})(m^{C}_{j}+[\mathbf{c}G^{C}]_{j}).$
(438)

The value of this phase-exponent was originally $y_{A}y_{B}y_{C}$ but with the
substitutions determined by Eqs. 434, 435 and 436 we get expression Eq. 438.

In the case of a $\mathbf{m}=(0,0,0)$ projection, we get the phase

$f(0,0,0)=[\mathbf{a}G^{A}]_{j}[\mathbf{b}G^{B}]_{j}[\mathbf{c}G^{C}]_{j},$
(439)

so that after switching notation by using Eq. 430 we get the desired phase in
Eq. 429. However, for non-zero measurement outcomes we have

$f(\mathbf{m})=f(0,0,0)+g(\mathbf{m}),$ (440)

where $g(\mathbf{m})$ represents the remaining terms in the expansions of Eq.
438. We can see that these remaining terms will be quadratic in the variables
$\\{\mathbf{a},\mathbf{b},\mathbf{c}\\}$ and so represent Clifford
corrections: the quadratic terms correspond to a circuit of $CZ$ gates, the
linear terms correspond to a circuit of $Z$ gates, and the constant term gives
a global phase.

For example, consider the case when $\mathbf{m}=(1,0,0)$ so

$\displaystyle g(\mathbf{m})$
$\displaystyle=[\mathbf{b}G^{B}]_{j}[\mathbf{c}G^{C}]_{j}$ (441)
$\displaystyle=\sum_{p,q}G^{B}_{p,j}G^{C}_{q,j}b_{p}c_{q}.$

This is corrected by a $CZ$ between qubits $(B,p)_{f}$ and $(C,q)_{f}$ for
every $\\{p,q\\}$ such that $G^{B}_{p,j}=G^{C}_{q,j}=1$. This correction
precisely matches the rule given in Items 1b and 1c of Algorithm 2. It is
straightforward but tedious to verify that the corrections of Algorithm 2
always give the desired phase needed to cancel $(-1)^{g(\mathbf{m})}$.

####  O.4.2 Injection using lattice surgery

Here we provide an alternative formulation of the conjugated CCZ injection
from that presented in Section O.4.1. Instead of using a CNOT circuit, the
injection procedure will be described entirely in terms of multi-qubit Pauli
operator measurements, as this is the natural set of operations in lattice
surgery implementations. We have already discussed the key ideas of this
mapping in Appendices M and V. Here we wish to allow for the option of
performing a lattice surgery operation between a repetition code clock (really
just a $d_{x}=1$ surface code) and thin surface codes, and we present an
example lattice surgery diagram in Fig. 61.

In general, imagine a circuit that performs the following: (i) do $n$ CNOT
gates targeted on qubit 0 and controlled on qubits $1$ to $n$; (ii) measure
$Z_{0}$; (iii) discard qubit zero. This is equivalent to the following
measurement driven procedure: (i’) measure multi-qubit Pauli
$\prod_{j=0}^{n}Z_{j}$; (ii’) measure single-qubit Pauli $X_{0}$ and discard;
(iii’) if second step gives $``-1"$ outcome perform a $\prod_{j=1}^{n}Z_{j}$
correction. In the bottom diagram of 12, we prove equivalence of these
approaches through a series of circuit identities (illustrated for the $n=3$
case). Applying this equivalence to Algorithm 2 we obtain Algorithm 3.

  1. 1.

For each $j\in\\{1,\ldots,n\\}$

    1. (a)

For each $D\in\\{A,B,C\\}$: measure a multi-qubit $Z$ operator, with support
on $(D,j)_{BU}$ and $(D,i)_{f}$ for every $i$ such that $[G^{D}]_{i,j}=1$ and
record the outcome as $\omega_{j}^{D}\in\\{0,1\\}$.

    2. (b)

For each $\omega_{j}^{D}=1$ , record a $Z$ correction to qubit $(D,i)_{f}$ for
every $i$ such that $[G^{D}]_{i,j}=1$.

    3. (c)

For each $D\in\\{A,B,C\\}$ measure the single-qubit Pauli $(D,j)_{BU}$ in the
$X$ basis and record the outcome as $m_{j}^{D}\in\\{0,1\\}$.

    4. (d)

For each pair $m_{j}^{D},m_{j}^{D^{\prime}}=1$, record a $Z$ correction to
every qubit $(D^{\prime\prime},p)_{f}$ for which
$G^{D^{\prime\prime}}_{p,j}=1$.

    5. (e)

For each pair $m_{j}^{D},=1$, record a $CZ$ correction to every pair of qubits
$(D^{\prime},p)_{f}$ and $(D^{\prime\prime},q)_{f}$ for which
$G^{D^{\prime}}_{p,j}=G^{D^{\prime\prime}}_{q,j}=1$.

Algorithm 3 A Pauli-measurement scheme realizing
$V^{\dagger}\text{CCZ}^{\otimes n}V$ as defined in Section O.3. Uses a trio of
$G^{D}$ matrices with $n$ rows and $k+m$ columns. Qubit label convention given
in Definition 2.

Note that in a Pauli measurement scheme, we never perform the Clifford
corrections. Rather whenever there is a subsequent Pauli measurement $P$, if
the Clifford correction register contains $C$, we instead measure
$CPC^{\dagger}$. The corrections in Algorithm 3 commute with all the
measurements here, and so can be postponed until later.

Figure 61: Lattice surgery to measure a multi-patch Pauli measurement between
three codes blocks: one repetition code logical qubit and two thin surface
code logical qubits. See Fig. 52 for comparison. This provides the principle
building block for the execution of Item 1a. In TDTOF, a multi-patch Pauli
measurement is always followed by a single-qubit measurement of the repetition
code and here we combine this with the third (split) step of lattice surgery.
The gradient coloured squares represent where an $X\otimes X\otimes Z\otimes
Z$ stabilizer measurement called a domain wall. Multiplying the outcome of the
stabilizers labeled with a white dot, gives the outcome of the $Z_{L}\otimes
Z_{L}\otimes Z_{L}$ multi-patch Pauli measurement (this is how we obtain the
outcomes labeled $\omega_{j}^{D}$ in Item 1a of Algorithm 3). To ensure fault-
tolerance of this measurement outcome, we repeat these stabilizer measurements
$d_{m}$ times as discussed in Section N.3. Afterwards all qubits are measured
in $Z$ basis, with their product determining the operator
$Z_{L}\otimes{\mathchoice{\rm 1\mskip-4.0mul}{\rm 1\mskip-4.0mul}{\rm
1\mskip-4.5mul}{\rm 1\mskip-5.0mul}}\otimes{\mathchoice{\rm
1\mskip-4.0mul}{\rm 1\mskip-4.0mul}{\rm 1\mskip-4.5mul}{\rm 1\mskip-5.0mul}}$
(this is how we obtain the outcomes labeled $m_{j}^{D}$ in Item 1a of
Algorithm 3). Since an error during a $Z$ measurement is physically
indistinguishable from a bit-flip error prior to the measurement, to fully
exploit noise bias we need these failure to be similarly unlikely. However, in
practice, in our noise model we find $Z$ measurement errors are much more
likely than bit-flips. However, since the qubits are idle for a long time
after the $Z$ measurement, we can boost their effective fidelity by using an
ancilla qubit to perform a non-destructive $Z$ measurement and repeat until
the fidelity is suitably high. As such, here the single qubit $Z$ measurements
should be interrupted as repeated non-destructive $Z$ measurements. We discuss
in Section O.8 the effect of errors in lattice surgery due to using finite
size code blocks. If we wish to instead measure $X_{L}\otimes Z_{L}\otimes
Z_{L}$ then we do not use the domain wall on the repetition code block.

###  O.5 Error propagation and detection

Here we discuss the effect of noisy $|\text{CCZ}\rangle$ states used in the
TDTOF protocol. For now, we assume all encoded Clifford gates are ideal, but
later we will relax this assumption.

To be precise regarding error propagation we introduce the following language

######  Definition 3.

Given a $|\text{CCZ}\rangle$ magic state, we say it has error pattern
$\mathbf{e}=(e^{A},e^{B},e^{C})\in\mathbb{F}_{2}^{3}$ error if it is in the
state

$\displaystyle E|\text{CCZ}\rangle$ $\displaystyle=Z[\mathbf{e}]|CZZ\rangle$
(442) $\displaystyle=(Z^{e^{A}}\otimes Z^{e^{B}}\otimes
Z^{e^{C}})|\text{CCZ}\rangle.$ (443)

Given $n$ such states, for each $j\in[1,n]$ we use
$\mathbf{e}_{j}=(e^{A}_{j},e^{B}_{j},e^{C}_{j})$ to denote the error for the
$j^{\mathrm{th}}$ $|\text{CCZ}\rangle$ state, so that

$E|\text{CCZ}\rangle^{\otimes
n}=\bigotimes_{j=1}^{n}\left(Z[\mathbf{e}_{j}]|\text{CCZ}\rangle\right).$
(444)

We say an error has $w$ fault-locations if there are $w$ non-zero
$\mathbf{e}_{j}$. Furthermore, for $D\in\\{A,B,C\\}$ we define

$\mathbf{e}^{D}=(e^{D}_{1},e^{D}_{2},\ldots,e^{D}_{n}).$ (445)

The distinction between our notion of fault-locations and the usual Hamming
weight of the concatenated string $(\mathbf{e}_{1},\ldots,\mathbf{e}_{n})$ is
important because many methods of preparing a noisy $|\text{CCZ}\rangle$ state
will lead to errors such as $Z\otimes Z\otimes Z$ that could have a comparable
probability to a single qubit error $Z\otimes{\mathchoice{\rm
1\mskip-4.0mul}{\rm 1\mskip-4.0mul}{\rm 1\mskip-4.5mul}{\rm
1\mskip-5.0mul}}\otimes{\mathchoice{\rm 1\mskip-4.0mul}{\rm
1\mskip-4.0mul}{\rm 1\mskip-4.5mul}{\rm 1\mskip-5.0mul}}$. Indeed, we will
typically be interested in knowing how many $|\text{CCZ}\rangle$ states are
affected by an arbitrary error, though we assume errors are uncorrelated
between different $|\text{CCZ}\rangle$ states. Errors propagate as follows

######  Claim 1 (How errors propagate).

Consider an implementation of Algorithm 3 using noisy CCZ states with Pauli
$Z$ error described by $\\{\mathbf{e}^{A},\mathbf{e}^{B},\mathbf{e}^{C}\\}$ as
in Definition 3. For each $D\in\\{A,B,C\\}$, let

$\mathbf{w}^{D}=\mathbf{e}^{D}G^{D}.$ (446)

The output of Algorithm 3 differs from the ideal case by an error
$Z[\mathbf{w}^{A}]\otimes Z[\mathbf{w}^{B}]\otimes Z[\mathbf{w}^{C}]$ on the
factory qubits and where the tensor product represents the three different
codeblocks. Identifying the last $m$ qubits of each block as check qubits, we
can partition the $\mathbf{w}^{D}$ into two parts as follows

$\displaystyle\mathbf{u}^{D}$ $\displaystyle=\mathbf{e}^{D}G^{D}_{1},$ (447)
$\displaystyle\mathbf{v}^{D}$ $\displaystyle=\mathbf{e}^{D}G^{D}_{0}.$ (448)

1 tells us that $Z$ errors propagate through Algorithm 3 in a manner that is
isomorphic to their propagation through error correction codes represented by
the corresponding $G$-matrices.

We can prove 1 by considering how a single $Z$ error on a $BU$-qubit
propagates onto a factory qubit under Algorithm 3. Since an error on a factory
qubit propagates to the end of the circuit, they compose independently.
Consult the last circuit of Fig. 12 and consider a $Z$ error on the top qubit.
It commutes with the multi-qubit Pauli $Z$ measurement but flips the final
single qubit $X$ measurement. The outcome for this $X$ measurement decides
whether to apply $Z$ to the qubits below. In other words, a $Z$ on the top
qubit propagates to all the qubits below. In Algorithm 3, when operating on
qubit $(D,j)_{BU}$ we apply the circuit of Fig. 12 to sets of factory qubits
identified by $(D,i)_{f}$ whenever $G_{i,j}^{D}=1$. Therefore, a $Z$ error on
$(D,j)_{BU}$ occurs whenever $\textbf{e}^{D}_{j}=1$ and will propagate to
every $(D,i)_{f}$ for which $G_{i,j}^{D}=1$. Summing over all $j\in[1,n]$
magic state injections, factory qubit $(D,i)_{f}$ will have a $Z$ error if

$\sum_{j}\textbf{e}^{D}_{j}G_{i,j}^{D}=\left[\textbf{e}^{D}G^{D}\right]_{i}=1\pmod{2}.$
(449)

Since the $i^{\mathrm{th}}$ qubit is $Z$-flipped according to the
$i^{\mathrm{th}}$ element of vector $\mathbf{w}^{D}:=\textbf{e}^{D}G^{D}$,
this vector describes the $Z$-error distribution on factory block $D$.
Splitting $G^{D}$ into its block matrix components $G^{D}_{1}$ and $G^{D}_{0}$
gives Eq. 447.

We have already described the main components of the magic state distillation
routine, but for completeness we recap how they fit together in Algorithm 4.

  1. 1.

Prepare $3k$ factory qubits $(D,j)_{f}$ in the $|+\rangle$ state.

  2. 2.

Prepare $n$ noisy CCZ magic states (e.g. using BUTOF);

  3. 3.

Perform injections using Algorithm 3.

  4. 4.

Measure $3m$ check qubits $(D,i)_{f}$ for all $i=m,\ldots,m+k$ and ACCEPT on
$|+\rangle$ for every outcome.

Algorithm 4 A complete magic state distillation routine using a space-time
tradeoff and multi-qubit Pauli measurements. It assumes a trio of $G^{D}$
matrices of size $n\times(m+k)$ representing $[[n,k,d]]$ codes with CCZ
transversality as in Lemma 2. We gave suitable $G^{D}$ matrices in Eqs. 410,
414 and 418 for which we have $n=8$, $k=2$, $d=2$ and $m=1$. Qubit label
convention given in Definition 2

Combining our previous results, we have that

######  Claim 2 (Distillation).

Consider an implementation of Algorithm 4 using $G^{D}$ matrices of size
$n\times(m+k)$ satisfying Lemma 2 and using $n$ noisy CCZ states with Pauli
$Z$ error described by $\\{\mathbf{e}^{A},\mathbf{e}^{B},\mathbf{e}^{C}\\}$ as
in Definition 3. The protocol will ACCEPT whenever

$\displaystyle\mathbf{v}^{D}$
$\displaystyle=\mathbf{e}^{D}G^{D}_{0}=\textbf{0}$ (450)

for every $D\in\\{A,B,C\\}$. Furthermore, provided for every $D\in\\{A,B,C\\}$
we have

$\displaystyle\mathbf{u}^{D}$
$\displaystyle=\mathbf{e}^{D}G^{D}_{1}=\textbf{0},$ (451)

the protocol outputs $|\text{CCZ}\rangle^{\otimes k}$. Furthermore, if the
$j^{\mathrm{th}}$ $|\text{CCZ}\rangle$ state has error $Z[\mathbf{e}_{j}]$
with probability $\mathbb{P}_{j}(\mathbf{e}_{j})$ then the probability of
passing the error detection test is

$P_{\mathrm{acc}}=\sum_{\mathbf{e}^{D}:[\mathbf{e}^{D}G^{D}_{0}=\mathbf{0}]\forall
D}\prod_{j}\mathbb{P}_{j}(\mathbf{e}_{j}),$ (452)

and the output fidelity is

$F=\frac{1}{P_{\mathrm{acc}}}\left(\sum_{\mathbf{e}^{D}:[\mathbf{e}^{D}G^{D}_{1}=\mathbf{0}]\forall
D}\prod_{j}\mathbb{P}_{j}(\mathbf{e}_{j})\right).$ (453)

First consider when there are no $Z$ errors. From Section O.4.2 we see that
Algorithm 3 will (when there is no $Z$ noise) apply $\text{CCZ}^{\otimes k}$
to the $3k$ qubits labeled $(D,i)_{f}$ with $i\leq k$. The check qubits with
$i>k$ are unaffected. Therefore, the check qubits should still be in the
$|+\rangle$ state and give “+1” in response to an $X$ measurement. This
confirms that the protocol acts correctly in the ideal case.

When there are one or more $Z$ errors, 1 shows that the check qubits remain
unflipped if and only if $\mathbf{u}^{D}=\mathbf{e}^{D}G_{0}=\mathbf{0}$ for
all $D$. Furthermore, if $\mathbf{v}^{D}=\mathbf{e}^{D}G_{1}=\mathbf{0}$ then
1 tells us whether there are no $Z$ errors propagated onto the factory qubits
forming the output $|\text{CCZ}^{\otimes k}\rangle$ state. The formulae for
$P_{\mathrm{acc}}$ and $F$ follow by simply summing over the probabilities of
these events.

For the remainder of this subsection, we consider the special case when
$G^{D}_{0}=(1,1,\ldots,1)$ as we have in Eqs. 410, 414 and 418. Then, the
state will pass the error detection test whenever

$\displaystyle\mathbf{v}^{D}$
$\displaystyle=\mathbf{e}^{D}G^{D}_{0}=\sum_{j}\mathbf{e}^{D}_{j}=\mathbf{0}.$
(454)

If there are no fault-locations so $\mathbf{e}_{j}=0$ for all $j$, then the
protocol will ACCEPT. If there is a single fault location, so a single $j$ for
which $\mathbf{e}_{j}=(e_{j}^{A},e_{j}^{B},e_{j}^{C})\neq(0,0,0)$ then the
error must be detected as there is no chance for cancellation. If there are
two fault-locations for which $\mathbf{e}_{j}\neq\mathbf{0}$ and
$\mathbf{e}_{i}\neq\mathbf{0}$ then the errors will go undetected only if they
cancel exactly, so $\mathbf{e}_{j}=\mathbf{e}_{i}$. Therefore, to leading
order

$P_{\mathrm{acc}}=\prod_{j=1}^{n}\mathbb{P}_{j}(\mathbf{0})+\sum_{\\{i,j\\}\subset[1,n],\mathbf{e}\neq\mathbf{0}}\mathbb{P}_{i}(\mathbf{e})\mathbb{P}_{j}(\mathbf{e})\prod_{\ell\neq
i,j}\mathbb{P}_{\ell}(\mathbf{0})+\ldots.$ (455)

For instance, let us consider an i.i.d depolarizing noise model such that
$\mathbb{P}_{j}(\mathbf{0})=1-\epsilon$ and
$\mathbb{P}_{j}(\mathbf{e}\neq\mathbf{0})=\epsilon/7$. There are 7 types of
fault $\mathbf{e}\neq\mathbf{0}$ and 28 pairs of possible locations, making
196 different undetected two fault-location errors, so that

$P_{\mathrm{acc}}=(1-\epsilon)^{8}+196\left(\frac{\epsilon}{7}\right)^{2}(1-\epsilon)^{6}+\ldots.$
(456)

To leading order, the infidelity $1-F$ is upper bounded by the probability of
an undetected two fault-location error,

$1-F\leq 196\left(\frac{\epsilon}{7}\right)^{2}(1-\epsilon)^{6}+\ldots.$ (457)

However, some undetected two fault-location errors will not lead to an output
error (i.e. when $[\mathbf{e}^{D}G^{D}_{1}=\mathbf{0}]\forall D$ ). For the
$G^{D}$ matrices of interest (Eqs. 410, 414 and 418), by brute force counting
we find that 184 of the undetected 196 two fault-location errors will lead to
an error. The 12 harmless faults are listed in Table 12 and will return to
play an important role in noise tailoring of Section O.6. Therefore, we can
tighten Eq. 457 to

$\displaystyle 1-F$ $\displaystyle\leq
184\left(\frac{\epsilon}{7}\right)^{2}(1-\epsilon)^{6}+\ldots$ (458)
$\displaystyle\sim 3.755\epsilon^{2}+O(\epsilon^{3}).$ (459)

Therefore, we have quadratic error suppression with quite a small constant
factor for depolarizing noise. In the main text, we usually quote the error
per TOF state and since the protocol outputs two TOF states, we have
$\epsilon_{TD}:=\frac{1}{2}(1-F)$. For the depolarizing noise model this leads
to:

$\epsilon_{TD}=\sim 1.878\epsilon^{2}+O(\epsilon^{3}).$ (460)

####  O.5.1 Truncation errors

While we give expressions up to second order, these summations can be easily
performed to higher order and any truncation error can be controlled. If we
perform calculations up to $t_{\mathrm{max}}$ fault-locations, then the
truncation error can be easily upper-bounded by assuming that every error
above the cut-off leads to an undetected output error so that we have the
rigorous bound

$1-F\leq(1-F_{t_{\mathrm{max}}})+\sum_{t=t_{\mathrm{max}}+1}^{8}\binom{8}{t}7^{t}\left(\frac{\epsilon}{7}\right)^{t}(1-\epsilon)^{8-t},$
(461)

where $(1-F_{t_{\mathrm{max}}})$ is a estimate counting up to
$t_{\mathrm{max}}$ fault-locations and the additional summation is our bound
on the truncation error. In all subsequent numerical calculations we have
confirmed the possible truncation error is many orders of magnitude smaller
than the estimated error. For instance, using $t_{\mathrm{max}}=3$ then for
$\epsilon\leq 10^{-4}$ the truncation error is no more than $3\cdot 10^{-16}$
and therefore negligible.

In practice, the error distribution from BUTOF is far from depolarizing and
this is further skewed when we account for Clifford noise (see Section O.8).
However, truncation error can be estimated of any noise model and controlled
in the above manner. Furthermore, one can also tailor the protocol to the
noise profile (see Section O.6).

####  O.5.2 Generic noise

We have show Algorithm 4 tolerates $Z$ error noise. Next, we show it also
tolerates $X$ noise on the noisy $|\text{CCZ}\rangle$ states. Abstracting away
the details of 2, the protocol maps pure states as follows

$Z[\mathbf{e}]|\text{CCZ}\rangle^{\otimes
n}\rightarrow\mathrm{det}(\mathbf{e})Z[\nu(\mathbf{e})]|\text{CCZ}\rangle^{\otimes
k},$ (462)

where $\mathrm{det}(\mathbf{e})=0,1$ depending on whether the error
$\mathbf{e}$ is detected or not, and the output error is some function $\nu$
of $\mathbf{e}$. Formulae for $\mathrm{det}$ and $\nu$ can be extracted from
2, but here it is useful to ignore these details. Going to density matrices,
we can write

$\displaystyle\rho$
$\displaystyle:=|\text{CCZ}\rangle\\!\langle\text{CCZ}|^{\otimes n}$ (463)
$\displaystyle\sigma$
$\displaystyle:=|\text{CCZ}\rangle\\!\langle\text{CCZ}|^{\otimes k}.$

Because $Z[\mathbf{e}]|\text{CCZ}\rangle^{\otimes n}$ form an orthonormal
basis, any input mixed state can be written as

$\displaystyle\tilde{\rho}$
$\displaystyle:=\sum_{\mathbf{e},\mathbf{f}}A_{\mathbf{e},\mathbf{f}}Z[\mathbf{e}]\rho
Z[\mathbf{f}].$ (464)

If the state suffered stochastic $Z$ noise then it would be diagonal with
respect to this basis, so $A_{\mathbf{e},\mathbf{f}}=0$ whenever
$\mathbf{e}\neq\mathbf{f}$. If there are off-diagonal elements
$A_{\mathbf{e},\mathbf{f}}\neq 0$ these could be eliminated by applying a
random twirl using the Clifford operators that stabilize $|\text{CCZ}\rangle$.
However, this would add unnecessary Clifford gates as these off-diagonals are
unimportant, as we now show.

Fault type $\mathbf{e}_{i}=\mathbf{e}_{j}=\mathbf{e}=$ | $(1,0,0)$ | $(0,1,0)$ | $(0,0,1)$
---|---|---|---
Fault locations $\\{i,j\\}=$ | $\\{1,2\\},\\{3,6\\},\\{4,5\\},\\{7,8\\}$ | $\\{1,5\\},\\{2,4\\},\\{3,7\\},\\{6,8\\}$ | $\\{1,3\\},\\{2,6\\},\\{4,8\\},\\{5,7\\}$

Table 11: A list of the errors with two fault-locations that are undetected
but do not cause a logical fault when executing Algorithm 4 with
$G^{D}$-matrices as in Eqs. 410, 414 and 418. The errors follow the notation
of Definition 3. For example, $\mathbf{e}=(1,0,0)$ corresponds to
$Z\otimes{\mathchoice{\rm 1\mskip-4.0mul}{\rm 1\mskip-4.0mul}{\rm
1\mskip-4.5mul}{\rm 1\mskip-5.0mul}}\otimes{\mathchoice{\rm
1\mskip-4.0mul}{\rm 1\mskip-4.0mul}{\rm 1\mskip-4.5mul}{\rm 1\mskip-5.0mul}}$
and is undetected yet harmless when it acts on $BU$-qubits $(A,1)_{BU}$ and
$(A,2)_{BU}$ . This is a direct consequence of
$(1,1,0,0,0,0,0,0)G^{A}_{1}=(0,0)$ that can be confirmed by inspection of Eq.
410. Notice that only unit vector $\mathbf{e}$ appears in this list of fault
types.

$j$ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
---|---|---|---|---|---|---|---|---
$M_{j}$ | $\left(\begin{array}[]{ccc}1&0&0\\\ 0&0&1\\\ 0&1&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}1&0&0\\\ 0&1&0\\\ 0&0&1\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&1&0\\\ 1&0&0\\\ 0&0&1\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&0&1\\\ 0&1&0\\\ 1&0&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}1&0&1\\\ 0&0&1\\\ 0&1&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}1&1&0\\\ 1&0&0\\\ 0&0&1\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&1&0\\\ 0&0&1\\\ 1&0&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&0&1\\\ 0&1&0\\\ 1&0&0\\\ \end{array}\right)$
$(1,0,0)$ | $\left(\begin{array}[]{ccc}1&0&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}1&0&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&1&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&0&1\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}1&0&1\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}1&1&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&1&0\\\ \end{array}\right)$ | $\left(\begin{array}[]{ccc}0&0&1\\\ \end{array}\right)$

Table 12: A set of transformation matrices $M_{j}$ that represent Clifford
symmetries as defined in Eq. 467. For every distinct pair of indices
$\\{i,j\\}$ they satisfy either condition $1^{\star}$ or condition $2^{\star}$
as stated in the proof of 3. In particular, the only pairs for which condition
$1^{\star}$ does not hold are $\\{1,2\\}$,$\\{3,7\\}$ and $\\{4,8\\}$.
However, for these three cases the fault pattern is one of the harmless cases
listed in Table 12.

By Eq. 462 and linearity, we have

$\displaystyle\tilde{\rho}\rightarrow\tilde{\sigma}$
$\displaystyle=\sum_{\mathbf{e},\mathbf{f}}\mathrm{det}(\mathbf{e})\mathrm{det}(\mathbf{f})A_{\mathbf{e},\mathbf{f}}Z[\nu(\mathbf{e})]\sigma
Z[\nu(\mathbf{f})].$ (465)

Because any physical process does not increase the trace of any terms, there
is no way for off-diagonal elements (with $\mathbf{e}\neq\mathbf{f}$) to be
mapped to on-diagonal elements (with $\nu(\mathbf{e})\neq\nu(\mathbf{f})$).
Since the success probability and fidelity only depend on the output diagonal
elements, we conclude that our figures of merit only depend on the diagonal
$A_{\mathbf{e},\mathbf{e}}$ elements. In other words, the success probability
and output fidelity are unchanged whether or not we twirl the initial state.
In all numerics presented, whenever the input magic states suffer a mix of $Z$
and $X$ noise, we have calculated the exact $\tilde{\rho}$ matrix, extracted
the diagonal elements and used them to build an equivalent stochastic $Z$
noise model. Consequently, any error on a single $|\text{CCZ}\rangle$ state
appears as a stochastic mixture of $Z$ errors at 1 fault location.

After the protocol is complete, we can twirl the output states to ensure that
the infidelity matches the trace norm error of the output states. Though
again, this twirl is never actually performed but included into the Clifford
record to modify Pauli-measurements used to inject the magic state into the
algorithm.

###  O.6 Noise tailoring through Clifford symmetries

There is some freedom in how injections are scheduled and whether to include
certain Clifford gates in TDTOF protocol. A $|\text{CCZ}\rangle$ gate is
invariant under permutation of qubits $A$, $B$ and $C$. More generally, there
are Clifford symmetries $C$ such that
$C|\text{CCZ}\rangle=|\text{CCZ}\rangle$. A permutation is a sort of Clifford
symmetry, but one that can be realized at no further gate count.

As such, we can add Cliffords or freely permute some of the indices in
Algorithm 3. In the ideal case, with no errors, these symmetry operations have
no effect. However, they can change the noise model. For qubits with
depolarizing noise, the noisy state is invariant under all these symmetries.
However, for BUTOF the output noise model is very asymmetric and highly skewed
towards a $Z$ error on qubit $A$ and so applying symmetry operations can
change the protocol’s performance. Here we explain the idea of noise tailoring
through symmetries and find that the change can be dramatic. Indeed, while the
protocol usually quadratically suppresses errors, we can tailor the noise for
cubic suppression of 1 error type. To make a clean statement we consider a toy
noise model.

######  Claim 3.

Consider a noise model on $|\text{CCZ}\rangle$ states such that for every $j$
it experiences error $Z[\mathbf{e}_{j}]$ (recall Definition 3) with
probability

$\mathbb{P}_{j}(\mathbf{e}_{j}):=\begin{cases}1-\epsilon_{1}-\epsilon_{2}&\mbox{
if }\mathbf{e}_{j}=(0,0,0)\\\ \epsilon_{1}&\mbox{ if
}\mathbf{e}_{j}=(1,0,0)\\\ (\epsilon_{2}/6)&\mbox{ otherwise }\end{cases},$
(466)

where $\epsilon_{2}\ll\epsilon_{1}$. Directly applying 2 leads to an output
infidelity of
$O(\epsilon_{1}^{2})+O(\epsilon_{2}^{2})+O(\epsilon_{1}\epsilon_{2})$.
However, there exists a set of Clifford symmetries $\\{C_{j}\\}$ such that
$C_{j}|\text{CCZ}\rangle=|\text{CCZ}\rangle$ and if applied at the start of
the protocol lead to an output infidelity of
$O(\epsilon_{1}^{3})+O(\epsilon_{1}\epsilon_{2})+O(\epsilon_{2}^{2})$.

Consider a set of Clifford symmetries such that

$C_{j}Z[\mathbf{e}_{j}]C_{j}^{\dagger}=\pm Z[\mathbf{e}_{j}M_{j}],$ (467)

where $M_{j}$ is an invertible $3\times 3$ binary matrix and
$\mathbf{e}_{j}M_{j}$ represents matrix multiplication. The $\pm$ phase will
depend on $Z[\mathbf{e}_{j}]$ but is irrelevant to our analysis. For example,
if $C_{j}$ permutes qubits in Hilbert space then $M_{j}$ represents the
permutation of the indices. Then applying $C_{j}$ to the input magic states
generates a new probability distribution for $Z$ errors

$\mathbb{P}^{\prime}_{j}(\mathbf{e}_{j}M_{j}):=\mathbb{P}_{j}(\mathbf{e}_{j}).$
(468)

Using that $M$ must be invertible, we equivalently have

$\mathbb{P}^{\prime}_{j}(\mathbf{e}_{j}):=\mathbb{P}_{j}(\mathbf{e}_{j}M_{j}^{-1}).$
(469)

Only errors with two fault-locations contribution second order contributions
to the output infidelity. Recall from Section O.5 that for such an error to go
undetected, we must have that $\mathbf{e}_{i}=\mathbf{e}_{j}=:\mathbf{e}\neq
0$ for some distinct pair $\\{i,j\\}$. We have introduce the shorthand
$\mathbf{e}$ for whatever nonzero error type is under consideration. This
occurs with probability

$\mathbb{P}^{\prime}_{i}(\mathbf{e}M_{i})\mathbb{P}^{\prime}_{j}(\mathbf{e}M_{j})\mathbb{P}^{\prime}_{j}(\mathbf{0})^{6}=\mathbb{P}_{i}(\mathbf{e}M_{i}^{-1})\mathbb{P}_{j}(\mathbf{e}M_{j}^{-1})\mathbb{P}_{j}(\mathbf{0})^{6}.$
(470)

This probability is of size $O(\epsilon_{1}^{2})$ if

$\mathbf{e}M_{i}^{-1}=\mathbf{e}M_{j}^{-1}=(1,0,0),$ (471)

and otherwise the probability is smaller: either
$O(\epsilon_{1}\epsilon_{2})$, $O(\epsilon_{2}^{2})$ or zero. Inverting again,
Eq. 471 can be converted into

$\mathbf{e}=(1,0,0)M_{i}=(1,0,0)M_{j}.$ (472)

It follows that to achieve $O(\epsilon_{1}^{3})$ scaling of output infidelity,
we require that for every $\\{i,j\\}$ pair either

  1. ($1^{\star}$)

$(1,0,0)M_{i}\neq(1,0,0)M_{j}$ ;

  2. ($2^{\star}$)

or if $(1,0,0)M_{i}=(1,0,0)M_{j}$ then fault $\mathbf{e}=(1,0,0)M_{j}$
corresponds to one of the harmless errors listed in Table 12.

There are 7 different possible values of $(1,0,0)M_{j}$ but 8 different $j$
indices, so it is (narrowly) not possible to use condition $1^{\star}$ alone.
However, it is possible to find a set of Clifford symmetries such that some
pairs $\\{i,j\\}$ are covered by condition $1^{\star}$ and some pairs
$\\{i,j\\}$ are covered by condition $2^{\star}$.

We provide such an $\\{M_{j}\\}$ set in Table 12, which suffices to prove 3.
Furthermore, this set can be implemented especially easily. Consulting Table
12 we find that the Clifford symmetries for indices $\\{1,2,3,4,7,8\\}$ all
correspond to permutations of indices and so can all be performed in software.
The only exceptions are indices $\\{5,6\\}$ that correspond to a
$W=\text{CNOT}_{B,A}X_{A}$ gate followed by an index permutation. In other
words, $W$ bit-flips qubit $A$ if qubit $B$ is in the $|0\rangle$ state.
Consequently, the state $|1,1,1\rangle$ is invariant under $W$ and other
computational basis states are permuted. Therefore, $W$ is a Clifford symmetry
of the $|\text{CCZ}\rangle$ state since all terms except $|1,1,1\rangle$ carry
the same amplitude and phase. Since
$|\text{TOF}\rangle=H_{C}|\text{CCZ}\rangle$ and $[W,H_{C}]=0$, we know $W$
also stabilizes $|\text{TOF}\rangle$. Furthermore, when conjugating a $Z$
error we have that Eq. 467 takes the form

$WZ[\mathbf{e}_{j}]W^{\dagger}=W(-1)^{e_{j}^{A}}Z[\mathbf{e}_{j}M_{W}],$ (473)

where

$M_{W}=\left(\begin{array}[]{ccc}1&1&0\\\ 0&1&0\\\ 0&0&1\\\
\end{array}\right).$ (474)

Permuting qubit indices after $W$ corresponds to swapping columns of $M_{W}$.
We get $M_{5}$ of 3 by swapping columns 2 and 3 of $M_{W}$. We get $M_{6}$ of
Table 12 by swapping columns 1 and 2 of $M_{W}$.

The actual noise distribution output from BUTOF is not exactly the toy noise
model of Table 12 but it shares the feature that $(Z\otimes{\mathchoice{\rm
1\mskip-4.0mul}{\rm 1\mskip-4.0mul}{\rm 1\mskip-4.5mul}{\rm
1\mskip-5.0mul}}\otimes{\mathchoice{\rm 1\mskip-4.0mul}{\rm
1\mskip-4.0mul}{\rm 1\mskip-4.5mul}{\rm 1\mskip-5.0mul}})$ errors dominate. In
all numerics presented, we use the Clifford symmetry operations of 3 and Table
12 but analyzed using the correct BUTOF noise model.

Implementing $W$ on repetition encoded qubits $A$ and $B$ is straightforward
because $W$ is transversal and the codeblocks are adjacent to each other in
the proposed layout.

Figure 62: A 2D layout for realising $8\text{TOF}\rightarrow 2\text{TOF}$ distillation via lattice surgery using a mixture of repetition codes and thin surface code. Example dimensions shown here with: encoding distances $d_{x}=3$, $d_{\mathrm{rep}}=5$, $d_{z}=5$ and $D_{z}=7$; and $M=10$ BUTOF modules. Additional space between codeblocks is provided for lattice surgery and routing between code blocks (see Appendix M and Fig. 61). We give explicit locations for the 9 factory qubits with labels $(D,i)_{f}$ following Definition 2. The modules labeled BU consists of 3 repetition codes and provide space to attempt a noisy $|\text{TOF}\rangle$ preparation using the BUTOF protocol. Note that BUTOF is executed with a distance $d_{BU}$ repetition code (typically we set $d_{BU}=5,7$) and then immediately grow to distance $d_{z}>d_{BU}$. Factory clock | Corridor A |  Corridor AB | Corridor BC |  Corridor C
---|---|---|---|---
1 | $\begin{array}[]{c}\text{X(}\text{C},4)_{BU}\\\ \text{Z(}\text{A},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},4)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{X(}\text{C},3)_{BU}\\\ \text{Z(}\text{B},1)_{f}\\\ \text{Z(}\text{B},2)_{f}\\\ \text{Z(}\text{B},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},3)_{BU}\\\ \end{array}$ | $\begin{array}[]{c}\text{X(}\text{C},2)_{BU}\\\ \text{Z(}\text{C},2)_{f}\\\ \text{Z(}\text{C},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},2)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{X(}\text{C},1)_{BU}\\\ \text{Z(}\text{C},1)_{f}\\\ \text{Z(}\text{C},2)_{f}\\\ \text{Z(}\text{C},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},1)_{BU}\\\ \end{array}$
2 | $\begin{array}[]{c}\text{Z(}\text{B},1)_{BU}\\\ \text{Z(}\text{A},0)_{f}\\\ \text{Z(}\text{A},1)_{f}\\\ \text{Z(}\text{A},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},1)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{B},2)_{BU}\\\ \text{Z(}\text{B},0)_{f}\\\ \text{Z(}\text{B},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},2)_{BU}\\\ \end{array}$ | $\begin{array}[]{c}\text{Z(}\text{B},4)_{BU}\\\ \text{Z(}\text{B},0)_{f}\\\ \text{Z(}\text{B},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},4)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{B},3)_{BU}\\\ \text{Z(}\text{C},1)_{f}\\\ \text{Z(}\text{C},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},3)_{BU}\\\ \end{array}$
3 | $\begin{array}[]{c}\text{Z(}\text{A},3)_{BU}\\\ \text{Z(}\text{A},0)_{f}\\\ \text{Z(}\text{A},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},3)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{A},2)_{BU}\\\ \text{Z(}\text{A},0)_{f}\\\ \text{Z(}\text{A},1)_{f}\\\ \text{Z(}\text{A},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},2)_{BU}\\\ \end{array}$ | $\begin{array}[]{c}\text{Z(}\text{A},1)_{BU}\\\ \text{Z(}\text{B},0)_{f}\\\ \text{Z(}\text{B},1)_{f}\\\ \text{Z(}\text{B},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},1)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{A},4)_{BU}\\\ \text{Z(}\text{C},1)_{f}\\\ \text{Z(}\text{C},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},4)_{BU}\\\ \end{array}$
4 | $\begin{array}[]{c}\text{X(}\text{C},8)_{BU}\\\ \text{Z(}\text{A},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},8)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{X(}\text{C},6)_{BU}\\\ \text{Z(}\text{B},2)_{f}\\\ \text{Z(}\text{B},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},6)_{BU}\\\ \end{array}$ | $\begin{array}[]{c}\text{X(}\text{C},7)_{BU}\\\ \text{Z(}\text{B},1)_{f}\\\ \text{Z(}\text{B},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},7)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{X(}\text{C},5)_{BU}\\\ \text{Z(}\text{C},1)_{f}\\\ \text{Z(}\text{C},3)_{f}\\\ \text{then}\\\ \text{Z(}\text{C},5)_{BU}\\\ \end{array}$
5 | $\begin{array}[]{c}\text{Z(}\text{B},5)_{BU}\\\ \text{Z(}\text{A},0)_{f}\\\ \text{Z(}\text{A},1)_{f}\\\ \text{Z(}\text{A},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},5)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{B},7)_{BU}\\\ \text{Z(}\text{A},1)_{f}\\\ \text{Z(}\text{A},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},7)_{BU}\\\ \end{array}$ | $\begin{array}[]{c}\text{Z(}\text{B},8)_{BU}\\\ \text{Z(}\text{B},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},8)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{B},6)_{BU}\\\ \text{Z(}\text{C},2)_{f}\\\ \text{then}\\\ \text{X(}\text{B},6)_{BU}\\\ \end{array}$
6 | $\begin{array}[]{c}\text{Z(}\text{A},6)_{BU}\\\ \text{Z(}\text{A},0)_{f}\\\ \text{Z(}\text{A},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},6)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{A},5)_{BU}\\\ \text{Z(}\text{B},1)_{f}\\\ \text{Z(}\text{B},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},5)_{BU}\\\ \end{array}$ | $\begin{array}[]{c}\text{Z(}\text{A},7)_{BU}\\\ \text{Z(}\text{C},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},7)_{BU}\\\ \end{array}$ |  $\begin{array}[]{c}\text{Z(}\text{A},8)_{BU}\\\ \text{Z(}\text{C},2)_{f}\\\ \text{then}\\\ \text{X(}\text{A},8)_{BU}\\\ \end{array}$
7 | $\begin{array}[]{c}\text{Setup}\\\ \text{exit}\\\ \end{array}$ |  $\begin{array}[]{c}\text{X(A,3})_{f}\\\ \text{Clifford}\\\ \text{corrected}\\\ \end{array}$ | $\begin{array}[]{c}\text{X(B,3})_{f}\\\ \text{Clifford}\\\ \text{corrected}\\\ \end{array}$ |  $\begin{array}[]{c}\text{X(C,3})_{f}\\\ \text{Clifford}\\\ \text{corrected}\\\ \end{array}$
8 | exit |  exit | exit |  exit
Table 13: The final form of our TDTOF protocol for one full cycle of the
factory. It executes a variant of Algorithm 4 that has been modified according
to the qubit permutations required for noise-tailoring (see Section O.6) and
embedded within the 2D layout of Fig. 62. Each cell for factory clocks 1-6 has
the form $A$ then $B$. Instruction $A$ specifies a multi-qubit Pauli operator
using the qubit notation of Definition 2. For example,
$X(C,4)_{BU},Z(A,3)_{f}$ means measure the operators $X\otimes Z$ where the
$X$ acts on magic input labeled $(C,4)_{BU}$ and the $Z$ acts on factory qubit
$(A,3)_{f}$. Instruction $B$ specifies a single-qubit measurement of a magic
input qubit. The $B$ instructions can be realized with physical single-qubit
measurements that takes a single surface code cycle. As such, $B$ instructions
require negligible time compared to the $A$ instructions, so we present both
$a$ and $B$ within a single Factory clock step that has duration $d_{m}+1$. In
factory clock steps 1 and 4, the role of $Z$ and $X$ are swapped on the magic
state qubits to account for the Hadamard difference between
$|\text{CCZ}\rangle$ and $|\text{TOF}\rangle$. The column headers “Corridor”
indicate which Corridor from Fig. 62 is used to realize the multi-qubit Pauli
measurement since lattice surgery requires some workspace to operate. Note
that Corridor AB can only be used to access factory qubit with labels of the
form $(A,i)_{f}$ or $(B,i)_{f}$. The column headers also list which factory
blocks $\\{A,B,C\\}$ the Corridor can be used to access and this constraint it
respected in this schedule. Notice that multi-qubit measurements of the form
$X(C,4)_{BU},Z(A,3)_{f}$ involve different capital letter indices on the
factory and magic qubits. In contrast, Item 1a of Algorithm 3 describes multi-
qubit Pauli measurements with matching capital letter indices. This is due to
the permutation operations required for noise tailoring (see Section O.6). In
particular, when performing measurements with the $j=4$ index, the matrix
$M_{4}$ of Table 12 instructs us to swap the $A$ and $C$ indices for the magic
state qubit. In the cases of $M_{6}$ and $M_{7}$, these are decomposed into a
single Clifford gate $W$ and a permutation. The above table only accounts for
the permutation, with the Clifford performed on the input magic state qubits
prior to injection into TDTOF. Factory clock times 1-3 correspond to batch 1,
so that measurements involve only magic state qubits of the form $(D,i)_{BU}$
with $i\in[1,4]$. Factory clock times 4-6 correspond to batch 2, so that
measurements involve only magic state qubits of the form $(D,i)_{BU}$ with
$i\in[5,8]$. The importance of batching and the related issue of BUTOF
scheduling is discussed in Section O.7. “Exit” refers to factory qubits moving
out of the factory.

###  O.7 Factory layout and scheduling

We see from Fig. 61 that lattice surgery require some additional workspace to
connect the various codeblocks. Fig. 62 presents a 2D layout to realize TDTOF
using lattice surgery, including all necessary workspace. If bit-flips are
sufficiently small, then the factory can be realized completely with
repetition codes. In the regime where bit-flips are rare but not completely
negligible, we use a mix of repetition codeblocks (for the $BU$-qubits) and
$d_{x}=3$ thin surface codes (for the factory qubits) to tolerate a single
physical bit-flip anywhere in the factory. Additional bit-flip protection
could be achieved by increasing the $X$ distance of all code blocks and/or
performing two rounds of TDTOF. Here we only describe a single round and
primarily focus on the version using $d_{x}=3$ surface code blocks.

For now, we assume a supply of TOF states generated from BUTOF. Then we can
schedule the main TDTOF steps as listed in Table 13. The required 8 input
$|\text{TOF}\rangle$ are divided into 2 batches of 4. How quickly can a batch
of 4 input $|\text{TOF}\rangle$ magic states be injected? Each
$|\text{TOF}\rangle$ state comprises 3 qubits, so there are a total of
$12=3\times 4$ multi-patch Pauli measurements needed per batch. These can be
partly parallelised. Fig. 62 shows 4 horizontal empty regions that we will
call access corridors labeled $\\{A,AB,BC,C\\}$. This allows us to perform 4
multi-patch Pauli measurement in parallel. There are some constraints on which
multi-patch Pauli measurements are performed (further discussion in the
caption of Fig. 62). The first batch is injected in factory clock steps 1-3.
The second batch is injected in factory clock steps 4-6. Factory clock step 7
performs the measurement of the check qubits, and starts the process of
exiting some factory qubits out of the factory. Factory clock step 8 completes
the process of exiting the factory qubits. Each factory clock step takes a
time $(d_{m}+1)T_{\mathrm{surf}}$ where $T_{\mathrm{surf}}$ is the duration of
1 surface code cycle and $d_{m}$ is the number of surface code cycle used per
multi-qubit Pauli measurement. The $``+1"$ in $(d_{m}+1)$ provides time to
perform high fidelity single qubit measurements and reset between rounds of
multi-qubit Pauli measurement. Roughly, a single execution of TDTOF takes time
$8(d_{m}+1)T_{\mathrm{surf}}$, though small extra additive timecosts may be
incurred to execute BUTOF, which we discuss next.

Fault source and remarks | Propagated |  Risk | Suppressing
---|---|---|---
|  |  | parameter
$Z$-logical errors on repetition codes during storage | Backwards |  not critical | $d_{\mathrm{rep}}$
$Z$-logical errors on factory qubits during storage | Forwards |  critical | $D_{z}$
$Z$-logical errors on check qubits during storage | Forwards |  not critical | $d_{z}$
$X$ logical on repetition codes during storage | Backwards |  not critical | $|\alpha|^{2}$
$X$ logical on surface codes factory qubits | Stuck |  critical |  $d_{x}$, $|\alpha|^{2}$
Timelike error during lattice surgery multi-patch measurement. Remarks: This flips multi-qubit measurement outcome (denoted $\omega^{D}_{j}$ in Algorithm 3) but is equivalent to Pauli error on input magic state. See Appendix M for details. | Backwards |  not critical | $d_{m}$
Measurement failure when reseting after lattice surgery. Remarks: This flips some single Pauli measurement outcome $m^{D}_{j}$ in Algorithm 3. Equivalent to Pauli error on input magic state. | Backwards |  not critical | $|\alpha|^{2}$
Table 14: Fault sources due to imperfect Cliffords. Each error is either
propagated forwards or backwards, or it is stuck. We sum the probability of
all stuck errors and add to the overall infidelity of TDTOF. Backwards
propagated errors modify the noise distribution on the input magic states.
Forwards propagated are handled by modifying the formulae (see Eqs. 478 and
479) for the infidelity and acceptance probability. An error is a critical
risk it occurs with probability $p$ and contributes to the overall infidelity
with probability $O(p)$ rather than $O(p^{2})$. Every error source can be
exponentially suppressed some parameter, where
$\\{d_{\mathrm{rep}},d_{z},D_{Z},d_{x}\\}$ are code distance illustrated in
Fig. 62; $d_{m}$ is the measurement distance denoting the number of surface
code cycles used during lattice surgery (see Appendix M); and $|\alpha|^{2}$
is the mean phonon number in the cat code qubit. For critical risk errors, the
associated parameter is typically set higher than the parameters set for non-
critical errors. In particular, the parameters
$\\{d_{z},d_{m},d_{\mathrm{rep}}\\}$ can be safely set at about half the value
of $D_{z}$ though our actual choice is determined by numerical search.

The BUTOF protocol can have a fairly high failure probability, labeled here by
$F_{BU}$. This failure probability depends on the repetition code distance
$d_{BU}$ used in BUTOF. To boost the probability of having ample supply of
states from BUTOF, we add redundancy in both time and space. Our illustrations
show $M=20$ modules for BUTOF, but we only need 8 input $|\text{TOF}\rangle$
or $|\text{CCZ}\rangle$ states for the protocol. Not all 8 input
$|\text{TOF}\rangle$ or $|\text{CCZ}\rangle$ states need to exist at the same
time as they are split into two batches. Rather we aim to prepare 4
$|\text{TOF}\rangle$ at the start of factory clock steps 1 and 4. Therefore,
during the factory clock steps 4-8 (a total time of
$5(d_{m}+1)T_{\mathrm{surf}}$), we need to prepare 4 $|\text{TOF}\rangle$ for
the first batch of the next round of TDTOF. During the factory clock steps 1-3
(a total time of $3(d_{m}+1)T_{\mathrm{surf}}$), we need to prepare 4
$|\text{TOF}\rangle$ for the second batch in the current round of TDTOF. Let
us focus our discussion on preparation during steps 1-3 as this is the
bottleneck point. Furthermore, our schedule requires that, of these 4
$|\text{TOF}\rangle$ states, 2 are located on the left and 2 are located on
the right. Considering just one side, we have $M/2$ BUTOF modules. Of these
$M/2$ modules, 2 are busy storing $|\text{TOF}\rangle$ states and performing
the required lattice surgery operations. This leaves $(M-1)/2$ modules
responsible for preparing 2 $|\text{TOF}\rangle$ states. Each attempt at BUTOF
takes a time

$T_{BU}=2d_{BU}T_{\mathrm{rep}}+\frac{d_{BU}+1}{2}(2+d_{BU}+1)T_{\mathrm{cnot}},$
(475)

where $T_{\text{CNOT}}$ is the optimal time for a CNOT gate and
$T_{\mathrm{rep}}$ is the time for a repetition code cycle. Therefore, steps
1-3 provide enough time to fit in $R:=\lfloor
3(d_{m}+1)T_{\mathrm{surf}}/T_{BU}\rfloor$ repeated attempts at BUTOF. Given
$R$ temporally multiplexed attempts, each BUTOF module has its failure
probability reduced from $F_{BU}$ to $\tilde{F}_{BU}:=F_{BU}^{R}$. Each side
fails if there are zero or one module successes of the $(M-1)/2$ modules,
which occurs with probability

$\displaystyle F_{\mathrm{side}}$
$\displaystyle=\tilde{F}_{BU}^{(M-1)/2}+\frac{M-1}{2}\tilde{F}_{BU}^{(M-1)/2}(1-\tilde{F}_{BU})$
$\displaystyle=F_{BU}^{R(M-1)/2}+\frac{M-1}{2}F_{BU}^{R(M-1)/2}(1-F_{BU}^{R}).$
(476)

For instance, executing BUTOF at distance 5 and using $d_{m}=15$ surface code
cycles per lattice surgery operation we have $R=3$ attempts at BUTOF (assuming
$\kappa_{1}/\kappa_{2}=10^{-5}$ and $|\alpha|^{2}=8$). If $F_{BU}=0.447$ then
the temporal redundancy reduces this to $\tilde{F}_{BU}=F_{BU}^{3}=0.089$.
Providing $M=10$ modules in total, there is $(M-1)/2=3$ available spatial
redundancy on each side, which further suppresses the failure probability to
$F_{\mathrm{side}}=0.023$. This is already quite low. We can further reduce
the failure probability by either: increasing space cost $M$; or inserting a
small number $Q$ additional rounds of BUTOF between steps 3 and 4. In the
latter case, the runtime of TDTOF is extended to

$T_{TD}=QT_{BU}+8(d_{m}+1)T_{\mathrm{surf}},$ (477)

where we have assumed $QT_{BU}\leq 2(d_{m}+1)$. This further reduces
$F_{\mathrm{side}}$. A coarse bound is obtained by replacing $R\rightarrow
R+Q$ in Eq. 476, though actually the suppression is slightly better as there
are now $M/2$ modules available for the $Q$ attempts. We do not wish to set
$Q$ too high, as the additional delay leads to logical error accumulation due
to finite distance choices.

Whenever BUTOF fails to proceed the required $|\text{TOF}\rangle$ states, we
count this as a failure of the whole TDTOF protocol. However, we use
sufficient redundancy that such occurrences are very rare. Typically, we set
$Q=1$ or $Q=2$, and we use $M=10$ when $d_{BU}=5$ and $M=20$ when $d_{BU}=7$.

An additional consideration is that a lattice dislocation is used when
performing a multi-qubit Pauli measurement including a $Z_{L}$ on a repetition
encoded logical qubit (see Fig. 61). This dislocation uses a small amount of
additional space. However, when using $|\text{TOF}\rangle$ input states
(instead of $|\text{CCZ}\rangle$) the third qubit differs by a Hadamard and so
the protocol is adjusted to measure $X_{L}$ and a dislocation is not required.
For this reason, we inject the qubits in reverse order: $(C,j)_{BU}$,
$(B,j)_{BU}$ then $(A,j)_{BU}$. After $(C,j)_{BU}$ is injected (without
needing a dislocation) some space is freed-up for dislocations to be used,
enabling $(B,j)_{BU}$ and $(A,j)_{BU}$ to be injected.

###  O.8 Clifford noise

$\epsilon_{\text{TD}}$ |  # ATS |  $P_{\text{ACC}}$ (%) |  Time/Tof ($\mu s$) | $d_{\text{BU}}$ |  $d_{\text{rep}}$ | $d_{z}$ |  $D_{z}$ | $d_{x}$ |  $d_{m}$
---|---|---|---|---|---|---|---|---|---
$7.6*10^{-6}$ |  1176 | 93 |  1602 | 5 |  5 | 7 |  15 | 3 |  11
$7.3*10^{-6}$ |  1218 | 73 |  1871 | 5 |  5 | 9 |  15 | 3 |  10
$4.8*10^{-6}$ |  1218 | 94 |  1723 | 5 |  5 | 9 |  15 | 3 |  12
$3.7*10^{-6}$ |  1260 | 93 |  1734 | 5 |  5 | 7 |  17 | 3 |  12
$1.5*10^{-6}$ |  1302 | 94 |  1724 | 5 |  5 | 9 |  17 | 3 |  12
$9.9*10^{-7}$ |  1386 | 98 |  1766 | 5 |  5 | 9 |  19 | 3 |  13
$8.6*10^{-7}$ |  1386 | 94 |  1721 | 5 |  7 | 9 |  17 | 3 |  12
$8.2*10^{-7}$ |  1428 | 94 |  1723 | 5 |  5 | 11 |  19 | 3 |  12
$6.1*10^{-7}$ |  1428 | 98 |  1889 | 5 |  5 | 11 |  19 | 3 |  14
$2.6*10^{-7}$ |  1470 | 98 |  1762 | 5 |  7 | 9 |  19 | 3 |  13
$1.3*10^{-7}$ |  1512 | 99 |  1886 | 5 |  7 | 11 |  19 | 3 |  14
$5.6*10^{-8}$ |  1596 | 99 |  1886 | 5 |  7 | 11 |  21 | 3 |  14
$4.1*10^{-8}$ |  1596 | 99 |  2137 | 5 |  7 | 11 |  21 | 3 |  16
$3.3*10^{-8}$ |  1680 | 99 |  2011 | 5 |  7 | 11 |  23 | 3 |  15
$2.8*10^{-8}$ |  1680 | 99 |  2262 | 5 |  7 | 11 |  23 | 3 |  17
$1.7*10^{-8}$ |  1722 | 99 |  2136 | 5 |  7 | 13 |  23 | 3 |  16
$1.5*10^{-8}$ |  1722 | 99 |  2388 | 5 |  7 | 13 |  23 | 3 |  18
$1.3*10^{-8}$ |  1806 | 99 |  2388 | 5 |  7 | 13 |  25 | 3 |  18
$1.3*10^{-8}$ |  1890 | 99 |  2513 | 5 |  7 | 13 |  27 | 3 |  19
$1.1*10^{-8}$ |  1890 | 99 |  2388 | 5 |  9 | 13 |  25 | 3 |  18
$1.1*10^{-8}$ |  1932 | 99 |  2388 | 5 |  7 | 15 |  27 | 3 |  18
$1.1*10^{-8}$ |  1932 | 99 |  2639 | 5 |  7 | 15 |  27 | 3 |  20
$1.1*10^{-8}$ |  1974 | 99 |  2513 | 5 |  9 | 13 |  27 | 3 |  19
$1.1*10^{-8}$ |  2016 | 99 |  2639 | 5 |  7 | 15 |  29 | 3 |  20
$9.0*10^{-9}$ |  2016 | 99 |  2388 | 5 |  9 | 15 |  27 | 3 |  18
$8.9*10^{-9}$ |  2016 | 99 |  2639 | 5 |  9 | 15 |  27 | 3 |  20
$8.8*10^{-9}$ |  2100 | 99 |  2639 | 5 |  9 | 15 |  29 | 3 |  20
$8.5*10^{-9}$ |  2226 | 99 |  2639 | 5 |  9 | 17 |  31 | 3 |  20
$8.5*10^{-9}$ |  2436 | 99 |  2639 | 5 |  9 | 19 |  35 | 3 |  20
$8.5*10^{-9}$ |  2604 | 99 |  2764 | 5 |  9 | 19 |  39 | 3 |  21
Table 15: Assuming $\kappa_{1}/\kappa_{2}=10^{-5}$, $\kappa_{\phi}=0$ and
$|\alpha|^{2}=8$. Performance of optimized TDTOF factory using BUTOF with
$d_{BU}=5$ and $M_{BU}=10$. Zero-dephasing noise.

Perhaps one of the most importance aspects of magic state factory design is
the choice of distance for various code blocks. It is possible to use much
smaller code distances within the factory than used inside the main algorithm.
Using finite code distances leads to noisy Clifford gates, noisy lattice
surgery operations and non-negligible memory noise. This needs to be accounted
for in addition to the error estimated by 2 under the assumption of ideal
Cliffords. Indeed, typically Clifford noise is the dominate source of errors
and the error of 2 should instead be regarded as the minimum achievable error
(with 1 round of TDTOF) in the limit of infinite code distances.

Some of the relevant spatial code distance parameters are shown in Fig. 62. An
important additional quantity is the “measurement distance” $d_{m}$ that is
increased to suppress the effect of timelike errors during lattice surgery
(see Appendix M for further details). A common choice in the literature is to
set $d_{m}=\mathrm{max}[d_{z},d_{x}]$, but this is by no means necessary or
optimal.

Rather than a Monte Carlo simulation of Clifford noise, we perform a computer-
assisted analytical analysis. It is helpful to distinguish critical and non-
critical faults. We say a Clifford fault is a critical risk if (assuming no
other errors occur) it leads to an undetected fault on the output magic
states. Conversely, a fault is a non-critical risk if it will be detected
(assuming no other errors). All sources of Clifford noise can be grouped into
one of four classes

  1. 1.

Backwards propagating and not critical: these are errors that can be commuted
towards the start of the circuit, so that they act on a single noisy input
$|\text{TOF}\rangle$ state. If $\rho$ is the density matrix with only noise
from BUTOF, the backwards propagating noise is applied so
$\rho\rightarrow\rho^{\prime}$. Then the effective $Z$ logical error
distribution is determined from $\rho^{\prime}$ using the procedure of Section
O.5.2.

  2. 2.

Forwards propagating and not critical: these errors can be commuted to the end
of the circuit, so that they act on the check qubits in the factory just
before they are measured.

  3. 3.

Forwards propagating and critical: these errors can be commuted to the end of
the circuit, so that they act on the output magic state qubits.

  4. 4.

Stuck errors and potentially critical: these are errors that are difficult to
commute forwards or backwards through the circuit. We sum the probability of
these events and add it to the error rate on the output magic states.

Our treatment of stuck errors means that we obtain an upper bound on the
performance. One might be concerned that this bound is loose, but in practice
the stuck errors are very rare and not, therefore, of major importance.
Indeed, if we instead attempted a Monte Carlo simulation, the statistical
variance in the error estimate would exceed that of the total stuck error
probability. Therefore, our computer-assisted analytical analysis leads to
more accurate results than Monte Carlo methods. We further remark that while a
mild amount of truncation of higher order processes is employed, we use the
procedure of Section O.5.1 to monitor this truncation error and verify that it
is negligible.

We list all the source of imperfections in Table 14 and describe the
propagation type and risk level. Let us assume that backwards propagation has
been performed and we have accounted for the effect of noise tailoring (recall
Section O.6) on the error distribution. Following earlier notation of
Definition 3 and Section O.6, we say $j^{\mathrm{th}}$ noisy TOF state suffers
fault $Z[\mathbf{e}_{j}]$ with probability $\mathbb{P}_{j}(\mathbf{e}_{j})$
that we precompute. Then, without any other noise sources, 2 would describe
the acceptance probability and output infidelity. However, the factory qubits
may be affected by some forwarded propagated error
$Z[(\tilde{\mathbf{w}}^{A},\tilde{\mathbf{w}}^{B},\tilde{\mathbf{w}}^{C})]$
where the labels $\\{A,B,C\\}$ refer to the 3 different blocks of factory
qubits. We used similar notation, without the tilde, in 1 to describe how
errors due to input magic states impact the protocol. To combine with the
forwarded propagated errors we simply replace
$\mathbf{w}\rightarrow\mathbf{w}+\tilde{\mathbf{w}}$ to add the effect of the
forwarded propagated errors and follow this modification through the analysis
of 2. As we did earlier, it will be useful to split
$\mathbf{w}=(\mathbf{v},\mathbf{u})$ to distinguish errors on check qubits and
output qubits. If the forwarded propagated error $\tilde{\mathbf{w}}$ on each
block occurs with some probability $\mathbb{F}(\tilde{\mathbf{w}})$ then the
results of 2 modify to

$P_{\mathrm{acc}}=\sum_{\begin{subarray}{c}\tilde{\mathbf{w}}^{D},\mathbf{e}^{D}\\\
[\mathbf{e}^{D}G^{D}_{0}=\tilde{\mathbf{v}}^{D}]\forall
D\end{subarray}}\prod_{\begin{subarray}{c}1\leq j\leq 8\\\
D\in\\{A,B,C\\}\end{subarray}}\mathbb{P}_{j}(\mathbf{e}_{j})\mathbb{F}(\tilde{\mathbf{w}}^{D}),$
(478)

and

$F=\frac{1}{P_{\mathrm{acc}}}\sum_{\begin{subarray}{c}\tilde{\mathbf{w}}^{D},\mathbf{e}^{D}\\\
[\tilde{\mathbf{e}}^{D}G^{D}_{1}=\tilde{\mathbf{u}}^{D}]\forall
D\end{subarray}}\prod_{\begin{subarray}{c}1\leq j\leq 8\\\
D\in\\{A,B,C\\}\end{subarray}}\mathbb{P}_{j}(\mathbf{e}_{j})\mathbb{F}(\tilde{\mathbf{w}}^{D}).$
(479)

There are three important changes here. First, in both equations we have
summed over forwards propagated errors and weighted by the appropriate
probability. In the acceptance probability the summation constraint
$[\mathbf{e}^{D}G^{D}_{0}=\mathbf{0}]\forall D$ has been replaced by
$[\mathbf{e}^{D}G^{D}_{0}=\tilde{\mathbf{v}}^{D}]\forall D$ since to pass the
check measurement any forwards propagated error $\tilde{\mathbf{v}}^{D}$ must
cancel (therefore equal) some other error to go undetected. Similarly, in the
fidelity expression we have replaced
$[\mathbf{e}^{D}G^{D}_{1}=\mathbf{0}]\forall D$ with
$[\mathbf{e}^{D}G^{D}_{1}=\tilde{\mathbf{u}}^{D}]\forall D$ because to
contribute to the fidelity any forwarded propagated error
$\tilde{\mathbf{u}}^{D}$ must cancel (therefore equal) some other error.

Calculating the expressions for $\mathbb{P}_{j}$, $\mathbb{F}$, performing the
summation and adding the stuck error events is too involved to perform by
hand. But it is relatively straightforward for a symbolic mathematics package
such as Mathematica. Optimizing over various error suppressing parameters, we
find the factory designs that achieve a certain target error per Toffoli at
the minimum qubit and ATS cost (without making significant sacrifices to
acceptance probabilities) and present results in Table 15.

###  O.9 The fidelity bottleneck in TDTOF

There are many contributing sources of error to the results presented in
Tables 4 and 15. In the main text summary of Table 4, the lowest reported
Toffoli error probability was $2.3*10^{-9}$. Here we discuss which error
sources are the bottleneck factor that limit us from reaching higher
fidelities with TDTOF protocol. We conclude with a discussion how the
presented TDTOF protocol can be adapted to pass this bottleneck.

Let us consider the process of bit-flip errors on noisy input TOF states
encoded in repetition codes. For hardware parameters
$\kappa_{1}/\kappa_{2}=10^{-5}$, $\kappa_{\phi}=0$ and $|\alpha^{2}|=8$, the
lowest total error rate is $\delta:=2.7*10^{-8}$ per repetition code cycle
(recall Fig. 7). If a single TOF state is stored for $r$ repetition code
cycles, then roughly the accumulated error on qubits $B$ and $C$ is $\delta r$
and this gives an additional contribution of $2\delta r$ to the non-dominate
noise contributions $\epsilon_{2}$. Returning to our benchmark example, the
output error is (roughly) lower bounded by

$\displaystyle C\epsilon_{1}\epsilon_{2}^{\prime}$ $\displaystyle\sim
C\epsilon_{1}\left(\epsilon_{2}+2\delta r\right)$ (480)
$\displaystyle=C(2*10^{-5})\left(7.5*10^{-9}+2*2.7*10^{-8}r\right).$

where $C$ is some constant that depends on the exact details of the noise
profile and we have discussed examples where $C\sim 2$ and $C\sim 8$.
Furthermore, for the larger factory examples in Table 4 repetition codes could
be in storage for as long as $r\sim 200$ repetition code cycles. Together this
approximate accounting indicates (with $r=200$ and $C=5$) that we should not
expect output infidelities lower than $\sim 1.1*10^{-9}$. Of course, this is a
rough estimation of one error source, just to provide the reader with some
intuition. Rather, for a precise accounting of all error sources the lowest
observed infidelity was $2.5*10^{-9}$. However, there are several
straightforward routes to reaching even lower infidelities. By converting
immediately after BUTOF from repetition code to thin surface code we would
reduce the time exposed to bit-flip errors. For our benchmark example,
encoding directly into surface codes should enable us to get much closer to
$1.2*10^{-12}$ infidelity (the ideal Clifford limit for noise tailored TDTOF).
Ultimately, arbitrarily high fidelities can be reached by concatenating TDTOF,
though resource costs jump substantially with each level of concatenation.
Alternatively, better fidelities could be reached it hardware parameters could
be improved by either further suppressing bit-flips by increasing
$|\alpha|^{2}$ or decreasing $\kappa_{1}/\kappa_{2}$.

## References

  * Bravyi and Kitaev [1998] S. B. Bravyi and A. Y. Kitaev, arXiv preprint quant-ph/9811052 (1998).
  * O’Gorman and Campbell [2017] J. O’Gorman and E. T. Campbell, Physical Review A 95, 032338 (2017), arXiv:1605.07197 .
  * Motta  _et al._ [2018] M. Motta, E. Ye, J. R. McClean, Z. Li, A. J. Minnich, R. Babbush, and G. K.-L. Chan, Low rank representations for quantum simulation of electronic structure (2018), arXiv:1808.02625 .
  * Gidney and Ekerå [2019] C. Gidney and M. Ekerå, How to factor 2048 bit RSA integers in 8 hours using 20 million noisy qubits (2019), arXiv:1905.09749 [quant-ph] .
  * Campbell  _et al._ [2019] E. Campbell, A. Khurana, and A. Montanaro, Quantum 3, 167 (2019), arXiv:1810.05582 .
  * Kivlichan  _et al._ [2020] I. D. Kivlichan, C. Gidney, D. W. Berry, N. Wiebe, J. McClean, W. Sun, Z. Jiang, N. Rubin, A. Fowler, A. Aspuru-Guzik, and et al., Quantum 4, 296 (2020), arXiv:1902.10673 .
  * Chamberland and Campbell [2021] C. Chamberland and E. T. Campbell, arXiv preprint arXiv:2109.02746 (2021).
  * Tuckett  _et al._ [2018] D. K. Tuckett, S. D. Bartlett, and S. T. Flammia, Phys. Rev. Lett. 120, 050505 (2018), arXiv:1708.08474 .
  * Tuckett  _et al._ [2019] D. K. Tuckett, A. S. Darmawan, C. T. Chubb, S. Bravyi, S. D. Bartlett, and S. T. Flammia, Phys. Rev. X 9, 041031 (2019), arXiv:1812.08186 .
  * Tuckett  _et al._ [2020] D. K. Tuckett, S. D. Bartlett, S. T. Flammia, and B. J. Brown, Phys. Rev. Lett. 124, 130501 (2020), arXiv:1907.02554 .
  * Ataides  _et al._ [2021] J. P. B. Ataides, D. K. Tuckett, S. D. Bartlett, S. T. Flammia, and B. J. Brown, Nature communications 12, 1 (2021).
  * Aliferis and Preskill [2008] P. Aliferis and J. Preskill, Phys. Rev. A 78, 052331 (2008), arXiv:0710.1301 .
  * Puri  _et al._ [2020] S. Puri, L. St-Jean, J. A. Gross, A. Grimm, N. E. Frattini, P. S. Iyer, A. Krishna, S. Touzard, L. Jiang, A. Blais, and et al., Science Advances 6, eaay5901 (2020), arXiv:1905.00450 .
  * Guillaud and Mirrahimi [2019] J. Guillaud and M. Mirrahimi, Phys. Rev. X 9, 041053 (2019), arXiv:1904.09474 .
  * Guillaud and Mirrahimi [2021] J. Guillaud and M. Mirrahimi, Phys. Rev. A 103, 042413 (2021).
  * Mirrahimi  _et al._ [2014] M. Mirrahimi, Z. Leghtas, V. V. Albert, S. Touzard, R. J. Schoelkopf, L. Jiang, and M. H. Devoret, New Journal of Physics 16, 045014 (2014).
  * Puri  _et al._ [2017] S. Puri, S. Boutin, and A. Blais, npj Quantum Inf. 3, 18 (2017).
  * Cohen [2017] J. Cohen,  _Autonomous quantum error correction with superconducting qubits_ , Ph.D. thesis, Université Paris sciences et lettres (2017).
  * Albert  _et al._ [2018] V. V. Albert, K. Noh, K. Duivenvoorden, D. J. Young, R. T. Brierley, P. Reinhold, C. Vuillot, L. Li, C. Shen, S. M. Girvin, B. M. Terhal, and L. Jiang, Phys. Rev. A 97, 032346 (2018).
  * Joshi  _et al._ [2020] A. Joshi, K. Noh, and Y. Y. Gao, arXiv e-prints , arXiv:2008.13471 (2020), arXiv:2008.13471 [quant-ph] .
  * Cai  _et al._ [2020] W. Cai, Y. Ma, W. Wang, C. L. Zou, and L. Sun, arXiv e-prints , arXiv:2010.08699 (2020), arXiv:2010.08699 [quant-ph] .
  * Leghtas  _et al._ [2015] Z. Leghtas, S. Touzard, I. M. Pop, A. Kou, B. Vlastakis, A. Petrenko, K. M. Sliwa, A. Narla, S. Shankar, M. J. Hatridge, M. Reagor, L. Frunzio, R. J. Schoelkopf, M. Mirrahimi, and M. H. Devoret, Science 347, 853 (2015), 1412.4633 .
  * Touzard  _et al._ [2018] S. Touzard, A. Grimm, Z. Leghtas, S. Mundhada, P. Reinhold, C. Axline, M. Reagor, K. Chou, J. Blumoff, K. Sliwa, and et al., Physical Review X 8, 021005 (2018), arXiv:1705.02401 .
  * Goto [2016a] H. Goto, Scientific Reports 6, 21686 (2016a).
  * Goto [2016b] H. Goto, Phys. Rev. A 93, 050301 (2016b).
  * Puri  _et al._ [2019] S. Puri, A. Grimm, P. Campagne-Ibarcq, A. Eickbusch, K. Noh, G. Roberts, L. Jiang, M. Mirrahimi, M. H. Devoret, and S. M. Girvin, Phys. Rev. X 9, 041009 (2019).
  * Grimm  _et al._ [2020] A. Grimm, N. E. Frattini, S. Puri, S. O. Mundhada, S. Touzard, M. Mirrahimi, S. M. Girvin, S. Shankar, and M. H. Devoret, Nature 584, 205 (2020), arXiv:1907.12131 .
  * Lescanne  _et al._ [2020] R. Lescanne, M. Villiers, T. Peronnin, A. Sarlette, M. Delbecq, B. Huard, T. Kontos, M. Mirrahimi, and Z. Leghtas, Nature Physics 16, 509 (2020).
  * Arrangoiz-Arriola and Safavi-Naeini [2016] P. Arrangoiz-Arriola and A. H. Safavi-Naeini, Phys. Rev. A 94, 063864 (2016).
  * MacCabe  _et al._ [2020] G. S. MacCabe, H. Ren, J. Luo, J. D. Cohen, H. Zhou, A. Sipahigil, M. Mirhosseini, and O. Painter, Science 370, 840 (2020), https://science.sciencemag.org/content/370/6518/840.full.pdf .
  * Blais  _et al._ [2021] A. Blais, A. L. Grimsmo, S. M. Girvin, and A. Wallraff, Rev. Mod. Phys. 93, 025005 (2021).
  * Arrangoiz-Arriola  _et al._ [2019] P. Arrangoiz-Arriola, E. A. Wollack, Z. Wang, M. Pechal, W. Jiang, T. P. McKenna, J. D. Witmer, R. Van Laer, and A. H. Safavi-Naeini, Nature 571, 537 (2019).
  * Dennis  _et al._ [2002a] E. Dennis, A. Kitaev, A. Landahl, and J. Preskill, Journal of Mathematical Physics 43, 4452 (2002a).
  * Fowler  _et al._ [2012a] A. G. Fowler, M. Mariantoni, J. M. Martinis, and A. N. Cleland, Physical Review A 86, 032324 (2012a).
  * Wollack  _et al._ [2021] E. A. Wollack, A. Y. Cleland, P. Arrangoiz-Arriola, T. P. McKenna, R. G. Gruenke, R. N. Patel, W. Jiang, C. J. Sarabalis, and A. H. Safavi-Naeini, Applied Physics Letters 118, 123501 (2021), https://doi.org/10.1063/5.0034909 .
  * Campbell  _et al._ [2017] E. T. Campbell, B. M. Terhal, and C. Vuillot, Nature 549, 172 (2017).
  * Bravyi and Haah [2012] S. Bravyi and J. Haah, Phys. Rev. A 86, 052329 (2012).
  * Meier  _et al._ [2013] A. M. Meier, B. Eastin, and E. Knill, Quant. Inf. and Comp. 13, 195 (2013).
  * Campbell and Howard [2018] E. T. Campbell and M. Howard, Quantum 2, 56 (2018).
  * Bravyi and Kitaev [2005a] S. Bravyi and A. Kitaev, Phys. Rev. A 71, 022316 (2005a).
  * Paz and Zurek [1998] J. P. Paz and W. H. Zurek, Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences 454, 355 (1998).
  * Ahn  _et al._ [2002] C. Ahn, A. C. Doherty, and A. J. Landahl, Phys. Rev. A 65, 042301 (2002).
  * Sarovar and Milburn [2005] M. Sarovar and G. J. Milburn, Phys. Rev. A 72, 012306 (2005).
  * Kerckhoff  _et al._ [2010] J. Kerckhoff, H. I. Nurdin, D. S. Pavlichin, and H. Mabuchi, Physical Review Letters 105, 040502 (2010).
  * Cochrane  _et al._ [1999] P. T. Cochrane, G. J. Milburn, and W. J. Munro, Phys. Rev. A 59, 2631 (1999).
  * Jeong and Kim [2002] H. Jeong and M. S. Kim, Phys. Rev. A 65, 042305 (2002).
  * Lieu  _et al._ [2020] S. Lieu, R. Belyansky, J. T. Young, R. Lundgren, V. V. Albert, and A. V. Gorshkov, Physical Review Letters 125, 10.1103/physrevlett.125.240405 (2020).
  * Reiter and Sørensen [2012] F. Reiter and A. S. Sørensen, Phys. Rev. A 85, 032111 (2012).
  * Frattini  _et al._ [2017] N. E. Frattini, U. Vool, S. Shankar, A. Narla, K. M. Sliwa, and M. H. Devoret, Applied Physics Letters 110, 222603 (2017), https://doi.org/10.1063/1.4984142 .
  * Mirhosseini  _et al._ [2020] M. Mirhosseini, A. Sipahigil, M. Kalaee, and O. Painter, arXiv preprint arXiv:2004.04838 (2020).
  * Lescanne  _et al._ [2019] R. Lescanne, L. Verney, Q. Ficheux, M. H. Devoret, B. Huard, M. Mirrahimi, and Z. Leghtas, Phys. Rev. Applied 11, 014030 (2019).
  * Sank  _et al._ [2016] D. Sank, Z. Chen, M. Khezri, J. Kelly, R. Barends, B. Campbell, Y. Chen, B. Chiaro, A. Dunsworth, A. Fowler, E. Jeffrey, E. Lucero, A. Megrant, J. Mutus, M. Neeley, C. Neill, P. J. J. O’Malley, C. Quintana, P. Roushan, A. Vainsencher, T. White, J. Wenner, A. N. Korotkov, and J. M. Martinis, Phys. Rev. Lett. 117, 190503 (2016).
  * Zhang  _et al._ [2019] Y. Zhang, B. J. Lester, Y. Y. Gao, L. Jiang, R. J. Schoelkopf, and S. M. Girvin, Phys. Rev. A 99, 012314 (2019).
  * Verney  _et al._ [2019] L. Verney, R. Lescanne, M. H. Devoret, Z. Leghtas, and M. Mirrahimi, Phys. Rev. Applied 11, 024003 (2019).
  * James and Jerke [2007a] D. F. V. James and J. Jerke, Can. J. Phys. 85, 625 (2007a).
  * Gamel and James [2010] O. Gamel and D. F. V. James, Phys. Rev. A 82, 052106 (2010).
  * Naik  _et al._ [2017] R. K. Naik, N. Leung, S. Chakram, P. Groszkowski, Y. Lu, N. Earnest, D. C. McKay, J. Koch, and D. I. Schuster, Nat. Commun. 8, 1904 (2017).
  * Pechal  _et al._ [2018] M. Pechal, P. Arrangoiz-Arriola, and A. H. Safavi-Naeini, Quantum Sci. Technol. 4, 015006 (2018).
  * Hann  _et al._ [2019] C. T. Hann, C.-L. Zou, Y. Zhang, Y. Chu, R. J. Schoelkopf, S. M. Girvin, and L. Jiang, Phys. Rev. Lett. 123, 250501 (2019).
  * Mundada  _et al._ [2019] P. Mundada, G. Zhang, T. Hazard, and A. Houck, Phys. Rev. Appl. 12, 10.1103/PhysRevApplied.12.054023 (2019).
  * Chen  _et al._ [2014] Y. Chen, C. Neill, P. Roushan, N. Leung, M. Fang, R. Barends, J. Kelly, B. Campbell, Z. Chen, B. Chiaro, A. Dunsworth, E. Jeffrey, A. Megrant, J. Y. Mutus, P. J. J. O’Malley, C. M. Quintana, D. Sank, A. Vainsencher, J. Wenner, T. C. White, M. R. Geller, A. N. Cleland, and J. M. Martinis, Phys. Rev. Lett. 113, 220502 (2014).
  * Gao  _et al._ [2018] Y. Y. Gao, B. J. Lester, Y. Zhang, C. Wang, S. Rosenblum, L. Frunzio, L. Jiang, S. M. Girvin, and R. J. Schoelkopf, Phys. Rev. X 8, 021073 (2018).
  * Gao  _et al._ [2019] Y. Y. Gao, B. J. Lester, K. S. Chou, L. Frunzio, M. H. Devoret, L. Jiang, S. M. Girvin, and R. J. Schoelkopf, Nature 566, 509 (2019).
  * Sun  _et al._ [2014] L. Sun, A. Petrenko, Z. Leghtas, B. Vlastakis, G. Kirchmair, K. Sliwa, A. Narla, M. Hatridge, S. Shankar, J. Blumoff, _et al._ , Nature 511, 444 (2014).
  * Hann  _et al._ [2018] C. T. Hann, S. S. Elder, C. S. Wang, K. Chou, R. J. Schoelkopf, and L. Jiang, Phys. Rev. A 98, 022305 (2018).
  * Elder  _et al._ [2020] S. S. Elder, C. S. Wang, P. Reinhold, C. T. Hann, K. S. Chou, B. J. Lester, S. Rosenblum, L. Frunzio, L. Jiang, and R. J. Schoelkopf, Phys. Rev. X 10, 011001 (2020).
  * Krantz  _et al._ [2019] P. Krantz, M. Kjaergaard, F. Yan, T. P. Orlando, S. Gustavsson, and W. D. Oliver, Applied Physics Reviews 6, 021318 (2019).
  * Gottesman [2010] D. Gottesman, Proceedings of Symposia in Applied Mathematics 68, 13 (2010).
  * Tomita and Svore [2014] Y. Tomita and K. M. Svore, Phys. Rev. A 90, 062320 (2014).
  * DiVincenzo and Aliferis [2007] D. P. DiVincenzo and P. Aliferis, Phys. Rev. Lett. 98, 020501 (2007).
  * Chamberland  _et al._ [2018] C. Chamberland, P. Iyer, and D. Poulin, Quantum 2, 43 (2018).
  * Kelly  _et al._ [2015] J. Kelly, R. Barends, A. G. Fowler, A. Megrant, E. Jeffrey, T. C. White, D. Sank, J. Y. Mutus, B. Campbell, Y. Chen, _et al._ , Nature 519, 66 (2015).
  * Ballance  _et al._ [2016] C. J. Ballance, T. P. Harty, N. M. Linke, M. A. Sepiol, and D. M. Lucas, Phys. Rev. Lett. 117, 060504 (2016).
  * Sung  _et al._ [2021] Y. Sung, L. Ding, J. Braumüller, A. Vepsäläinen, B. Kannan, M. Kjaergaard, A. Greene, G. O. Samach, C. McNally, D. Kim, A. Melville, B. M. Niedzielski, M. E. Schwartz, J. L. Yoder, T. P. Orlando, S. Gustavsson, and W. D. Oliver, Phys. Rev. X 11, 021058 (2021).
  * Fowler  _et al._ [2013] A. G. Fowler, S. J. Devitt, and C. Jones, Scientific reports 3, 1 (2013).
  * Horsman  _et al._ [2012] C. Horsman, A. G. Fowler, S. Devitt, and R. V. Meter, New Journal of Physics 14, 123011 (2012).
  * Landahl and Ryan-Anderson [2014] A. J. Landahl and C. Ryan-Anderson, arXiv preprint arXiv:1407.5103 (2014).
  * Litinski and Oppen [2018] D. Litinski and F. v. Oppen, Quantum 2, 62 (2018).
  * Litinski [2019a] D. Litinski, Quantum 3, 128 (2019a).
  * Litinski and von Oppen [2018] D. Litinski and F. von Oppen, Quantum 2, 62 (2018).
  * Bravyi  _et al._ [2016] S. Bravyi, G. Smith, and J. A. Smolin, Physical Review X 6, 021043 (2016).
  * Paler and Fowler [2019] A. Paler and A. G. Fowler, arXiv preprint arXiv:1906.07994 (2019).
  * Fowler  _et al._ [2012b] A. G. Fowler, M. Mariantoni, J. M. Martinis, and A. N. Cleland, Phys. Rev. A 86, 032324 (2012b).
  * Fowler [2012a] A. G. Fowler, arXiv preprint arXiv:1210.4626 (2012a).
  * Chamberland and Cross [2019] C. Chamberland and A. W. Cross, Quantum 3, 143 (2019).
  * Chamberland and Noh [2020] C. Chamberland and K. Noh, npj Quantum Information 6, 91 (2020).
  * Note [1] Recently, it was also shown in Ref. [15] that when implementing a logical Toffoli gate using a piece-wise fault-tolerant approach, one can track the $CZ$ errors that arise when $Z$ errors propagate through the target qubits of the physical Toffoli gates (see Appendix L) and correct all errors at the final output of piece-wise circuit (instead of in between each blocks of physical Toffoli gates). Such an approach could potentially be used in our bottom-up $|\text{TOF}\rangle$ state preparation scheme, allowing us to avoid using the STOP algorithm to prepare $|0\rangle_{L}$ and $|1\rangle_{L}$. However we leave such an analysis to future work.
  * Note [2] This should be compared to the circuits used in [86] for preparing $|H\rangle$ type magic states which are fault-tolerant to all types of Pauli noise given that a depolarizing circuit level noise model was assumed.
  * Bravyi and Kitaev [2005b] S. Bravyi and A. Kitaev, Phys. Rev. A 71, 022316 (2005b).
  * Haah and Hastings [2018] J. Haah and M. B. Hastings, Quantum 2, 71 (2018).
  * Litinski [2019b] D. Litinski, Quantum 3, 205 (2019b).
  * Gidney and Fowler [2019] C. Gidney and A. G. Fowler, Quantum 3, 135 (2019).
  * Wiebe and Granade [2016] N. Wiebe and C. Granade, Phys. Rev. Lett. 117, 010503 (2016).
  * Gidney [2018] C. Gidney, Quantum 2, 74 (2018).
  * Bravyi  _et al._ [2019] S. Bravyi, D. Browne, P. Calpin, E. Campbell, D. Gosset, and M. Howard, Quantum 3, 181 (2019).
  * Campbell [2020] E. Campbell (2020), arXiv:2012.09238.
  * Zheng  _et al._ [2017] B.-X. Zheng, C.-M. Chung, P. Corboz, G. Ehlers, M.-P. Qin, R. M. Noack, H. Shi, S. R. White, S. Zhang, and G. K.-L. Chan, Science 358, 1155 (2017).
  * Note [3] In contract, for an additive (intensive) error energy estimation, $\epsilon$ is constant in $L$, and so the gate complexity will grow with system size [6, 96].
  * Li  _et al._ [2019] M. Li, D. Miller, M. Newman, Y. Wu, and K. R. Brown, Phys. Rev. X 9, 021041 (2019).
  * Chamberland  _et al._ [2020a] C. Chamberland, G. Zhu, T. J. Yoder, J. B. Hertzberg, and A. W. Cross, Phys. Rev. X 10, 011022 (2020a).
  * Debroy  _et al._ [2020] D. M. Debroy, M. Li, S. Huang, and K. R. Brown, Quantum Science and Technology 5, 034002 (2020).
  * Huang and Brown [2020] S. Huang and K. R. Brown, Phys. Rev. A 101, 042312 (2020).
  * Nigg  _et al._ [2012] S. E. Nigg, H. Paik, B. Vlastakis, G. Kirchmair, S. Shankar, L. Frunzio, M. H. Devoret, R. J. Schoelkopf, and S. M. Girvin, Phys. Rev. Lett. 108, 240502 (2012).
  * Pechal and Safavi-Naeini [2017] M. Pechal and A. H. Safavi-Naeini, Phys. Rev. A 96, 042305 (2017).
  * Kreikebaum  _et al._ [2020] J. M. Kreikebaum, K. P. O’Brien, A. Morvan, and I. Siddiqi, Superconductor Science and Technology 33, 06LT02 (2020).
  * Ferreira  _et al._ [2020] V. S. Ferreira, J. Banker, A. Sipahigil, M. H. Matheny, A. J. Keller, E. Kim, M. Mirhosseini, and O. Painter, arXiv preprint arXiv:2001.03240 (2020).
  * Azouit  _et al._ [2016] R. Azouit, A. Sarlette, and P. Rouchon, in  _2016 IEEE 55th Conference on Decision and Control (CDC)_ (IEEE, 2016) pp. 4559–4565.
  * Azouit  _et al._ [2017] R. Azouit, F. Chittaro, A. Sarlette, and P. Rouchon, Quantum Sci. Technol. 2, 044011 (2017).
  * Sete  _et al._ [2015] E. A. Sete, J. M. Martinis, and A. N. Korotkov, Phys. Rev. A 92, 012325 (2015).
  * James and Jerke [2007b] D. F. James and J. Jerke, Canadian Journal of Physics 85, 625 (2007b), https://doi.org/10.1139/p07-060 .
  * Heinsoo  _et al._ [2018] J. Heinsoo, C. K. Andersen, A. Remm, S. Krinner, T. Walter, Y. Salathé, S. Gasparinetti, J.-C. Besse, A. Potočnik, A. Wallraff, and C. Eichler, Phys. Rev. Applied 10, 034040 (2018).
  * Jeffrey  _et al._ [2014] E. Jeffrey, D. Sank, J. Y. Mutus, T. C. White, J. Kelly, R. Barends, Y. Chen, Z. Chen, B. Chiaro, A. Dunsworth, A. Megrant, P. J. J. O’Malley, C. Neill, P. Roushan, A. Vainsencher, J. Wenner, A. N. Cleland, and J. M. Martinis, Phys. Rev. Lett. 112, 190504 (2014).
  * Pfaff  _et al._ [2017] W. Pfaff, C. Axline, L. Burkhart, _et al._ , Nature Physics 13, 882 (2017).
  * Clerk  _et al._ [2010] A. A. Clerk, M. H. Devoret, S. M. Girvin, F. Marquardt, and R. J. Schoelkopf, Rev. Mod. Phys. 82, 1155 (2010).
  * Didier  _et al._ [2015] N. Didier, J. Bourassa, and A. Blais, Phys. Rev. Lett. 115, 203601 (2015).
  * Chamberland and Beverland [2018] C. Chamberland and M. E. Beverland, Quantum 2, 53 (2018).
  * Aliferis  _et al._ [2006] P. Aliferis, D. Gottesman, and J. Preskill, Quantum Info. Comput. 6, 97 (2006).
  * Edmonds [1965] J. Edmonds, Canadian Journal of mathematics 17, 449 (1965).
  * Delfosse and Nickerson [2017] N. Delfosse and N. H. Nickerson, arXiv e-prints , arXiv:1709.06218 (2017), arXiv:1709.06218 .
  * Note [4] There are cases where families of error correcting codes have thresholds when using the STOP algorithm to decode with the syndrome from the last round. One such example includes concatenated codes using the methods of [117].
  * Brooks and Preskill [2013] P. Brooks and J. Preskill, Physical Review A 87, 032310 (2013).
  * Anderson  _et al._ [2014] J. T. Anderson, G. Duclos-Cianci, and D. Poulin, Phys. Rev. Lett. 113, 080501 (2014).
  * Vuillot  _et al._ [2019] C. Vuillot, L. Lao, B. Criger, C. G. Almudéver, K. Bertels, and B. M. Terhal, New Journal of Physics 21, 033028 (2019).
  * Landahl and Ryan-Anderson [2014] A. J. Landahl and C. Ryan-Anderson, arXiv e-prints , arXiv:1407.5103 (2014), arXiv:1407.5103 .
  * G. Fowler and Gidney [2018] A. G. Fowler and C. Gidney, arXiv:1808.06709 (2018).
  * Gottesman [1999] D. Gottesman, Proceedings, XXII International Colloquium on Group Theoretical Methods in Physics , 32 (1999).
  * Dennis  _et al._ [2002b] E. Dennis, A. Kitaev, A. Landahl, and J. Preskill, J. Math. Phys. 43, 4452 (2002b).
  * Kovalev and Pryadko [2012] A. A. Kovalev and L. P. Pryadko, arXiv preprint arXiv:1208.2317 (2012).
  * Raussendorf and Harrington [2007] R. Raussendorf and J. Harrington, Physical review letters 98, 190504 (2007).
  * Wang  _et al._ [2011] D. S. Wang, A. G. Fowler, and L. C. L. Hollenberg, Phys. Rev. A 83, 020302 (2011).
  * Fowler [2012b] A. G. Fowler, Phys. Rev. Lett. 109, 180502 (2012b).
  * Chamberland  _et al._ [2020b] C. Chamberland, A. Kubica, T. J. Yoder, and G. Zhu, New Journal of Physics 22, 023019 (2020b).
  * Shor [1996] P. W. Shor, in  _Proceedings of the 37th Annual Symposium on Foundations of Computer Science_ , FOCS ’96 (IEEE Computer Society, USA, 1996) p. 56.
  * Dennis [2001] E. Dennis, Phys. Rev. A 63, 052314 (2001).
  * Jones [2013a] C. Jones, Phys. Rev. A 87, 042305 (2013a).
  * Fowler [2013] A. G. Fowler, arXiv:1310.0863 (2013).
  * Hastings and Haah [2018] M. B. Hastings and J. Haah, Physical review letters 120, 050504 (2018).
  * Jones [2013b] C. Jones, Phys. Rev. A. 87, 022328 (2013b).
  * Eastin [2013] B. Eastin, Phys. Rev. A. 87, 032321 (2013).
  * Campbell and O’Gorman [2016] E. T. Campbell and J. O’Gorman, Quantum Science and Technology 1, 015007 (2016).
  * Campbell and Howard [2017a] E. T. Campbell and M. Howard, Physical Review A 95, 022316 (2017a).
  * Campbell and Howard [2017b] E. T. Campbell and M. Howard, Physical review letters 118, 060501 (2017b).
  * Haah  _et al._ [2017] J. Haah, M. B. Hastings, D. Poulin, and D. Wecker, Quantum 1, 31 (2017).
  * Paetznick and Reichardt [2013] A. Paetznick and B. W. Reichardt, Physical review letters 111, 090505 (2013).
  * Kubica  _et al._ [2015] A. Kubica, B. Yoshida, and F. Pastawski, New Journal of Physics 17, 083026 (2015).
  * Vasmer and Browne [2018] M. Vasmer and D. E. Browne, arXiv preprint arXiv:1801.04255 (2018).
  * MacWilliams and Sloane [1988] F. MacWilliams and N. Sloane,  _The Theory of Error-Correcting Codes_ (North Holland, 1988).