Main

Quantum error-correcting codes are an essential ingredient to protect quantum information in a quantum computer from errors due to coupling to an external environment. Recent progress1,2,3,4,5 has led to the discovery of good quantum low-density parity-check (qLDPC) codes6,7,8, which have a constant encoding rate and relative distance. Such codes are far more efficient at protecting large amounts of quantum information9,10 than standard approaches based on the surface code. An important question is whether the advantages that good qLDPC codes offer for quantum information storage come at the cost of straightforward and efficient logical quantum information processing.

A key requirement for logical quantum gates on a quantum error-correcting code is fault tolerance—they must function in the presence of errors and protect the encoded quantum information throughout a computation. Existing approaches to perform fault-tolerant logical quantum gates can be roughly divided into code preserving and code deforming.

Code-preserving gates include transversal gates11, which act via the same operator on all physical and logical qubits as well as more general locality-preserving gates12. Non-trivial code-preserving gates are synonymous with symmetries of an underlying code13,14. As a consequence, such gates necessitate a degree of structure to exist in the code.

Code-deforming gates are more general and allow a code to be deformed through a sequence of different codes to enact a logical gate15,16. Unlike code-preserving gates, code-deforming gates are generic as they do not necessitate the existence of non-trivial symmetries of the code beyond the logical operators themselves. In particular, code-deforming gates allow for the fault-tolerant measurement of logical operators16. This opens up the possibility of implementing measurement-only quantum computation, where Clifford gates and T-gate injections are implemented via measurement, or a Pauli-based computation17 in which a quantum circuit is compiled into a sequence of generalized magic state injections18. Lattice surgery is a code-deforming approach to fault-tolerant computation for the surface code that has been studied extensively16,18,19,20.

There are a number of proposals for performing fault-tolerant logical gates on qLDPC codes in the literature21,22,23,24,25,26,27. These include code-preserving gates and code-deforming gates. The most direct generalization of surface code lattice surgery is the scheme proposed in ref. 23, and refined in ref. 26, which applies to general qLDPC codes and makes use of an auxiliary system similar to a patch of surface code. The auxiliary system itself incurs a qubit overhead of Θ(Wd), where W is the weight of the logical being measured and d is the code distance. This auxiliary overhead can make fault-tolerant-measurement-based computation much more expensive than implementing a quantum memory. For instance, a good quantum code that uses n = Θ(d) physical qubits to encode k = Θ(d) qubits (ref. 6 provides examples) requires an auxiliary system at least Ω(n2) in size, substantially larger than the code itself. Even for other constant-rate k = Θ(n) codes with polynomial distances d = poly(n), such as hypergraph product codes2,28, measuring generic logical operators with weight W = Θ(n), such as in a Pauli-based computation, uses a superlinear number \(\begin{array}{c}{n}^{\omega (1)}\end{array}\) of qubits in the auxiliary system.

In this work, we introduce a general procedure for the fault-tolerant measurement of a logical operator in a stabilizer code by treating it as a physical symmetry and gauging it via measurement29,30. The gauging procedure is common in the theory of condensed-matter and high-energy physics, it enforces a global symmetry via a product of local symmetries. Our measurement scheme is based on the fact that the gauging transformation makes it possible to infer the measurement of a logical operator via a product of local stabilizers in a deformed code. Gauging has been widely used in theoretical physics to construct new models and establish relationships between known models31,32,33. The connection of gauging to quantum codes has also been studied34,35,36,37,38. Previous work focused on gauging procedures that correspond to the simultaneous initialization and read-out of all logical qubits in a code and did not consider fault tolerance. The appearance of a similar procedure in recent work on weight reduction for quantum codes hints at wider applications of gauging in quantum error correction39,40,41,42,43,44.

Here we go beyond previous work by developing a fault-tolerant gauging measurement procedure that can precisely address arbitrary individual logical operators in a large code block. We prove that the worst-case qubit overhead of the gauging measurement procedure applied to an arbitrary Pauli operator of weight W is \(O(W{\log }^{3}W)\), a substantial improvement over existing results in the literature. We further demonstrate that the flexibility inherent to the gauging measurement procedure leads to better performance than existing schemes for logical measurement25,26 even for small instances of bivariate bicycle (BB) codes10 (see the BB code example section in the Supplementary Information).

Results

Gauging measurement

We now present the procedure to measure a logical operator via gauging. We focus on the task of measuring a logical representative L in an [n, k, d] qLDPC stabilizer code on qubits specified by checks {si} (ref. 11). Choosing an appropriate basis for each qubit, we ensure that L is a product of Pauli-X matrices without loss of generality. We view L as a symmetry of the code by identifying the code space with the ground space of the Hamiltonian H = −∑isi and noting that L commutes with H. From this point of view, it is natural to project into an eigenspace of L by gauging it.

To gauge L, we first pick a connected graph G whose vertices V are identified with the qubits in the support of L. We sometimes refer to this graph as the auxiliary graph. Next, we introduce auxiliary qubits on the edges E of G, one per edge, initialized in the \(\left|0\right\rangle\) state. In the physics literature, these edge qubits are referred to as gauge qubits. Using these edge qubits, we introduce a set of Gauss’s law operators, \({\mathcal{A}}={\{{A}_{v}\}}_{v\in V}\), where Av = XvevXe, and crucially L = ∏vAv, so that we can infer the eigenvalue of L from the eigenvalues of all Av. To obtain these eigenvalues, we measure each Av operator. This results in a deformed code, which is a subsystem code if the number of edge qubits exceeds the number of Gauss’s law operators. However, this subsystem code is gauge fixed by the choice of the initial state for the edge qubits. Specifically, in the stabilizer group, include a set of flux operators \({\mathcal{B}}={\{{B}_{p}\}}_{p\in C}\), where Bp = ∏epZe, and p labels a generating set of cycles for G. The flux operators commute with the Av operators by construction and can be obtained by deforming the initial single-qubit Ze operators on edge qubits following standard stabilizer update rules11.

The measurement of operators in \({\mathcal{A}}\) also necessarily deforms the check operators of the original code. Specifically, those check operators si that have Z-type support (that is, the set of qubits acted on by a Y or Z) intersecting with the support of L do not commute with operators in \({\mathcal{A}}\). Thus, in the deformed code, si is replaced by si times some set of single-qubit Ze operators on edge qubits. This set of edge qubits has a conceptually simple form in relation to the graph G. Because L is logical in the original code, si commutes with it, and therefore, the size of the Z-type support of si on L is even. The corresponding even-sized set of vertices in G can be paired up via a perfect matching μi, that is, a set of edges whose \({{\mathbb{Z}}}_{2}\) boundary is equal to the set of vertices. Then, \({\widetilde{s}}_{i}={s}_{i}{\prod }_{e\in {\mu }_{i}}{Z}_{e}\) is an appropriately deformed version of si, which commutes with \({\mathcal{A}}\). Because the flux operators \({\mathcal{B}}\) defined on cycles of the graph have +1 eigenvalues, different choices of perfect matching result in the same code space.

Figure 1 depicts the Tanner graph of the deformed code including the auxiliary edge qubits, the Gauss’s law operators \({\mathcal{A}}\), the flux operators \({\mathcal{B}}\) and the deformed checks \(\{\widetilde{{s}_{i}}\}\).

Fig. 1: Tanner graph of the gauging measurement and a surface code example.
Fig. 1: Tanner graph of the gauging measurement and a surface code example.
Full size image

Left: Tanner graph of the deformed code can be compactly represented by creating ordered subsets of qubits (circles) and checks (squares) of X, Z or mixed (unlabelled) type. Each edge connecting an X or Z check set \({\mathcal{P}}\) and qubit set \({\mathcal{Q}}\) is labelled by a binary matrix H with \(| {\mathcal{P}}|\) rows and \(| {\mathcal{Q}}|\) columns, where Hij = 1 if and only if the ith check in \({\mathcal{P}}\) acts non-trivially on the jth qubit in \({\mathcal{Q}}\). Edges from the mixed-type check sets are instead labelled with a symplectic matrix of the form [HXHZ], where HX indicates qubits acted on by X and HZ, those by Z. The original code may not be CSS, but we assume (without loss of generality) that L—the operator being measured—is X type and its qubit support is \({\mathcal{L}}\). Set \({\mathcal{C}}\) contains checks from the original code that do not have Z-type support on \({\mathcal{L}}\), whereas set \({\mathcal{S}}\) contains checks that do. Also, \({\mathcal{A}}\) is the set of Gauss’s law operators Av, \({\mathcal{B}}\) is the set of flux operators Bp, \({\mathcal{E}}\) is the set of edge qubits and we abuse the notation so that G also denotes the auxiliary graph’s incidence matrix. Matrix N specifies a cycle basis of G, and M indicates how original stabilizers are deformed by perfect matching in G. Right: applying the gauging measurement procedure to a product of X-type logicals on a pair of surface codes (dark grey edges) and choosing the graph G to be a ladder (light grey edges) results in a standard surface code lattice surgery procedure.

The above gauging procedure maps the original code space into the code space of a deformed code (also known as a gauged code in physics literature37). The gauged code supports fully mobile charges that are created and moved around via strings of Ze operators, and fluxes that are created via Xe operators. These operators can be viewed as generalized higher-form symmetries, and share a mutual braiding anomaly due to the commutation relations of Pauli matrices. To implement the eigenspace projections of the gauging procedure, we rely on measuring the Gauss’s law operators29,30. Although the initial measurement of each Gauss’s law operator may return a random eigenvalue outcome, the product of all outcomes yields the measured eigenvalue of the logical L. We can return to the original code space by simply projecting onto the simultaneous +1 eigenspace of the Ze operators on all the edge qubits. To implement this step, we measure Ze on each edge qubit. Although the outcome of each measurement may be random, it is possible to find a Pauli-X byproduct operator on the original qubits that can be applied to achieve the same effect as projecting onto all the +1 measurement outcome. This step is commonly referred to as ungauging34. These steps are collected in Algorithm 1.

Algorithm 1:

Gauging measurement procedure

Require: a Pauli stabilizer code specified by checks {si} initialized in the physical code state \(\left|\psi \right\rangle\).

 A Pauli logical operator representative L.

 A connected graph G = (V, E) with an arbitrarily chosen vertex v0 and an isomorphism that identifies the qubits in the support of L with the vertices of G.

Ensure: the result σ = ±1 of measuring L and the post-measurement code state \(\left|\Psi \right\rangle =\frac{1}{2}({\mathbb{1}}+\sigma L)\left|\psi \right\rangle\).

σ ← 1

\(\left|\Psi \right\rangle \leftarrow \left|\psi \right\rangle\)

\({\{{\omega }_{e}\}}_{e\in E}\leftarrow {\{1\}}_{e\in E}\)

γ ← {}

for each edge e in G do

  \(\left|\Psi \right\rangle \leftarrow \left|\Psi \right\rangle \otimes {\left|0\right\rangle }_{e}\)     initialize a qubit on e

end for

for each vertex v in G do

  Measure Av on \(\left|\Psi \right\rangle\)       Av = XvevXe

  ε ← measurement result    measurement result is ±1

  \(\left|\Psi \right\rangle \leftarrow \frac{1}{2}({\mathbb{1}}+\varepsilon {A}_{v})\left|\Psi \right\rangle\)    post-measurement state

  σεσ

end for

for each edge e in G do

  Measure Ze on \(\left|\Psi \right\rangle\)

  ωe ← measurement result    measurement result is ±1

  \(\left|\Psi \right\rangle \leftarrow \frac{1}{2}({\mathbb{1}}+{\omega }_{e}{Z}_{e})\left|\Psi \right\rangle\)    post-measurement state

  Discard auxiliary qubit on e

end for

for each vertex v in G do

  γ ← an arbitrary edge path from v0 to v

  ifeγωe = −1 then

   \(\left|\Psi \right\rangle \leftarrow {X}_{v}\left|\Psi \right\rangle\)    apply byproduct operator

  end if

end for

Theorem 1

The gauging procedure defined in Algorithm1is equivalent to performing a projective measurement of L.

Proof

The proof is provided in the Methods.

We note that the auxiliary graph G can be chosen to have additional vertices beyond the qubits in support of a given logical operator. Conceptually, this is achieved by adding an extra qubit, initialized in the \(\left|+\right\rangle\) state, for each desired extra vertex and then gauging L multiplied by X on each extra vertex, instead of L itself. We refer to extra vertices as dummy vertices. In practice, the qubits on dummy vertices do not need to exist; as they are initialized in the \(\left|+\right\rangle\) state, their contribution to the Gauss’s law operators is just the deterministic value +1.

Graph desiderata and constructions

Algorithm 1 is an extremely flexible recipe for logical measurement because the choice of a connected auxiliary graph G is arbitrary. However, the properties of the deformed code strongly depend on the choice of this graph. For instance, the gauging measurement procedure has a qubit overhead equal to the number of edges in the graph G (and involves an additional, proportional number of checks). Next, we list the desirable properties of G to achieve a fault-tolerant implementation of the gauging measurement with a low overhead.

Definition 1

(Suitable graph). Given a logical operator L in a qLDPC code, a suitable graph G for the gauging measurement procedure is defined to be a connected graph that results in a deformed code that is LDPC and has a code distance at least that of the original code.

Theorem 2

(Graph desiderata). Consider the gauging measurement procedure for a logical operator L in a qLDPC code with a choice of connected graph G. If the following desiderata are satisfied, G is a suitable graph.

  1. 1.

    The graph G is sparse, that is, it has a constant degree.

  2. 2.

    The matchings μi for all checks si are of a constant size, and any edge qubit is in no more than a constant number of these matchings.

  3. 3.

    There is a generating set of constant-weight cycles for G such that any edge is in a constant number of cycles from the generating set.

  4. 4.

    The graph G is sufficiently expanding in the sense that its Cheeger constant h(G) is at least 1.

Proof

The first three desiderata are shown to hold if and only if the deformed code is LDPC by explicitly defining a generating set of checks for the deformed code (Lemma 1 in the Methods), and inspecting that the generating set for the LDPC property. Lemma 2 in the Methods establishes that the expansion property in desideratum 4 implies a sufficient deformed code distance.

Theorem 3

(Construction of a suitable G). Consider an arbitrary-weight-W logical L in a qLDPC code; a suitable graph G can be constructed with qubit overhead \(O(W{\log }^{3}W)\).

Proof

We now outline a construction that produces a graph G with qubit overhead \(O(W{\log }^{3}W)\) that satisfies the desiderata in Theorem 2. The graph starts with W vertices associated with the qubits in the support of L. First, to satisfy desideratum 2, for each check si, we pair up the qubits in the intersection of the Z-type support of si with the support of L, and add an edge to G for each pair of matched qubits. This step results in a constant-degree graph due to the LDPC property of the input code. Second, to satisfy desideratum 4, we add edges to G until h(G) ≥ 1. This step can be performed by adding edges to G at random and preserving the constant degree, or by taking an existing constant-degree expander graph with h(G) ≥ 1 and adding its edges to G. Both these methods lead to a constant-degree graph. Third, we take the Cartesian graph product of G with a path graph on r vertices. In other words, this step takes r copies of G and for all i = 1, 2…r − 1, it connects copy i to copy i + 1 by adding an edge between each vertex in copy i and the corresponding vertex in copy i + 1. Fourth, we add edges to the additional layers to sparsify the cycle basis of this product graph and achieve a desired constant-weight cycle basis. This results in a final graph that satisfies the first three desiderata by construction (Lemma 3 in the Methods). The last two steps are based on the Freedman–Hastings decongestion lemma45 and cellulation, and their purpose is to satisfy desideratum 3 by creating a graph with a sparse cycle basis without compromising the other desiderata that were established in steps one and two. Desideratum 4 may not be satisfied by the larger graph created during the decongestion step; however, in Corollary 1 (Methods), we show that as long as the original graph G satisfies desideratum 4, the deformed code distance is at least that of the original code. The Freedman–Hastings decongestion lemma establishes an \(O({\log }^{3}W)\) upper bound on the number of layers needed to sparsify the cycles of an arbitrary constant-degree graph G with W vertices when following the third and fourth steps; ref. 46 provides a detailed review of this point. The lemma comes with an efficient algorithm to construct a sparsified basis of cycles, given a constant-degree graph. Figure 2 shows a depiction of the deformed code after these steps.

Fig. 2: Tanner graph of the decongested and cellulated gauging measurement.
Fig. 2: Tanner graph of the decongested and cellulated gauging measurement.
Full size image

Tanner graph of the complete construction including decongestion and cellulation to guarantee the deformed code is LDPC (Theorem 3). We use the same notation as that in Fig. 1. Here, as a result of the Cartesian product operation in step three of Theorem 3, the r = (R + 1)/2 copies of a base expanding graph G have vertices and edges \(({{\mathcal{A}}}_{j},{{\mathcal{E}}}_{j})\) for odd j. Notation (B1B2) indicates a block matrix constructed from submatrices B1 and B2. We use block matrices in which the qubits of the left block are those on the edges of the expanding graph G and qubits of the right block are those added to cellulate cycles in step four of Theorem 3. Depending on the layer, cellulation is done to different elements of the cycle basis of G. Using \(r=O({\log }^{3}W)\) layers ensures the deformed code is LDPC by the decongestion lemma45.

Fault-tolerant implementation

Even if the measurements are faulty, Algorithm 1 can be implemented in a fault-tolerant manner by measuring the stabilizer checks of the original code for d rounds, followed by measuring the checks of the deformed code for d rounds, and finally measuring the checks of the original code for a further d rounds.

Theorem 4

(Fault tolerance). The fault-tolerant implementation of Algorithm 1with a suitable graph has spacetime fault distance d.

Proof

The proof follows several lemmas that are stated and proved in the ‘Fault-tolerant implementation’ section in the Methods and the spacetime code and spacetime fault-distance section in the Supplementary Information. The argument is structured as follows: the fault distance is shown to be lower bounded by the minimum of the space fault distance and the time fault distance. The time fault distance is lower bounded by the number of rounds between the start and end of the code deformation, which is chosen to be d. The space fault distance is lower bounded by the distance of the original code multiplied by \(\min (1,h(G))\). This is because any logical in the deformed code can be cleaned such that it defines a logical of the original code. The distance reduction of the cleaning is determined by the connectivity of G.

The d rounds of quantum error correction in the original code before and after the gauging measurement are for the purposes of establishing a proof and may be overkill in practice. In a full fault-tolerant computation, the number of rounds required before and after gauging measurement depends on the surrounding operations. If the gauging measurement occurs in the middle of a large computation, it could be that even a constant number of rounds before and after are sufficient to ensure fault tolerance. It is an open question to fully characterize when fault tolerance is achieved with fewer than d rounds between gauging measurements and how this choice affects the threshold depending on the surrounding operations.

Discussion

In this work, we have introduced a method to implement low-overhead fault-tolerant quantum computation with high-distance qLDPC codes. Our method is based on viewing a logical operator as a symmetry and gauging it via local measurements. The gauging measurement procedure allows a high degree of flexibility, making it a promising method that can be optimized for even small code instances with near-term applications. We have taken advantage of this flexibility to devise specific gauging measurements (for example, BB codes) that are more efficient than all existing measurement schemes in the literature23,26.

The gauging measurement goes beyond previous approaches to qLDPC code surgery, which was initiated in ref. 23 and developed in subsequent works25,26,27,47. Our key innovation is the introduction of a flexible ancilla system that is not wholly defined by the structure of the logical in the original code. This allowed us to find a fault-tolerant qLDPC code surgery procedure to measure arbitrary Pauli logicals with a worst-case scaling that is linear in the weight of the target logical, up to polylogarithmic factors. It also allowed us to find more efficient logical measurements on instances with a small block size. The flexibility of the gauging measurement procedure can be used to recover a number of well-known existing schemes for logical measurement including surface code lattice surgery16, the measurement scheme in ref. 23 and the modified version in ref. 26. The recovering existing protocols from the gauging measurement framework section in the Supplementary Information provides more details on how these and other existing protocols are special cases of gauging measurement.

Some aspects of our approach to design high-performance gauging measurements extend previous work on qLDPC code surgery. In particular, ref. 26 points out the importance of sufficient hypergraph expansion to ensure a large fault distance. As a result of our work, we are able to guarantee appropriate expansion in the gauging measurement of an arbitrary logical operator by adding edges to the auxiliary graph. The gauging measurement also implements gauge fixing of the deformed code, as in ref. 26, by measuring the checks associated with cycles in the auxiliary graph. Importantly, the graph-based approach introduced in the gauging measurement allows us to construct a sparse cycle check basis for any code by using cellulation and decongestion41,45 to ensure that the deformed code remains LDPC (Fig. 3). This goes beyond previous ad hoc approaches to gauge fixing on specific instances without a worst-case guarantee, as that in ref. 26.

Concurrent with our work, ref. 48 introduced a similar approach to qLDPC code surgery that involves gauge fixing with cellulation, and boosting expansion by adding edges to an auxiliary graph. There, the focus was on logicals of a fixed Pauli type in the Calderbank–Shor–Steane (CSS) codes, whereas our focus is on general Pauli logicals in stabilizer codes, which can be non-CSS. Furthermore, ref. 48 does not consider decongestion, and, as such, does not provide a worst-case guarantee on the scaling of their logical measurement procedure. In a follow-up work, ref. 49 builds directly on the gauging measurement framework by introducing a graph construction algorithm that is used to find an efficient procedure to perform a joint logical measurement of disjoint logical operators on one or more qLDPC code blocks. This operation is a gauging measurement with a different choice of auxiliary graph to the worst-case construction outlined above.

The progress reported in this work raises a number of directions that invite further investigation. For what families of good qLDPC codes can the gauging measurement be performed with a linear qubit overhead? Can the generalization of the gauging measurement to a hypergraph be used to measure a large number of commuting but overlapping logical operators simultaneously? Can we introduce meta-checks to the generalized gauging measurement procedure to perform a single-shot measurement with a constant time overhead? How should the fault-tolerant gauging measurement be decoded? We expect that a general-purpose decoder based on belief propagation with ordered statistics post-processing can be used; however, it should be possible to take advantage of the extra structure inherent to the procedure to find a decoder with better performance. Such a decoder could incorporate matching on the Av syndromes similar to the approach in ref. 26.

The directions listed here can be interpreted as a list of desiderata for an ideal fault-tolerant logical measurement procedure: it should implement Pauli-based computation, be fully parallelized and have a constant relative overhead in space and time. It remains an open question whether any fault-tolerant logical measurement can satisfy the above desiderata, or how close one can get. Even the answer to the classical analogue of this question is not known.

Fig. 3: Cycle sparsification and cellulation.
Fig. 3: Cycle sparsification and cellulation.
Full size image

Left: cycle sparsification with two layers. Thin, black edges are copies of the original graph and grey edges connect them. A complete cycle basis consists of the highlighted cycles and all length-four cycles between layers that traverse exactly two black and two grey edges. The constant c in Definition 3 is 1 after this sparsification, whereas it was 2 for the original graph, and therefore, \({R}_{G}^{1}=2\). Right: cellulating a weight-six cycle (black) into triangles by adding additional edges (grey).

Methods

Gauging measurement

Here we prove Theorem 1, showing that the gauging measurement correctly performs a logical measurement. We first introduce definitions of boundary and coboundary maps on a graph G.

Definition 2

(\({{\mathbb{Z}}}_{2}\) boundary and coboundary maps). In this work, we use binary vectors to indicate collections of vertices, edges and cycles of the graph G. The boundary mapon an edge vector is a \({{\mathbb{Z}}}_{2}\)-linear map that is defined by its action on a single edge \(\partial e=v+{v}^{{\prime} }\), where v and \({v}^{{\prime} }\) are the adjacent edges of e. The coboundary map is given by the transpose of the boundary map δ = ∂T and satisfies δv = ∑eve. Given a choice of a collection of cycles in G, we also define a second boundary map2 whose action on a cycle is2c = ∑ece. Similarly, we define a second coboundary map \({\delta }_{2}={\partial }_{2}^{{\rm{T}}}\), which acts on a single edge as δ2e = ∑cec.

Remark 1

The maps ∂2, ∂ form an exact sequence if a generating set of cycles is chosen, and similarly for δ, δ2. These sequences are not short exact as δ has a non-trivial kernel given by all vertices.

Throughout this work, we abuse a notation by identifying the binary vector associated with a set of vertices, edges or cycles with the set itself. Where this is done, the meaning should be clear from context.

Proof

(Proof of Theorem 1). Applying the gauging measurement to an initial state \(\left|\Psi \right\rangle\) results in

$$\mathop{\prod }\limits_{v}\frac{1}{2}({\mathbb{1}}+{\varepsilon }_{v}{A}_{v})\left|\Psi \right\rangle {\left|0\right\rangle }_{E}$$
(1)

up to an overall normalization. Here εv is the observed result of measuring the operator Av = XvevXe and \({\left|0\right\rangle }_{E}={\left|0\right\rangle }^{\otimes E}\). Ungauging by measuring out the edge degrees of freedom in the Z basis and discarding them results in the state

$${\left\langle {z}_{e}\right|}_{E}\mathop{\prod }\limits_{v}\frac{1}{2}({\mathbb{1}}+{\varepsilon }_{v}{A}_{v})\left|\Psi \right\rangle {\left|0\right\rangle }_{E},$$
(2)

up to an overall normalization. Here \({\left\langle {z}_{e}\right|}_{E}={\otimes }_{e}{\left\langle {z}_{e}\right|}_{e}\), where ze is the observed result of measuring the operator Ze. Next, we expand the product of projection operators into a sum

$${\left\langle {z}_{e}\right|}_{E}\frac{1}{{2}^{V}}\mathop{\sum }\limits_{c\in {C}^{0}(G,{{\mathbb{Z}}}_{2})}\varepsilon (c){X}_{V}(c){X}_{E}(\delta c)\left|\Psi \right\rangle {\left|0\right\rangle }_{E},$$
(3)

where the sum is over \({{\mathbb{Z}}}_{2}\)-valued 0-cochains on G:

$$\varepsilon (c)=\mathop{\prod }\limits_{v}{\varepsilon }_{v}^{{c}_{v}},$$
(4)
$${X}_{V}(c)=\mathop{\prod }\limits_{v}{X}_{v}^{{c}_{v}},$$
(5)
$${X}_{E}(\delta c)=\mathop{\prod }\limits_{e}{X}_{e}^{{\{\delta c\}}_{e}}.$$
(6)

Since \({\left\langle {z}_{e}\right|}_{E}{X}_{E}(\delta c){\left|0\right\rangle }_{E}\) is zero unless ze = {δc}e on all edges, we can rewrite the ungauged state as

$$\begin{array}{rcl}\frac{1}{{2}^{V}} & & \mathop{\sum }\limits_{c\,{\rm{s.t.}}\,\delta c=z}\varepsilon (c){X}_{V}(c)\left|\Psi \right\rangle \\ =\frac{1}{{2}^{V}}{X}_{V}({c}^{{\prime} }) & & \mathop{\sum }\limits_{c\in {Z}^{0}(G,{{\mathbb{Z}}}_{2})}\varepsilon (c){X}_{V}(c)\left|\Psi \right\rangle \end{array}$$
(7)

for a fixed \({c}^{{\prime} }\) that satisfies \(\delta {c}^{{\prime} }=z\) and \({Z}^{0}(G,{{\mathbb{Z}}}_{2})\) is the group of 0-cocycles on G. For a connected graph G, there are only two elements \(c\in {Z}^{0}(G,{{\mathbb{Z}}}_{2})\), either cv = 1 for all vertices or cv = 0 for all vertices. Hence, the ungauged state is

$${X}_{V}({c}^{{\prime} })\frac{1}{2}({\mathbb{1}}+\sigma L)\left|\Psi \right\rangle ,$$
(8)

where L = ∏vXv is the logical operator being measured and σ = ∏vϵv is the observed outcome of the logical measurement. Here \({X}_{V}({c}^{{\prime} })\) is a Pauli byproduct operator determined by the observed measurement outcomes.

This byproduct operator is the same as the one defined in the final step of Algorithm 1.

Graph desiderata and constructions

In this section, we analyse the deformed code that is created after measuring the Av terms in the gauging measurement procedure. The auxiliary graph G contains vertices V and edges E.

Lemma 1

(Deformed code). The following form a generating set of checks for the deformed code:

  • Av = XvevXe for all v V that are not dummy vertices.

  • Av = ∏evXe for all dummy vertices v V.

  • Bp = ∏eγZe for a generating set of cycles γ E.

  • \({\widetilde{s}}_{i}={s}_{i}{\prod }_{e\in {\mu }_{i}}{Z}_{e}\) for all checks in the input code si and appropriate perfect matchings μi E for each of those checks.

Proof

The Av operators become checks since they are measured during the gauging process. Both Bp and \({\widetilde{s}}_{i}\) operators can be thought of as arising from applying stabilizer update rules11 to the initial stabilizer group generated by checks of the original code {si} and the single-qubit Ze stabilizers on the edge qubits e. Specifically, the Bp operators originate from the Ze stabilizers because for a product of these edge stabilizers to remain a check after measuring the Av = ∏ev Xe operators, it must commute with them all. This is equivalent to a product ∏eγ Ze being over edges γ that satisfies ∂γ = 0, that is, γ represents a graph cycle. Similarly, the \({\widetilde{s}}_{i}\) operators arise from products of si and Ze stabilizers from the initialization step that commute with all Av operators. The specific Av operators that si anticommutes with are those associated with vertices in the set SZ suppZ(si) ∩ supp(L), where suppZ(si) is the Z-type support of si. Thus, commuting with all Av requires a set of edges μi such that ∂μi = suppZ(si) ∩ supp(L), or in other words, μi is a perfect matching of the vertices in SZ.

By counting the qubits and checks, it is evident that the dimension of the code space of the deformed code is only reduced by a single qubit compared with the original code, corresponding to the logical L that is measured by the gauging deformation. A total of E new qubits are introduced along with [V] new independent X-type checks and a number of new independent Z-type checks that is equal to C, the number of generating cycles of G. We then have the well-known relation EC − [V] = −1 for a connected graph. This provides an alternative method to Theorem 1 to see that no logical information is lost beyond the measurement of L.

There is a large degree of freedom when specifying a generating set of checks in the deformed code. If we fix the choice of Av and si checks, then the freedom can be associated with choosing cycles and matchings γ and μi. These choices do not affect the code space, as the Bp operators for any generating set of cycles in G generate the same algebra. Furthermore, the \({\widetilde{s}}_{j}\) operator for two different choices of path γ are related by multiplication with Bp operators. In practice, we aim to choose a set of paths γ and μi that result in a set of checks with a small weight and that result in a small qubit degree (the number of checks a qubit is involved in). Indeed, this is the point of the first three graph desiderata in Theorem 2, which ensure the deformed code is LDPC. The necessity and sufficiency of the desiderata for that purpose should now be clear from inspecting the full set of deformed code checks in Lemma 1.

To complete the proof of Theorem 2, it remains to show that graph expansion implies the deformed code has code distance no smaller than the original code. We do that in the following lemma.

Lemma 2

(Space fault distance). The distance of the deformed code satisfies \({d}^{* }\ge \min (h(G),1)d\), where h(G) is the Cheeger constant of G and d is the distance of the original code.

Proof

A logical operator on the deformed code can be written as \({L}^{{\prime} }={i}^{\sigma }{L}_{X}^{V}{L}_{Z}^{V}{L}_{X}^{E}{L}_{Z}^{E}\widetilde{L}\). Here \(\widetilde{L}\) captures the support of \({L}^{{\prime} }\) that does not intersect the gauged logical, \({{\mathcal{S}}}_{X}\) denotes the X support of \({L}^{{\prime} }\), \({L}_{X}^{V}={\prod }_{v\in {{\mathcal{S}}}_{X}\cap {V}_{G}}{X}_{v}\) captures the intersection of the X support of \({L}^{{\prime} }\) with the gauged logical, \({L}_{X}^{E}={\prod }_{e\in {{\mathcal{S}}}_{X}\cap {E}_{G}}{X}_{e}\) captures the X support of \({L}^{{\prime} }\) on the edges introduced by the gauging procedure, and similarly for Z.

First, we consider the X-type component of the logical operator \({L}^{{\prime} }\). The logical operator must commute with the Bp checks by definition; hence, \({{\mathcal{S}}}_{X}^{E}={{\mathcal{S}}}_{X}\cap {E}_{G}\) is a 1-cocycle on the graph G as it satisfies \({\delta }_{2}{{\mathcal{S}}}_{X}^{E}=0\). Since the Bp terms are defined on a generating set of cycles, we have that the sequence formed by δ, δ2 is exact (Remark 1). Hence, \({{\mathcal{S}}}_{X}^{E}=\delta {\widetilde{{\mathcal{S}}}}_{X}^{V}\) for some set of vertices \({\widetilde{{\mathcal{S}}}}_{X}^{V}\subset {V}_{G}\). From this, we have \({L}_{X}^{E}={\overline{L}}_{X}^{V}{\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{A}_{v}\), where \({\overline{L}}_{X}^{V}={\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{X}_{v}\). We now have another logical representative that is equivalent to \({L}^{{\prime} }\), given by \(\overline{L}={i}^{\sigma }{L}_{X}^{V}{\overline{L}}_{X}^{V}{L}_{Z}^{V}{L}_{Z}^{E}\widetilde{L}={L}^{{\prime} }{\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{A}_{v}\).

Next, we consider the Z-type component of the logical operator \({L}^{{\prime} }\). We first point out that the deformed checks \({\widetilde{s}}_{i}\) are given by the original checks, potentially multiplied with some Ze operators. Similarly, the equivalent logical operator \(\overline{L}\) is some operator on the original qubits potentially multiplied by Ze operators.

From this, we can see that the equivalent logical operator restricted to the qubits of the original code \(\overline{L}{| }_{V}={i}^{\sigma }{L}_{X}^{V}{\overline{L}}_{X}^{V}{L}_{Z}^{V}\widetilde{L}\) must be a logical operator of the original code. This is because it must commute with the deformed checks; since the additional operators on the edge qubits in the deformed checks are all of the form Ze, they play no role in the commutation relations. From this, we see that the full equivalent logical operator \(\overline{L}\) is obtained from the restricted logical \(\overline{L}{| }_{V}\) via the gauging code deformation.

Hence, any logical in the deformed code is equivalent to a logical on the original code \(\overline{L}{| }_{V}\) potentially multiplied by some Ze operators. The weight of any non-trivial logical on the original code, such as \(\overline{L}{| }_{V}\), is lower bounded by the distance d. Hence, the weight of the unrestricted logical \(\overline{L}\) is also lower bounded by d. Furthermore, we can construct \(\overline{L}\) to have support on no more than half the vertex qubits \(\le \frac{| V| }{2}\) by optionally multiplying \({L}^{{\prime} }\) with the stabilizer \({\prod }_{v\in {V}_{\bar{G}}}{A}_{v}\).

We now lower bound the relative change in operator weight, induced by the equivalence under multiplication with vertex stabilizers that convert the deformed logical \(\overline{L}\) back to the logical \({L}^{{\prime} }\), by the Cheeger constant h(G) of a single layer of graph G. In the worst case, multiplication with \({\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{A}_{v}\) to convert \(\overline{L}\) to \({L}^{{\prime} }\) removes the support on the vertex set \({\widetilde{{\mathcal{S}}}}_{X}^{V}\) and adds support on the edge coboundary set \(\delta {\widetilde{{\mathcal{S}}}}_{X}^{V}\). Then, we apply \(| \delta {\widetilde{{\mathcal{S}}}}_{X}^{V}| \ge h(G)| {\widetilde{{\mathcal{S}}}}_{X}^{V}|\) to achieve the distance bound on the logical \({L}^{{\prime} }\).

In the rest of this subsection, we discuss the cycle sparsification step in more detail and ensure it preserves the first three desiderata and the deformed code distance, as claimed in Theorem 3.

Definition 3

(Cycle-sparsified graph \(\bar{G}\)). Given a graph G and a constant c, we call the cycle degree, a cycle sparsification of G is a new graph that is built by adding edges to copies of G numbered 1, 2…r, and alternatively referred to as layers (as shown in Fig. 2; also see Fig. 3). One type of additional edge connects each vertex to its layer in the subsequent layer and serves to implement the Cartesian product operation of graph G with a path graph on r vertices (Fig. 3). The other type of additional edges cellulate a cycle into triangles by connecting vertices as follows: {(1, N − 1), (N − 1, 2), (2, N − 2), (N − 2, 3),…} following an ordering of the vertices as they are visited when the cycle is traversed (Fig. 3). If the original graph had cycle basis {γi}, the cycle-sparsified graph cellulates exactly one copy of each γi, and, given a sufficient number of layers r, the number of these cellulated cycles containing any particular edge can be chosen to be at most c for any choice of c ≥ 1. We use \({R}_{G}^{c}\) to denote the minimal number of layers to achieve a cycle sparsification of G with constant c. Besides L, the number of specified vertices in the first layer; all vertices in the cycle-sparsified graph are dummy vertices.

Remark 2

The cycle-sparsified graph \(\bar{G}\) may fail to satisfy desideratum 4. This is because the cycle sparsification step does not preserve h(G) ≥ 1. In particular, once there are more than four copies of G in the cycle-sparsified graph \(\bar{G}\), the set \({V}_{0,1}={V}_{{G}_{0}}\cup {V}_{{G}_{1}}\) of all vertices on the first two copies of G satisfies \(| \delta {V}_{0,1}| =| {V}_{{G}_{1}}| =\frac{1}{2}| {V}_{0,1}|\), and hence, the Cheeger constant is upper bounded by a half. Below, we prove that \(\bar{G}\) nonetheless results in a deformed code with the same distance bound as for G. The reason behind this is that sufficient expansion in the first layer of G that is attached directly to the logical operator suffices to guarantee that the distance is preserved during code deformation.

Corollary 1

(Cycle-sparsified space fault distance). The distance of the deformed code based on the cycle-sparsified graph \(\bar{G}\) (Definition3) satisfies d* ≥ (h(G), 1)d.

Proof

Following the proof of Lemma 2, we have \({L}_{X}^{E}={\overline{L}}_{X}^{V}{\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{A}_{v}\), where \({\overline{L}}_{X}^{V}={\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}\cap {V}_{{G}_{0}}}{X}_{v}\). In the definition of \({\overline{L}}_{X}^{V}\), the product of the operators is only over vertices in G0 since the vertices in the other layers are dummy vertices, which do not support qubits. We now have that \(\overline{L}={i}^{\sigma }{L}_{X}^{V}{\overline{L}}_{X}^{V}{L}_{Z}^{V}{L}_{Z}^{E}\widetilde{L}={L}^{{\prime} }{\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{A}_{v}\) is a logical representative equivalent to \({L}^{{\prime} }\). The restriction of the logical \(\overline{L}\) to the original qubits produces a logical in the original code; hence, the weight of \(\overline{L}\) is at least the distance of the original code.

To bound the distance of the general logical \({L}^{{\prime} }\) in the deformed code, we now focus on the change in weight caused by the term \({\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{A}_{v}\). The size of the vertex set \({\widetilde{{\mathcal{S}}}}_{X}^{V}\cap {V}_{{G}_{0}}\) can be taken as \(\le \frac{| {V}_{{G}_{0}}| }{2}\), up to multiplying \({L}^{{\prime} }\) with the measured logical, which is now the stabilizer \({\prod }_{v\in \bar{G}}{A}_{v}\). The operator \(\overline{L}{\prod }_{v\in {\widetilde{{\mathcal{S}}}}_{X}^{V}}{A}_{v}\) has X support on at least all edges in \(\left(\delta ({\widetilde{{\mathcal{S}}}}_{X}^{V}\cap {V}_{{G}_{0}})\right)\cap {E}_{{G}_{0}}\). This is the set of edges inside G0 that are in the coboundary of the relevant vertices in G0. The size of this set satisfies \(| \left(\delta ({\widetilde{{\mathcal{S}}}}_{X}^{V}\cap {V}_{{G}_{0}})\right)\cap {E}_{{G}_{0}}|\) \(\ge h(G)| {\widetilde{{\mathcal{S}}}}_{X}^{V}\cap {V}_{{G}_{0}}|\). Hence, the relative weight of \({L}^{{\prime} }\) and \(\overline{L}\) is lower bounded by h(G).

Lemma 3

Given a graph G that satisfies the first two desiderata in Theorem 2, its cycle sparsification \(\bar{G}\) satisfies the first three desiderata in Theorem 2.

Proof

The degree of the cycle-sparsified graph \(\bar{G}\) is upper bounded by the degree of G plus the constant (deg(G)c + 2), where c is the congestion number of cycles in the chosen basis that are assigned to a single layer of \(\bar{G}\). Hence, if the graph G satisfies desideratum 1, so too does \(\bar{G}\). The cycle-sparsified graph \(\bar{G}\) supports matchings μi that can be routed entirely through the first layer since that layer is already a connected graph containing all the non-dummy vertices. Hence, assuming the graph G satisfies desideratum 2, so too does \(\bar{G}\). The cycle-sparsified graph \(\bar{G}\) has a cycle basis consisting of length-three and length-four cycles by construction. Hence, \(\bar{G}\) satisfies desideratum 3.

We use the freedom in choosing checks of the deformed code per Lemma 1 for the cycle-sparsified graph to take advantage of the layered structure. This leads to a very natural cycle basis constructed from cycles with a length of ≤4 coming in two types. First, for each layer i = 1, 2…r − 1 and each edge e E of the original graph, there is a length-four cycle γi,e, which consists of the copy of edge e in layer i, the copy of the edge e in layer i + 1, and the two edges connecting the layers together and adjacent to those copies of e. Second, there are length-three cycles resulting from the triangular cellulations.

In Definition 3, we have chosen to cellulate the cycles into triangles as they have minimal weight. A similar procedure applies for squares, or even arbitrary polygons, which need not have a uniform number of edges. We note that using squares is also natural in the sense that square cycles already appear between layers in the cycle-sparsified graph.

For a constant-degree graph, there are Θ(V) cycles in a minimal generating set. For a random expander graph, making an appropriate choice, almost all generating cycles are expected to be of length \(O(\log | V| )\). In this case, we expect a cycle degree of \(O(\log | V| )\) and a number of layers \({R}_{G}^{c}=O(\log | V| )\) required for cycle sparsification. We remark that the decongestion lemma45 establishes a worst-case bound \({R}_{G}^{c}=O({\log }^{3}| V| )\) for cycle sparsification of a constant-degree graph. This leads to the overhead scaling bound in Theorem 3; ref. 46 provides a detailed review of this point. On the other hand, for some cases of the gauging measurement, no sparsification is required, such as the BB code example presented later. It would be interesting to understand conditions under which this occurs generally.

Fault-tolerant implementation

In this section, we provide an overview of the fault-tolerant operation of the gauging measurement procedure. Detailed definitions and proofs of fault tolerance are provided in the spacetime code and fault distance section in the Supplementary information.

To prove Theorem 4, we analyse the gauging measurement in a standard phenomenological noise model50 in which qubits and measurements of Pauli operators can suffer errors, but we ignore circuit-level details that may spread errors or introduce other sources of correlated errors. Our main strategy to ensure fault tolerance is to repeat the measurement of the checks of the deformed code, that is, Av, Bp and \({\widetilde{s}}_{i}\), at least d times, where d is the code distance of the original code. Intuitively, this provides redundant, and hopefully independent, measurements of logical L since the set of Av measurements at any time t = 1, 2…d, denoted as \(\{{A}_{v}^{(t)}\}\), would ideally satisfy \(L={L}^{(t)}:={\prod }_{v}{A}_{v}^{(t)}\). If the L(t) values are not constant in time, however, we know an error occurred and can, in some cases, correct it.

The complete proof of Theorem 4 is involved; we provide details in the spacetime code and fault-distance section in the Supplementary Information and only summarize the main ideas here. This starts with some basic definitions (similar to ref. 51).

Definition 4

(Space and time faults). A space fault is a Pauli error operator that occurs on some qubit during the implementation of the gauging measurement. A time fault is a measurement error in which the result of a measurement is incorrectly reported during the implementation of the gauging measurement. A general spacetime fault is a collection of space and time faults.

For the purposes of our discussion, state initializations can be implemented via single-qubit Z measurement followed by a conditional application of X to prepare the \(\left|0\right\rangle\) state. State initialization faults (occurring, for example, when an edge qubit is initialized in \(\left|1\right\rangle\) instead of \(\left|0\right\rangle\) due to an error) can be considered space faults by decomposing them into a perfect initialization followed by a Pauli error.

Definition 5

(Detectors). A detector is a collection of state initializations and measurements that ideally yield a deterministic result, in the sense that the product of the observed measurement results must be +1 independent of the individual measurement outcomes, if there are no faults in the procedure.

The set of detectors defines a spacetime code. We enumerate the detectors in gauging measurement in lemma 1 in the Supplementary Information. Generally, detectors are formed from subsequent measurements of the same check operator. This changes slightly at the first round of measurement in the deformed code, where the measurements of si and \({\widetilde{s}}_{i}\) together form a detector, and on the return to the original code when the edge qubits are measured out, where the measurements of si, \({\widetilde{s}}_{i}\), and of the edge qubits in μi altogether form a detector.

Definition 6

(Syndrome). The syndrome caused by a spacetime fault is defined to be the set of detectors that are violated in the presence of the fault. That is, the set of detectors that do not satisfy the constraint that the observed measurement results multiply to +1 in the presence of the fault.

With these definitions in hand, it is natural to define a spacetime logical fault to be a collection of space and time faults that violates no detectors, or in other words, has a trivial syndrome. Similarly, by propagating the errors through the procedure, we can determine if a spacetime logical fault affects the result of the gauging measurement procedure, either by flipping the logical measurement result or by causing a logical operator other than L to be applied. If the spacetime logical fault does not affect the logical outcome of the procedure, we say it is a spacetime stabilizer; otherwise, it is a non-trivial spacetime logical fault. The minimum number of faults in a non-trivial spacetime logical fault is called the spacetime fault distance.

In the spacetime code and fault-distance section in the Supplementary Information, theorem 1 shows that the spacetime fault distance of gauging measurement is d provided that a graph G satisfying desideratum 3 in theorem 2 is used, and that at least d rounds of syndrome measurement in the deformed code are performed. Interestingly, we can show this by separately considering (1) that it takes at least d measurement faults to cause a non-trivial spacetime logical fault (that is, the time fault distance is at least d; lemma 3 in the Supplementary Information) and (2) that the distance of the deformed code, or what we called the space fault distance in lemma 2, is also at least d. Effectively, these two failure mechanisms, time-like or space-like faults, can be cleanly separated (lemma 4 in the Supplementary Information) by multiplying an arbitrary spacetime logical fault by spacetime stabilizers, the structure of which we also explicitly describe in lemma 2 in the Supplementary Information.