Introduction

As gauge theories lie at the heart of the framework governing the interactions and forces described by the Standard Model, considerable effort has been expended in numerical simulations of these theories for computing physical quantities. Lattice gauge theories (LGTs) have been among the most fruitful formulations of non-perturbative approaches amenable for implementation on classical computers1,2,3,4,5. In regimes where classical simulations are plagued by an exponential scaling of the computational cost, digital quantum computers have emerged as a promising platform for the efficient simulation of LGTs. Notable examples are real-time dynamics or the study of systems at finite density6,7,8,9.

Despite considerable advances on this front, digital quantum simulation of LGTs can time-evolve a given fiducial state into unphysical sectors due to noise and the approximation error associated with the simulation protocol used. A popular approach to mitigate this problem, especially useful for ground-state calculations but shown to be useful also out-of-equilibrium10, is to enforce Gauss’ law by adding an energy penalty to the Hamiltonian (see e.g.,6,7,10,11,12 and also13 for techniques to reduce the gate cost of adding penalty terms). Another recent proposal for error mitigation in gauge theories uses random gauge transformations to suppress the component of the quantum state in the unphysical Hilbert space14,15. The recent approach proposed in16, and its generalization to non-Abelian theories17, uses instead a quantum oracle to detect the presence of gauge violating errors by performing explicit Gauss’ law checks and flagging an ancilla qubit. These techniques are suitable for error detection but in general do not possess error correction capabilities and are not fault-tolerant.

With the long-time goal of performing quantum simulation of LGT on fault-tolerant protocols, an intriguing possibility is to tailor general purpose error correction schemes to best exploit the structural properties of these theories in order to reduce the resource requirements for early explorations (see e.g.,18 for a recent attempt in this direction using the surface code). The physical intuition behind the approach followed in this work is that error correcting codes can be seen as artificial gauge theories where the logical Hilbert space is determined by states that satisfy a suitable local symmetry. When simulating LGTs which themselves need to satisfy a physical local symmetry, it might then be advantageous to exploit this natural redundancy to reduce the cost of the full error correction encoding.

We develop in this work fault-tolerant algorithms for error correction suitable for \({{\mathbb{Z}}}_{2}\) or truncated U(1) lattice gauge theories in 1+1, and 2+1 spacetime dimensions with a cutoff of 1 on the links. These algorithms combine the physicality constraint provided by Gauss’ law with bit and phase flip error correction codes19 to detect and correct errors stemming from device noise that occur on a site or its adjacent links. Error correction for a 1D lattice with 2N links and 2N staggered fermionic sites with periodic boundary conditions is accomplished by tessellating these encodings across the whole lattice so that errors occurring on a particular site and its adjacent link can be detected by a Gauss’ law check on the next set of sites and links. The extension to 2D follows a similar idea using instead plaquettes and links coming out of them as the fundamental blocks of the partition.

In the electric basis used here, a gauge violation is caused by bit-flip errors which can be corrected using a standard encoding based on the repetition code using 12N qubits: 3 for each site and 3 for each link (see the schematic illustration in Fig. 1a). The error correction procedure proposed here instead requires no bit-flip repetition code for the fermionic sites and a compressed encoding requiring only half of the qubits (3N in total) for the link variables. Full fault-tolerance can then be achieved by concatenation with a standard phase-flip code (similar to what is done in the 9 qubit Shor code19) and using fault tolerant gadget design (e.g., using flag qubits20). For the simpler case when the fermionic sites are non-dynamical, i.e., they can be represented by classical bits, the scheme proposed here requires 9N qubits for unit flux cutoffs with O(1) ancillas. The full construction depicted in Fig. 1a involving dynamical fermions requires 15N qubits with O(1) ancillas. These are to be contrasted with the 10N and 20N qubits required for the two cases respectively using the [5,1,3] code for each site and link21,22. Similarly, our construction for the 2D case requires for a lattice with 8NxNy links and 4NxNy sites, a total of 48NxNy qubits for the dynamical fermion case and 36NxNy qubits in pure gauge or with only static charges. For comparison, a [5, 1, 3] code would require 60NxNy and 40NxNy qubits, respectively (see Fig. 1b). It is foreseeable that more space efficient codes could be constructed, with the present work developing a first attempt to exploit the intrinsic redundancy present in gauge theories to reduce the cost of the error correction procedures required for their simulation at large scale.

Fig. 1: Error correction with Gauss’s law.
figure 1

a Schematic illustration of the differences between two error-correcting schemes for a simple one-dimensional LGT: a traditional bit-flip encoding scheme and the two schemes proposed here exploiting the Gauss’ law gauge symmetry. b Number of qubits required (excluding ancillas) for performing fault-tolerant error-correction with different encodings on a \({{\mathbb{Z}}}_{2}\) or truncated U(1) 1+1 dimensional LGT system with 2N links, 2N staggered fermions and a 2+1 dimensional LGT with 8NxNy links and 4NxNy sites, both with a flux cutoff of 1. The second row gives the cost for an encoding where Gauss’s law is exploited to give a bit-flip encoding via an extra even-numbered link qubit in 1+1 D. The last row of the 1+1 and 2+1 D cases gives the cost when only the redundancies from Gauss’s law are used at the logical level to perform error correction. The case with non-dynamical fermions requires the same resources as the pure gauge case and is omitted from the table.

The structure of the paper is as follows: “Structure of U(1) and \({{\mathbb{Z}}}_{n}\) Abelian” lattice gauge theories introduces the structure of U(1) and \({{\mathbb{Z}}}_{n}\) Abelian LGTs. “Preliminaries on the repetition code” surveys the basics of error correction codes and develops the formalism for integrating Gauss’ law with a repetition code. “Pure gauge theory” and on then presents applications of these ideas for pure gauge theory first before treating the cases of error correction for a Z2 1+1 dimensional LGT with both non-dynamical and dynamical fermions. We discuss an extension of these ideas to the more complex case of 2 spatial dimensions in “Extension to two dimensions”. “Discussion” summarizes the results and discusses future work for extending these results to different symmetry groups, and higher spacetime dimensions, and flux cutoffs.

Results

Structure of U(1) and \({{\mathbb{Z}}}_{n}\) Abelian lattice gauge theories

We follow the basic outline given in ref. 16 and review the structure of abelian lattice gauge theories, specifically for the general gauge groups \(G={{\mathbb{Z}}}_{n}\) and G = U(1) which contain those considered throughout this work. There are several physical models for which the gauge symmetries discussed here are important such as the Schwinger Model, or QED in 1+1 dimensions on a lattice23,24. It is the one of the simplest concrete examples of an Abelian LGT and serves as a convenient setting for the analysis and application of Gauss’ law symmetries to error correction. This model has been extensively used as an important stepping stone in simulations of lattice field theories using both tensor networks and quantum devices11,25,26,27,28.

We discretize space on a cubic lattice L with sites labeled by s and links labeled by l. We assume that the lattice consists of N sites for even N ≥ 0 and that a staggered fermion representation is used wherein every second site is positronic. Each link l is associated an independent separable Hilbert space \({{{{\mathcal{H}}}}}_{l}\) with the same orthonormal basis:

$$\langle {\epsilon }^{{\prime} }| \epsilon \rangle ={\delta }_{{\epsilon}^{{\prime} },\epsilon},\,\,\,\,\,\,\,\,\hat{{\mathbb{1}}}=\mathop{\sum}\limits_{\epsilon }\left\vert \epsilon \right\rangle \left\langle \epsilon \right\vert$$
(1)

with

$${\epsilon }^{{\prime} },\epsilon \in \left\{\begin{array}{ll}{{\mathbb{Z}}}_{n},\quad &{{{\rm{if}}}}\,G={{\mathbb{Z}}}_{n}\\ {\mathbb{Z}},\quad &{{{\rm{if}}}}\,G={{{\rm{U}}}}(1).\end{array}\right.$$

The Hamiltonian for this LGT is a function of the link operators \({\hat{U}}_{l}\) and their conjugate electric fields \({\hat{E}}_{l}\) defined explicitly in this basis by

$${\hat{U}}_{l}=\mathop{\sum}\limits_{{\epsilon }_{l}}\left\vert {\epsilon }_{l}+1\right\rangle \left\langle {\epsilon }_{l}\right\vert ,\,\,\,\,\,\,\,\,\,\,\,\,{\hat{E}}_{l}=\mathop{\sum}\limits_{{\epsilon }_{l}}{\epsilon }_{l}\left\vert {\epsilon }_{l}\right\rangle \left\langle {\epsilon }_{l}\right\vert .$$
(2)

From this expression we can see that \({\hat{U}}_{l}\) acts as a raising operator and its adjoint as a lowering operator on the Hilbert space \({{{{\mathcal{H}}}}}_{l}\) of the link. Operators defined on different link Hilbert spaces commute while the same-link commutation relations are given by

$$[{\hat{E}}_{l},{\hat{U}}_{l}]={\hat{U}}_{l},\,\,\,\,\,\,\,\,\,\,G={{{\rm{U}}}}(1)$$
(3)
$${\hat{Q}}_{l}{\hat{U}}_{l}{\hat{Q}}_{l}^{{\dagger} }={\hat{U}}_{l}{e}^{2\pi i/n}\,\,\,\,\,\,\,\,\,\,G={{\mathbb{Z}}}_{n}$$
(4)

where

$${\hat{Q}}_{l}:={e}^{2\pi i{\hat{E}}_{l}/n}=\mathop{\sum }\limits_{{\epsilon }_{l}=0}^{N-1}{e}^{2\pi i{\epsilon }_{l}/n}\left\vert {\epsilon }_{l}\right\rangle \left\langle {\epsilon }_{l}\right\vert .$$

The form of the commutation relation for \({{\mathbb{Z}}}_{n}\) is due to the fact that the electric field values are periodic, so the Hamiltonian depends on \({\hat{Q}}_{l}\).

When considering fermionic matter fields on the sites, we work in the occupation number basis where number operators nσ are diagonal with eigenvalues {0, 1}. Here, σ is a collective index denoting the relevant species or indices (like flavor or spinor) involved. The global state of the entire lattice is spanned by a basis given by a specification of electric fields on the links of the lattice and occupation numbers on the sites. Due to the locality of the symmetry, we will typically consider a particular site on a lattice and those links attached to it and denote the corresponding basis states by

$$\left\vert {{{\bf{E}}}},\rho \right\rangle \to {\otimes }_{i = 1}^{D}\left\vert {E}_{i}(s)\right\rangle {\otimes }_{i = 1}^{D}\left\vert {E}_{i}(s-{\hat{e}}_{i})\right\rangle {\otimes }_{\sigma }\left\vert {n}_{\sigma }\right\rangle ,$$

where D is the spatial dimension of the lattice and ρ is a discretized charge density defined by

$$\hat{\rho }(s)=\mathop{\sum}\limits_{\sigma }{e}_{\sigma }{\hat{n}}_{\sigma }(s),$$

and eσ = ± 1. Due to gauge invariance, states in the physical Hilbert space satisfy a local Gauss’ law which relates the state of a site with the state of the links emanating from it. Gauge-invariant states are in the kernel of the operator

$$\begin{array}{lll}{\hat{G}}_{s}&:=&(\nabla \cdot \hat{E})(s)-\hat{\rho }(s)\\ &:=&\mathop{\sum }\limits_{i=1}^{D}({\hat{E}}_{i}(s)-{\hat{E}}_{i}(s-{\hat{e}}_{i}))-\mathop{\sum}\limits_{\sigma }{e}_{\sigma }{\hat{n}}_{\sigma }(s),\end{array}$$
(5)

where the second line is obtained by discretization of the gradient operator on the lattice.

When dealing with a U(1) gauge group, it is necessary to truncate the link electric field values to enable digital quantum simulation with a finite number of qubits. This can be accomplished by wrapping the electric field at a cutoff Λ:

$${\hat{E}}_{l}=\mathop{\sum }\limits_{{\epsilon }_{l}=-{{\Lambda }}}^{{{\Lambda }}-1}{\epsilon }_{l}\left\vert {\epsilon }_{l}\right\rangle \left\langle {\epsilon }_{l}\right\vert$$
(6)
$${\hat{U}}_{l}\left\vert {{\Lambda }}-1\right\rangle =\left\vert -{{\Lambda }}\right\rangle$$
(7)
$${\hat{U}}_{l}^{{\dagger} }\left\vert -{{\Lambda }}\right\rangle =\left\vert {{\Lambda }}-1\right\rangle .$$
(8)

This choice of discretization results in a modification of the commutation relations as follows:

$$[{\hat{E}}_{l},{\hat{U}}_{l}]={\hat{U}}_{l}-2{{\Lambda }}\left\vert -{{\Lambda }}\right\rangle \left\langle {{\Lambda }}-1\right\vert$$
(9)
$$[{\hat{E}}_{l},{\hat{U}}_{l}^{{\dagger} }]=-{\hat{U}}_{l}^{{\dagger} }+2{{\Lambda }}\left\vert {{\Lambda }}-1\right\rangle \left\langle -{{\Lambda }}\right\vert .$$
(10)

Note that with our choice of the lower and upper bound, the link Hilbert spaces are even-dimensional and can therefore be mapped onto a \(\lceil \log (2{{\Lambda }})\rceil\)-qubit Hilbert space. In this work, we will restrict the discussion to Λ = 1 and comment on the prospects of generalizing our constructions to arbitrary cutoffs in “Discussion”.

Preliminaries on the repetition code

We briefly discuss the bit and phase-flip error correction codes used throughout the paper, following the treatment given in ref. 29, and show how to integrate them with Gauss’ law to reduce the number of qubits required. The overarching idea is to perform an encoding of the link physical qubits into logical states and use the local gauge symmetry to implement a more space-efficient error correction code under an error model with arbitrary single-qubit errors.

First consider a noisy classical communications channel through which we wish to send a bit between two locations and suppose its behavior is such that it flips the bit with probability p. To protect the bit against the effects of noise, we can employ what is known as a repetition code. This involves replacing the bit with three copies of itself, i.e., 0 → 000 and 1 → 111. These new bit strings are denoted as the logical 0 and logical 1 and we send these through the channel. The receiver then attempts to decode what the original bit was. If the output is 010 for instance, then provided the probability p of error is not high and the noise acts independently on each bit, it is likely the second bit was flipped and that the original bit was 0. This is known as majority voting, since the intended original message is determined by whatever bit value appears more in the output. This can obviously fail if more than one bit was flipped. It can be easily determined that with this encoding scheme, the transmission becomes more reliable if p < 1/2.

Now consider a noisy quantum channel that applies a bit-flip, or X gate, to a state \(\left\vert \psi \right\rangle\) sent through it with probability p. We write \(\left\vert \psi \right\rangle\) in terms of the computational basis as \(\left\vert \psi \right\rangle =a\left\vert 0\right\rangle +b\left\vert 1\right\rangle\) and encode it in three qubits as \(a\left\vert 000\right\rangle +b\left\vert 111\right\rangle\). In other words, we have a mapping between the “physical" qubits \(\left\vert 0\right\rangle\) and \(\left\vert 1\right\rangle\) to the logical qubits \({\left\vert 0\right\rangle }_{L}=\left\vert 000\right\rangle\) and \({\left\vert 1\right\rangle }_{L}=\left\vert 111\right\rangle\) respectively, where the subscript L denotes a logical state. Such an encoding can be accomplished by the encoding portion of the circuit in Fig. 2a.

Fig. 2: Bit-flip error correction procedure.
figure 2

a Full circuit for correcting a bit flip errors on a general state \(\left\vert \psi \right\rangle =a\left\vert 0\right\rangle +b\left\vert 1\right\rangle\). b Equivalent circuit for the measurement of the stabilizers Z1Z2 and Z2Z3 for the bit-flip error correction code. This can be obtained from the identity HZH = X and the fact that controlled-Z gates are equivalent to a controlled-Z gate with the control and target flipped. c Syndrome measurements outcomes, and correction operations for bit flip error correction code.

Each qubit in the encoded state is passed through a separate bit-flip channel. If a bit-flip occurs on at most one qubit, we can measure the parities of the qubits by performing projective measurements of the operators Z1Z2 and Z2Z3, where the tensor product is implied. This process is known as making syndrome measurements for the error syndromes Z1Z2 and Z2Z3. These operators have eigenvalues of ±1. Z1Z2 measures the parities of the first two qubits and yields the eigenvalue −1 if they differ and +1 if they do not. Z2Z3 acts in the same way for the second and third qubits. The measurement outcomes of either operator allows us to determine which qubit was flipped. For instance, if eigenvalues of −1 are obtained from the measurement of both operators, we know that with high probability the second qubit was flipped. We can then perform error correction by applying an X gate on the 2nd qubit to flip it back to its original state. Note that the measurement of these operators gives no information about the amplitudes a and b of the encoded state and therefore do not destroy the state we wish to perform error detection and correction on. Figure 2b outlines the possible measurement outcomes for the syndromes Z1Z2 and Z2Z3 and the error correction operations to perform. Figure 2a gives the full circuit to correct bit-flip errors. An equivalent circuit used for the projective measurement of the stabilizers Z1Z2 and Z2Z3 is presented in Fig. 2c. We will use this decomposition in the rest of this work.

Now suppose we have a noisy quantum channel that applies a phase flip (i.e., a Z gate) with probability p to a qubit in the state \(\left\vert \psi \right\rangle =a\left\vert 0\right\rangle +b\left\vert 1\right\rangle\). Unlike the bit-flip encoding, there is no classical analog of applying a phase to a bit. However, we can convert this channel to a bit flip channel by working in the \(\left\vert +\right\rangle =(\left\vert 0\right\rangle +\left\vert 1\right\rangle )/\sqrt{2}\) and \(\left\vert -\right\rangle =(\left\vert 0\right\rangle -\left\vert 1\right\rangle )/\sqrt{2}\) basis. With respect to this basis, the Z operator takes \(\left\vert +\right\rangle\) to \(\left\vert -\right\rangle\) and therefore acts as a bit flip. We can then apply the same logic for error correction in the bit-flip case to the present case by switching from the computational basis to the \(\left\vert +\right\rangle\) and \(\left\vert -\right\rangle\) basis via the Hadamard gate. In our present work, we will find it convenient to use the logical codeword basis \({\left\vert 0\right\rangle }_{L}=(\left\vert +++\right\rangle +\left\vert ---\right\rangle )/\sqrt{2}\) and \({\left\vert 1\right\rangle }_{L}=(\left\vert +++\right\rangle -\left\vert ---\right\rangle )/\sqrt{2}\). Then to detect errors, we can perform projective measurements of the stabilizers X1X2 and X2X3 to determine the parity of the bits. Based on the measurement outcomes, we can apply Z gates to correct the errors accordingly. The logical encoding and the phase-flip error correction procedure are depicted in Fig. 3.

Fig. 3: Phase-flip error correction circuit.
figure 3

Full circuit for correcting phase flip errors on a general state \(\left\vert \psi \right\rangle =a\left\vert 0\right\rangle +b\left\vert 1\right\rangle\).

The constructions given in20 allow us to ensure the fault tolerance of the encoding, error detection, and recovery operations in either code. The underlying technique involves introducing an extra flag qubit prepared in the \(\left\vert +\right\rangle\) state and performing CNOT operations from it on the syndrome ancilla qubit at key points in the circuit (see Fig. 3(b) in20). This flag qubit is then measured in the X basis and a result of \(\left\vert -\right\rangle\) indicates an error of weight two or more on the data qubits. Additional flag qubits can be added between each gate in the stabilizer measurement to ensure a localization of errors. Similar constructions apply in creating fault-tolerant versions of other important subroutines like logical state-preparation and stabilizer measurements (see Appendix A in20).

Integrating the repetition code with Gauss’ law

We are now in the position to discuss how the expression of Gauss’ law in Eq. (5) can remove the need to use an explicit bit flip code in fault-tolerant LGT simulations. To simplify the discussion we will henceforth consider the one-dimensional case (D = 1) with staggered fermionic sites, where only one fermionic flavor with charge es is present on any given site s. The Gauss’ law operator at site s between links l and l + 1 simplifies then to

$${\hat{G}}_{s}={\hat{E}}_{l+1}-{\hat{E}}_{l}-{e}_{s}\hat{n}(s),$$
(11)

and in the simpler pure gauge case with no matter to

$${\hat{G}}_{s}={\hat{E}}_{l+1}-{\hat{E}}_{l}.$$
(12)

We start by discussing the latter case and consider a general state of the two links in the electric basis

$$\left\vert {{{\Psi }}}_{l,l+1}\right\rangle =\mathop{\sum}\limits_{{\epsilon }_{l}}\mathop{\sum}\limits_{{\epsilon }_{l+1}}{{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l+1}\right\rangle .$$
(13)

Following the discussion in “Structure of U(1) and \({{\mathbb{Z}}}_{n}\) Abelian lattice gauge theories”, a physical state needs to be in the kernel of the Gauss’ law operator. Using Eq. (12) above we see that \({\hat{G}}_{s}\) acts on \(\left\vert {{{\Psi }}}_{l,l+1}\right\rangle\) as

$${\hat{G}}_{s}\left\vert {{{\Psi }}}_{l,l+1}\right\rangle =\mathop{\sum}\limits_{{\epsilon }_{l}}\mathop{\sum}\limits_{{\epsilon }_{l+1}}{{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}({\epsilon }_{l+1}-{\epsilon }_{l})\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l+1}\right\rangle ,$$
(14)

and is zero only if the coefficient matrix is diagonal

$${{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}({\epsilon }_{l+1}-{\epsilon }_{l})=0\ \iff \ {{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}={{{\Psi }}}_{{\epsilon }_{l}}{\delta }_{{\epsilon }_{l},{\epsilon }_{l+1}}.$$
(15)

This argument, which can be easily generalized to the case where the state of the links is mixed, shows that gauge invariant states are analogous to a bit-flip repetition code with only two copies: \({\left\vert 0\right\rangle }_{L}=\left\vert 0\right\rangle \otimes \left\vert 0\right\rangle\) and \({\left\vert 1\right\rangle }_{L}=\left\vert 1\right\rangle \otimes \left\vert 1\right\rangle\). The distance between these codewords is not sufficient to allow for error correction but is sufficient for error detection (see e.g.,30). This explains in an intuitive way why oracles like those presented in ref. 16 are capable of detecting bit-flip errors without requiring additional qubits for the encoding.

It is now easy to see how the use of Gauss’ law allows for a space reduction in the bit-flip encoding: the standard procedure described above will require three link registers to encode a logical link as

$$\begin{array}{lll}{\left\vert {{{\Phi }}}_{l}\right\rangle }_{L}&:=&\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Phi }}}_{{\epsilon }_{l}}\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}\right\rangle \\ &=&\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Phi }}}_{{\epsilon }_{l}}{\left\vert {\epsilon }_{l}\right\rangle }_{L}.\end{array}$$
(16)

The fact that physical states satisfy Eq. (14) means we need only two registers per link and can use one of the two registers for the l + 1 link across a site s when we measure stabilizers and perform error recovery. Since only three registers are involved in this procedure, we will consider a construction with two-qubit registers for even links and only one register for the odd links in order to minimize the memory cost. More explicitly, we will use the alternative encoding

$${\left\vert {{{\Phi }}}_{l}\right\rangle }_{GLE}:=\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Phi }}}_{{\epsilon }_{l}}\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}\right\rangle =\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Phi }}}_{{\epsilon }_{l}}{\left\vert {\epsilon }_{l}\right\rangle }_{GLE},$$
(17)

for the even links in the lattice and

$${\left\vert {{{\Phi }}}_{l}\right\rangle }_{GLO}:=\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Phi }}}_{{\epsilon }_{l}}\left\vert {\epsilon }_{l}\right\rangle =\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Phi }}}_{{\epsilon }_{l}}{\left\vert {\epsilon }_{l}\right\rangle }_{GLO},$$
(18)

equivalent to a bare encoding, for the odd links. For physical states that satisfy the Gauss’ law constraint in Eq. (15) we have then

$$\begin{array}{lll}{\left\vert {{{\Phi }}}_{l,l+1}\right\rangle }_{GL}&=&\mathop{\sum}\limits_{{\epsilon }_{l}}\mathop{\sum}\limits_{{\epsilon }_{l+1}}{{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}{\left\vert {\epsilon }_{l}\right\rangle }_{GLE}\otimes {\left\vert {\epsilon }_{l+1}\right\rangle }_{GLO}\\ &=&\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Psi }}}_{{\epsilon }_{l}}{\left\vert {\epsilon }_{l}\right\rangle }_{GLE}\otimes {\left\vert {\epsilon }_{l}\right\rangle }_{GLO}\\ &=&\mathop{\sum}\limits_{{\epsilon }_{l}}{{{\Psi }}}_{{\epsilon }_{l}}\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}\right\rangle ,\end{array}$$
(19)

and we can now use the stabilizer measurements and recovery operation on the three qubits as in the bit-flip repetition code. The second line is obtained by ensuring that the logical state \({\left\vert {{{\Phi }}}_{l,l+1}\right\rangle }_{GL}\) is in the kernel of the logical Gauss’ law operator derived from Eq. (12)

$$\begin{array}{lll}{\hat{G}}_{s}^{(GL)}&=&{\hat{E}}_{l+1}^{(GLO)}-{\hat{E}}_{l}^{(GLE)}\\ &=&{\hat{E}}_{l+1}-{\hat{E}}_{l}\otimes {\hat{E}}_{l}.\end{array}$$
(20)

The expressions above apply directly to sites s between l even and l + 1 odd, but it is straightforward to generalize them to the site s + 1 where the left link is odd and the right link is even as follows

$$\begin{array}{lll}{\left\vert {{{\Phi }}}_{l+1,l+2}\right\rangle }_{GL}&=&\mathop{\sum}\limits_{{\epsilon }_{l+1}}\mathop{\sum}\limits_{{\epsilon }_{l+2}}{{{\Psi }}}_{{\epsilon }_{l+1},{\epsilon }_{l+2}}{\left\vert {\epsilon }_{l+1}\right\rangle }_{GLO}\otimes {\left\vert {\epsilon }_{l+2}\right\rangle }_{GLE}\\ &=&\mathop{\sum}\limits_{{\epsilon }_{l+1}}{{{\Psi }}}_{{\epsilon }_{l+1}}{\left\vert {\epsilon }_{l+1}\right\rangle }_{GLO}\otimes {\left\vert {\epsilon }_{l+1}\right\rangle }_{GLE}\\ &=&\mathop{\sum}\limits_{{\epsilon }_{l+1}}{{{\Psi }}}_{{\epsilon }_{l+1}}\left\vert {\epsilon }_{l+1}\right\rangle \otimes \left\vert {\epsilon }_{l+1}\right\rangle \otimes \left\vert {\epsilon }_{l+1}\right\rangle .\end{array}$$
(21)

The gauge invariant logical state is again equivalent to the standard bit-flip encoding shown in Eq. (16). Since Gauss’ law only detects errors in the flux value, which in our representation corresponds to bit-flip errors, each register of qubits in the construction presented above needs to be encoded in a phase-flip code to ensure that all single errors are correctable. With this concatenation, the gauge-invariant logical states \({\left\vert {{{\Phi }}}_{l,l+1}\right\rangle }_{GL}\) and \({\left\vert {{{\Phi }}}_{l+1,l+2}\right\rangle }_{GL}\) become equivalent to a full 9-qubit encoding19. However, we encode two full links using the 9-qubit encoding as opposed to each link separately. This encoding therefore has better memory efficiency than error correcting codes that act on individual qubits, the best one requiring 5 qubits21,22. Note that it is still possible to find codes with even higher memory efficiency when multiple logical qubit are encoded. For instance, 3 logical qubits can be encoded into eight while correcting all single errors (see e.g.,31,32).

Adding fermions to the system modifies the relation between link states across a site so that they do not necessarily need to be the same. The full state around a site s is a generalization of Eq. (13) and should now be written as

$$\left\vert {{{\Psi }}}_{l,l+1}^{s}\right\rangle =\mathop{\sum}\limits_{{\epsilon }_{l}}\mathop{\sum}\limits_{{\epsilon }_{l+1}}\mathop{\sum}\limits_{n=0,1}{{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}^{n}\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l+1}\right\rangle \otimes {\left\vert n\right\rangle }_{s}.$$
(22)

The gauge-invariance constraint becomes therefore

$$\begin{array}{l}{{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}^{0}({\epsilon }_{l+1}-{\epsilon }_{l})=0,\\ {{{\Psi }}}_{{\epsilon }_{l},{\epsilon }_{l+1}}^{1}({\epsilon }_{l+1}-{\epsilon }_{l}-{e}_{s})=0.\end{array}$$
(23)

A state belonging to the physically meaningful portion of the Hilbert space is then

$$\left\vert {{{\Psi }}}_{l,l+1}^{s}\right\rangle =\mathop{\sum}\limits_{{\epsilon }_{l}}\mathop{\sum}\limits_{n=0,1}{{{\Psi }}}_{{\epsilon }_{l}}^{n}\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}+n{e}_{s}\right\rangle \otimes {\left\vert n\right\rangle }_{s},$$
(24)

where we recall that es = 1 for a fermionic site and es = − 1 for an anti-fermionic site. In order to obtain a useful encoded state for error correction, we can then apply a lowering operator \({\hat{U}}_{l+1}^{{\dagger} }\) (for es = 1) or a raising operator \({\hat{U}}_{l+1}\) (for es = − 1) to the link l + 1 controlled on the state of the site qubit. Calling this operation \({\hat{W}}_{s}\), for a site between an even and an odd link we have that

$$\begin{array}{lll}{\hat{W}}_{s}{\left\vert {{{\Psi }}}_{l,l+1}^{s}\right\rangle }_{GL}&=&\mathop{\sum}\limits_{{\epsilon }_{l}}\mathop{\sum}\limits_{n=0,1}{{{\Psi }}}_{{\epsilon }_{l}}^{n}{\left\vert {\epsilon }_{l}\right\rangle }_{GLE}\otimes {\left\vert {\epsilon }_{l}\right\rangle }_{GLO}\otimes {\left\vert n\right\rangle }_{s}\\ &=&\mathop{\sum}\limits_{{\epsilon }_{l}}\mathop{\sum}\limits_{n=0,1}{{{\Psi }}}_{{\epsilon }_{l}}^{n}\left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}\right\rangle \otimes \left\vert {\epsilon }_{l}\right\rangle \otimes {\left\vert n\right\rangle }_{s}\end{array}$$
(25)

and the error correction procedure can be carried out on this new state. After one site has been processed, we apply the inverse \({\hat{W}}_{s}^{{\dagger} }\) and move to the next site. In this approach, we effectively move from a gauge-invariant encoding that satisfies Eq. (23) to a logical encoding equivalent to the bit-flip code by using \({\hat{W}}_{s}\) and its inverse. This operation needs to be performed fault-tolerantly in order to ensure a controlled propagation of errors. In the next section, we will restrict the discussion to the simpler case where the link registers are formed by a single qubit (ie. the flux cutoff is set to one). In that case, we show that the construction can be done in a fault-tolerant way.

It is preferable to avoid directly implementing the \({\hat{W}}_{s}\) operation in practice as bit-flip errors can propagate from the site used as the control for the l + 1 link. This can be done by adopting a full bit-flip encoding for the site alone and using the measurement of its stabilizers to correct for the induced error in the link. A more efficient strategy however is to compute the parity between the between the l + 1 link and the adjacent site and store the result in a physical ancilla qubit, as shown schematically in Fig. 4a. The ancilla qubit can then be used as part of a logical encoding for the even-numbered links. We can catch errors of weight two or higher that occur from errors propagating past the logical CNOTs with the use of flag qubits (see ref. 20) and an example of this is shown in Fig. 4a. This construction can be readily extended to situations with large cutoffs if we employ a unary encoding for the flux state using m qubits per link, in which case we will require m ancilla qubits. Generalizing the approach to larger cutoff values with various encodings is an important issue that will need to be addressed in future work (see also “Discussion”). As we show in more detail in the next section, using ancilla qubits to temporarily store the parity of the two links allows for a fault-tolerant error correction of a gauge theory with dynamical fermions using the unencoded sites directly, providing a significant saving in qubits.

Fig. 4: Logical-to-physical operations.
figure 4

a Fault-tolerant logical-to-physical CNOT using flag qubits. b Equivalence of logical CNOT between logical qubits and two logical-to-physical CNOTs.

In summary, the number of link registers required for the Gauss’ law aided bit-flip error correction is 3N for a system with a total of 2N links. The total number of qubits required in a pure gauge simulation is therefore 9N + O(1) when restricting the unit electric cutoff case as done above and accounting for the additional 3 physical qubits required for the phase-flip encoding. With the addition of dynamical fermions on 2N sites, one can exploit the relationship given by Gauss’ law between the state of a site and its adjacent links to do error correction with a total of 15N + O(1) qubits, 9N for links and 6N for sites. These are impossible results if one instead attempts to perform error correction on individual qubits. The total space required would instead be 10N for the non-dynamical case and 20N for the dynamical one using the perfect 5-qubit encoding from ref. 21,22. As mentioned previously, better ratios are possible if one encodes multiple logical qubits at a time and we leave the extension to the more efficient encodings for future work31,32.

Pure gauge theory

We specialize in this and the next few sections to a \({{\mathbb{Z}}}_{2}\) or truncated U(1) gauge theory in 1+1 dimensions with a cutoff of Λ = 1 for the flux in each link. We work with a system with 2N sites and 2N links with PBCs. Site k, for an integer k ≥ 1, is denoted by \({S}_{k}^{1}\) and the links coming into and out of the site are written as \({L}_{k}^{1}\) and \({L}_{k+1}^{1}\) respectively.

Unless otherwise specified, every subsequent circuit is a concatenated one, with every qubit encoded within the phase flip error-correcting code as in the encoding portion of Fig. 3. Logical qubits arising in this manner will be denoted with the subscript L.

We applications of the previous analysis to a few gauge theories in order of increasing generality. Beginning with the pure gauge theory case with no matter present on the sites, Gauss’ law gives the equality between the incoming and outgoing flux on a site. This allows us to use \(\left\vert {L}_{k}^{1}\right\rangle\) and \(\left\vert {L}_{k+1}^{1}\right\rangle\) as part of a single logical qubit for a concatenated bit-flip error correction procedure, where an additional qubit is introduced only if the links are even-numbered.

This situation is easily generalized to a theory with static charges or non-dynamical fermions on the sites by applying a link-lowering operator on an odd-numbered link conditioned on the classical state of the adjacent site. We then perform the error correction procedure on the appropriate logical link qubit before restoring the odd link’s flux value with a raising operator.

The scenario with dynamical fermions is dealt with by computing the parity between an odd-numbered link and its adjacent site and storing the result in a physical ancilla qubit. This qubit is then used as part of a logical encoding for the even-numbered links. Bit-flip checks can be performed on two sets of adjacent links and sites and the information from them can be used to correct errors on all the relevant qubits, provided there is a single bit-flip error per two such checks.

Note that we cannot perform this analysis entirely within the stabilizer formalism since our controlled operations are not logical ones at the level of the bit-flip encoding. While certain aspects of our treatment, therefore, rely on standard constructions within the stabilizer formalism, others involving Gauss’ law require us to move between physical and logical states.

We adopt the notation \({\left\vert {L}_{k}^{n}\right\rangle }_{L}\) and \({\left\vert {S}_{k}^{n}\right\rangle }_{L}\) to denote link and site logical qubits respectively in the phase flip code, and \({O}_{k}^{n}\) for operators acting on the k-th logical link or site qubit. The case where n = 1 in the superscript denotes the original logical qubit and logical qubit operator, while values of n greater than 1 denote the auxiliary link or site qubits introduced for the error correction procedures. If a given logical site or link is the only one of its kind, we will drop the superscript.

In each of the subsequent circuits, we introduce no additional qubits for the odd numbered links and an auxiliary qubit \({\left\vert {L}_{2k}^{2}\right\rangle }_{L}\) for each even numbered link \({\left\vert {L}_{2k}^{1}\right\rangle }_{L}\) that is arranged to have the same state as \({\left\vert {L}_{2k}^{1}\right\rangle }_{L}\). The constraint that the fluxes satisfy Gauss’ law at site \({\left\vert {S}_{2k}^{1}\right\rangle }_{L}\) with associated link qubits \(\{{\left\vert {L}_{2k}^{1}\right\rangle }_{L},{\left\vert {L}_{2k}^{2}\right\rangle }_{L},{\left\vert {L}_{2k+1}\right\rangle }_{L}\}\) will then ensure that \({\left\vert {L}_{2k}^{1}\right\rangle }_{L}={\left\vert {L}_{2k}^{2}\right\rangle }_{L}={\left\vert {L}_{2k+1}^{1}\right\rangle }_{L}\), or more precisely that the wave-function factorizes as in Eq. (19) above.

As noted in the previous section, the grouping \(\{{\left\vert {L}_{2k}^{1}\right\rangle }_{L},{\left\vert {L}_{2k}^{2}\right\rangle }_{L},{\left\vert {L}_{2k+1}\right\rangle }_{L}\}\) acts as a 3-qubit logical encoding for the link logical qubit \({\left\vert {L}_{2k}^{1}\right\rangle }_{L}\) that can be used in the bit flip error correction code outlined in Fig. 5a. The circuit is however sensitive to single-qubit phase flip errors that propagate to weight two or three phase flip errors. This is due to the use of logical to physical CNOT gates, which enable the propagation of physical Z errors from the target of these CNOTs to logical Z errors on the links. We, therefore, employ the fault-tolerant logical-to-physical CNOT depicted in Fig. 4a. This CNOT is implicitly used in all the subsequent circuits where logical-to-physical CNOT operations occur.

Fig. 5: Error correction in pure and non-dynamical LGT.
figure 5

a Bit-flip syndrome measurement and correction operations for links in pure gauge theory. The subscript L denotes the phase-flip encoding of these qubits shown in the encoding portion of Fig. 3. Each CNOT operation here consists of three individual CNOTs from the qubits in the underlying phase-flip encoding. Here X is the operation XXX which acts as a logical X. b Syndrome measurement and correction operations for LGT system with non-dynamical fermions. The circuit holds for arbitrary sites Sk and not just even-numbered ones. Note that the circuit can be simplified by using commutation relations to move the initial classically controlled X to the end of the circuit, thereby replacing the classical controls with a classically controlled flip of the last measurement outcome.

There is an alternative way to accomplish this error correction procedure without introducing an additional logical qubit for the even-numbered links. This method simply requires doing overlapping Gauss’s law checks on the qubits \(\{{\left\vert {L}_{2k}\right\rangle }_{L},{\left\vert {L}_{2k+1}\right\rangle }_{L},{\left\vert {L}_{2k+2}\right\rangle }_{L}\}\) and the qubits in Fig. 5a can then be replaced with these respectively. The number of qubits required to fully error correct a 1+1 lattice system with 2N links would then be 6N instead of 9N. However, we can then only tolerate at most one error occurring over a larger portion of the lattice, namely a group of three consecutive links, compared to the previous scenario where we could tolerate at most one error over the more localized grouping \(\{{\left\vert {L}_{2k}^{1}\right\rangle }_{L},{\left\vert {L}_{2k}^{2}\right\rangle }_{L},{\left\vert {L}_{2k+1}\right\rangle }_{L}\}\). Thus there is a trade-off between the number of qubits needed for our compressed encoding and the spatial region over which the Gauss’s law checks need to be performed to localize a bit-flip error. This pattern will recur in the subsequent cases we consider and becomes less favorable in larger dimensions.

Error correction with non-dynamical fermions

It is straightforward to generalize the results of the preceding subsection to the case where we have non-dynamical fermions on the sites. Since we know in this case whether or not a certain physical site \({S}_{2k}^{1}\) (this is not a logical site qubit but a classical binary variable) has a fermion, it is not necessary to introduce an ancilla qubit and use the equivalence in Fig. 4b. The controlled operation \({\hat{W}}_{s}\) introduced above (see Eq. (25)) is instead replaced by its classically controlled counterpart. As such, we apply a classically conditioned link-lowering operator to \({\left\vert {L}_{2k+1}\right\rangle }_{L}\) to lower its flux value and have it match that of \({\left\vert {L}_{2k}^{1}\right\rangle }_{L}\). We then apply the preceding bit-flip error correction code and restore the flux value of \({\left\vert {L}_{2k+1}^{1}\right\rangle }_{L}\) back to its original value with a classically conditioned link-raising operation.

Given our assumptions on the flux cutoff, we have the circuit in Fig. 5b for the non-dynamical fermionic case. This construction also holds for an arbitrary site Sk and not just even-numbered ones. Note that the circuit can be expressed in a simpler form by exploiting commutation relations to move the initial classically controlled X to the end of the circuit. This effectively replaces this operation with a classically controlled flip of the last measurement outcome.

As in the pure gauge theory case, we can dispense with the extra logical qubit \({\left\vert {L}_{2k}^{2}\right\rangle }_{L}\) and extend the Gauss’s law check to the group of qubits \(\{{\left\vert {L}_{2k}^{1}\right\rangle }_{L},{\left\vert {L}_{2k}^{2}\right\rangle }_{L},{\left\vert {L}_{2k+1}\right\rangle }_{L}\}\), replacing the link qubits in Fig. 5b accordingly. The number of qubits needed for this approach is again 6N like the pure gauge case instead of 9N with the above encoding, and the trade-offs are identical as well.

Error correction with dynamical fermions

A naïve approach to extend the preceding constructions to the case with dynamical staggered fermions on the sites is to apply a CNOT gate to \({\left\vert {L}_{2k+1}\right\rangle }_{L}\) conditioned on the state of \({\left\vert {S}_{2k}\right\rangle }_{L}\). We could then introduce additional qubits \({\left\vert {S}_{2k}^{2}\right\rangle }_{L}\) and \({\left\vert {S}_{2k}^{3}\right\rangle }_{L}\) to create a bit-flip encoding of \({\left\vert {S}_{2k}\right\rangle }_{L}\) and thereby protect it from bit-flip errors. Errors propagating to \({\left\vert {L}_{2k+1}\right\rangle }_{L}\), \({\left\vert {L}_{2k}^{1}\right\rangle }_{L}\), and \({\left\vert {L}_{2k}^{2}\right\rangle }_{L}\) can be corrected with a separate bit-flip code involving these qubits, with additional recovery operations included to account for the propagation of X errors past the control of the CNOT.

This construction only involves Clifford operations and can easily be made fault tolerant. It however requires 18N + 6N + 3N = 27N qubits for an 2N site and 2N link system excluding ancillas, which is suboptimal compared to the 20N qubits obtained from using the [5, 1, 3] encoding for each site and link.

We instead develop a procedure that further exploits Gauss’ law to reduce the cost to 15N qubits. This is achieved by noticing that, as discussed in “Integrating the repetition code with Gauss’ law”, given the state on a site S2k+1 and its adjacent links L2k+1 and L2k+2, a bit-flip error on any of these qubits will cause a violation of Gauss’ law. The ambiguity in where the error occurred can be resolved by overlapping Gauss’ law checks on the preceding and subsequent site and their adjacent links. In fact, we will show only two such checks are needed to resolve the ambiguity.

Figure 6 depicts to overlapping Gauss’ law checks \({{{{\mathcal{G}}}}}_{2k}\) and \({{{{\mathcal{G}}}}}_{2k+1}\) on sites S2k and S2k+1 respectively. Consider \({{{{\mathcal{G}}}}}_{2k+1}\) in particular. We can compute the parity between \({\left\vert {S}_{2k+1}\right\rangle }_{L}\) and \({\left\vert {L}_{2k+1}\right\rangle }_{L}\) as per Fig. 4b and store this result into a physical ancilla qubit \(\left\vert 0\right\rangle\), which serves as a proxy for \({\left\vert {L}_{2k+1}\right\rangle }_{L}\) but with its flux value reset. We can then treat \(\left\vert 0\right\rangle\), \({\left\vert {L}_{2k+2}^{1}\right\rangle }_{L}\), \({\left\vert {L}_{2k+2}^{2}\right\rangle }_{L}\) as a logical qubit for a bit-flip error correction code and uncompute the value in \(\left\vert 0\right\rangle\) afterwards. These steps constitute \({{{{\mathcal{G}}}}}_{2k+1}\) for the odd sites and their neighboring links and are repeated analogously across the lattice.

Fig. 6: Circuit for error correction of 1D Abelian LGT with dynamical fermions.
figure 6

Circuit for using information from Gauss’ law checks \({{{{\mathcal{G}}}}}_{2k}\) and \({{{{\mathcal{G}}}}}_{2k+1}\) on S2k, S2k+1, and their adjacent links to correct bit-flip errors on them. Bit-flip errors on even-numbered links can be corrected using the information obtained from one such check. Bit-flip errors on sites and odd-numbered links require information from two such checks to be corrected. See Fig. 7b for the corresponding syndrome outcomes.

To see how the information obtained from the stabilizer measurements employing the last two ancilla qubits in Fig. 6 helps us correct errors on the data qubits, consider \({{{{\mathcal{G}}}}}_{2k+1}\) first. The syndrome measurement outcomes 10 and 01 uniquely identify bit-flip errors occurring on the even links \({\left\vert {L}_{2k+2}^{1}\right\rangle }_{L}\) and \({\left\vert {L}_{2k+2}^{2}\right\rangle }_{L}\) respectively. The remaining non-trivial outcome 11 indicates a bit-flip error on either \({\left\vert {L}_{2k+1}\right\rangle }_{L}\) or \({\left\vert {S}_{2k+1}\right\rangle }_{L}\) with no way to resolve the ambiguity.

If the error occurred on \({\left\vert {S}_{2k+1}\right\rangle }_{L}\) however, we would obtain the syndrome 00 from the check \({{{{\mathcal{G}}}}}_{2k}\) as Gauss’ law is satisfied between S2k, L2k, and L2k+1. If the error occurred on \({\left\vert {L}_{2k+1}\right\rangle }_{L}\), we would then obtain the syndrome 11 from \({{{{\mathcal{G}}}}}_{2k}\). As these two cases yield distinct syndromes, we can resolve the aforementioned ambiguity as shown in Fig. 7b. Note that this analysis will only hold if a bit-flip error occurs once during the checks \({{{{\mathcal{G}}}}}_{2k}\) and \({{{{\mathcal{G}}}}}_{2k+1}\).

Fig. 7: Error localization for 1+1 dimensional LGTs with dynamical fermions.
figure 7

a Schematic illustration of how to correct any single-qubit error on S2k+1 and its adjacent logical link qubits by 3 overlapping Gauss’s law checks. This requires that only one single-qubit error occurs over the links and sites involved in the 3 Gauss’s law checks. b How to resolve the ambiguity in the location of a bit-flip error associated to the syndrome 11 for \({{{{\mathcal{G}}}}}_{2k+1}\) using the syndrome results of \({{{{\mathcal{G}}}}}_{2k}\). See Fig. 6. c How to localize the error occurring on \({\left\vert {S}_{2k+1}\right\rangle }_{L}\) or its adjacent logical link qubits \({\left\vert {L}_{2k+1}\right\rangle }_{L},{\left\vert {L}_{2k+2}\right\rangle }_{L}\) by overlapping Gauss’s law checks. Each error is associated with a unique syndrome, enabling error correction.

To assess the fault-tolerance of this construction, we first consider the possibility that single-qubit bit flip errors occurring at the physical level can propagate to undetectable errors at level of the phase-flip code. Consider WLOG an error of the form XII occurring at the level of the underlying phase-flip code. On the logical codespace defined by the basis \({\left\vert 0\right\rangle }_{L}=(\left\vert +++\right\rangle +\left\vert ---\right\rangle )/\sqrt{2}\) and \({\left\vert 1\right\rangle }_{L}=(\left\vert +++\right\rangle -\left\vert ---\right\rangle )/\sqrt{2}\), this error maps \({\left\vert 0\right\rangle }_{L}\mapsto {\left\vert 1\right\rangle }_{L}\). In other words, a physical bit-flip error propagates to a logical bit-flip error which can be detected by our bit-flip correction code. It is easily seen that two bit flip errors leave our code space invariant. The circuit’s sensitivity to single qubit phase flip errors propagating to weight two or three phase flip errors from the logical-to-physical CNOT gates is again resolved with the fault-tolerant CNOT construction shown in Fig. 4a.

Logical bit-flip errors occurring on the logical qubits only propagate to the ancilla qubits and not to the data qubits. The possibility of more than one such error occurring on the data qubits is suppressed by higher powers of p, where p is the probability of an error occurring.

We can again consider the situation where we dispense with the extra qubits for the even-numbered links and correct bit-flip errors solely based on information obtained from Gauss’s law. This modified situation is depicted in Fig. 7a and shows how three overlapping Gauss’s law checks can be used to detect an error on \(\left\vert {S}_{2k+1}\right\rangle\) or its adjacent links. Note that this requires only one single-qubit error to occur on the links and qubits involved in the checks, and so we can lessen the memory overhead required for error-correction in this setting at the expense of a worse error tolerance over a larger region of the lattice. This modified approach then requires 3(2N) + 3(2N) = 12N qubits for a 1+1 dimensional lattice system with 2N staggered fermions and 2N links. The corresponding circuit is similar to Fig. 6, with the exception that the extra even-numbered link qubits and intermediate classical recovery operations in each \({{{{\mathcal{G}}}}}_{j}\) are removed and the logical qubits \({\left\vert {S}_{2k+2}\right\rangle }_{L},{\left\vert {S}_{2k+3}\right\rangle }_{L}\) are present. We simply perform the parity checks \({{{{\mathcal{G}}}}}_{2k},{{{{\mathcal{G}}}}}_{2k+1},{{{{\mathcal{G}}}}}_{2k+2}\), store the results into 3 ancilla qubits, and use the outcomes to correct the error that happened on \({\left\vert {S}_{2k+1}\right\rangle }_{L},{\left\vert {L}_{2k+1}\right\rangle }_{L},{\left\vert {L}_{2k+2}\right\rangle }_{L}\). Figure 7c depicts the possible outcomes from these checks and shows that we can localize the error.

Extension to two dimensions

The scheme described in the previous sections can be also extended to higher spatial dimensions. In order to give a concrete example we describe here how one could implement a compressed error correcting code for a simple 2+1 dimensional lattice gauge theory. We consider in detail the case of \({{\mathbb{Z}}}_{2}\) but the construction can be also applied to U(1). We start from a different form of Gauss’ law which allows for a more direct connection to the stabilizer formalism. The Gauss’ operator at each site s = (xs, ys) and it’s neighboring links is defined as

$$\hat{G}({{{\bf{s}}}})={Z}_{{{{\bf{s}}}}}^{x}{Z}_{{{{\bf{s}}}}}^{y}{Z}_{{{{\bf{s}}}}+x}^{x}{Z}_{{{{\bf{s}}}}+y}^{y}{(-1)}^{\hat{q}({{{\bf{s}}}})},$$
(26)

and physical states satisfy the condition

$$\hat{G}({{{\bf{s}}}}){\left\vert {{\Psi }}\right\rangle }_{phys}={\left\vert {{\Psi }}\right\rangle }_{phys}.$$
(27)

In the expression Eq. (26) we use the indexing convention for the links as displayed in Fig. 8a and the charge operator using staggered fermions is given by

$$\hat{q}({{{\bf{s}}}})={\psi }^{{\dagger} }({{{\bf{s}}}})\psi ({{{\bf{s}}}})-\frac{1}{2}\left(1-{(-1)}^{{x}_{s}+{y}_{s}}\right),$$
(28)

with \({\hat{\psi }}^{{\dagger} }({{{\bf{s}}}})\) and \(\hat{\psi }({{{\bf{s}}}})\) the fermionic creation and annihilation operators at site s. With this definition, at even site the states \(\{\left\vert 0\right\rangle ,\left\vert 1\right\rangle \}\) indicate the absence/presence of a fermion of charge 1 while for odd sites the role is reversed and \(\{\left\vert 0\right\rangle ,\left\vert 1\right\rangle \}\) represent the presence/absence of an anti-fermion of opposite charge. In the following we will denote fermionic sites with a red color (as in Fig. 8a) and anti-fermion sites with a green color. The convention for the indexing of links is unaffected. The presence of static charges at different sites is easily included by adding their contributions in the charge at the site. In order to keep the current exposition simple we neglected this possibility.

Fig. 8: Error correction with Gauss’s law in 2D.
figure 8

a Convention for the indexing of the link variables around a fermionic site s = (xs, ys). b The adopted bi-partition of the 2D lattice into plaquettes used for the two rounds of the error correction procedure: the first round acts on bold links and sites (e.g., the region delimited by the dashed line) the second round acts on the light-colored links and sites and the 8 external links attached to them (e.g., the regions delimited by dotted lines). The blue-shaded region is the patch of the 2D lattice where one-bit flip error can occur and be corrected. c The structure of the relevant region for one round of the error correction procedure.

Using the Pauli Z operator at the site we can express the Gauss law operator more explicitly as

$$\hat{G}({{{\bf{s}}}})={(-1)}^{{x}_{s}+{y}_{s}}{Z}_{{{{\bf{s}}}}}^{x}{Z}_{{{{\bf{s}}}}}^{y}{Z}_{{{{\bf{s}}}}+x}^{x}{Z}_{{{{\bf{s}}}}+y}^{y}{Z}_{{{{\bf{s}}}}},$$
(29)

and we see then that physical states are eigenvectors of

$${Z}_{{{{\bf{s}}}}}^{x}{Z}_{{{{\bf{s}}}}}^{y}{Z}_{{{{\bf{s}}}}+x}^{x}{Z}_{{{{\bf{s}}}}+y}^{y}{Z}_{{{{\bf{s}}}}}$$
(30)

with positive eigenvalue on even sites and negative eigenvalue on odd sites. As alluded above, this form is reminiscent of the stabilizer formalism.

The error correcting procedure proceeds as follow: (1) we first partition the full lattice into square plaquettes and their neighboring links and proceed in two rounds by first considering the plaquettes indicated with bold colors in Fig. 8b (see e.g., the one indicated by the dashed line) and in the second round we consider the second half of the plaquettes denoted with light colors (for the highlighted plaquette, these correspond to those indicated by dotted lines); (2) for each individual plaquette we perform a sequence of parity checks. Before describing these, note that we require an additional qubit for every pair of links denoted as a blue curved line in the diagrams of Fig. 8c. These qubits are used to store the parity of the two links they touch, for instance

$${Z}_{(1,0)}^{x}{Z}_{(1,0)}^{y}\left\vert {{\Phi }}\right\rangle ={Z}_{{A}_{10}}\left\vert {{\Phi }}\right\rangle ,$$
(31)

where with \(\left\vert {{\Phi }}\right\rangle\) we denote the full state. This can be achieved by simply applying two CNOT gates with control on the links and target on the ancillary qubit initially set in \(\left\vert 0\right\rangle\). Then, whenever we modify the state of a link, we correspondingly update the state of the ancilla by applying another CNOT. These are CNOT operations between phase-flip encoded qubits and can be done transversally. At this point three separate parity checks are performed on each site participating in the plaquette and its four connected links. Starting from the site (0, 0) on the bottom left, we have the stabilizers

$$\begin{array}{lll}{P}_{(0,0)}^{a}&=&{Z}_{(0,0)}^{y}{Z}_{(0,1)}^{x}{Z}_{{A}_{00}}\\ {P}_{(0,0)}^{b}&=&{Z}_{(0,0)}^{y}{Z}_{(0,1)}^{x}{Z}_{(1,0)}^{y}{Z}_{(0,0)}^{x}{Z}_{(0,0)}\\ {P}_{(0,0)}^{c}&=&{Z}_{{A}_{00}}{Z}_{(1,0)}^{y}{Z}_{(0,0)}^{x}{Z}_{(0,0)},\end{array}$$
(32)

where Z(0, 0) is the operator acting on the qubit at the site. The parity check table for one site is reported in Fig. 9b, together with the possible error location. We can see that only 4 outcomes correspond to either one error or no errors. In the following discussion on the complete plaquette we restrict our attention to these situations only. Note however that errors on the ancillas As can be uniquely determined by only stabilizer measurements on sites and we could therefore detect and fix an arbitrary number of them.

Fig. 9: Syndrome outcomes for error correction with Gauss’s law in 2D.
figure 9

a Syndrome measurements outcomes and corresponding error location for the 12 stabilizers used on one complete plaquette. The labeling conventions follow Fig. 8c. We have excluded outcomes corresponding to more than one error. b Syndrome measurement outcomes and corresponding error location(s) for the parity check around a single site. Two or more errors are denoted generically as 2+.

We will use the same convention for all the other sites and take \({P}_{{{{\bf{s}}}}}^{a}\) to be the weight 3 stabilizer between the ancilla As and the two links connected to it, \({P}_{{{{\bf{s}}}}}^{b}\) the weight 5 stabilizer from the Gauss’ law operator Eq. (30), and \({P}_{{{{\bf{s}}}}}^{c}\) the weight 4 stabilizer obtained applying Gauss’ law to the ancilla As, the two links not connected to it, and the site. Accounting for the difference between the correct eigenspace of the Gauss’law stabilizer for even (fermionic) and odd (anti-fermionic) sites, the parity check table for a complete plaquette is reported in Fig. 9a. Note that the last four syndrome outcomes do not allow to uniquely localize the error as it could have happened on either the site or the external link opposite to the location of the ancilla As. Similarly to the construction described above for the one dimensional case, this ambiguity can be completely resolved by measuring one stabilizer on the neighboring plaquettes. In particular, under the assumption that only one error can occur in the shaded area in Fig. 8b during the two rounds of check, it is enough to measure the Pa stabilizers on the four highligthed sites. For completeness, we report the full syndrome measurement table required to distinguish these cases in Fig. 10.

Fig. 10: Error localization for 2D Abelian LGT.
figure 10

Full parity check outcomes are required to uniquely localize the errors on sites or external links opposite to the location of the As ancillas obtained using four additional Pa stabilizer measurement on neighboring sites.

The extended 2D scheme presented here uses only standard stabilizer measurements over phase-flip encoded qubits and can thus be implemented in a fault-tolerant way using similar techniques to those discussed in the 1D case. The main non-standard component of the scheme is the presence of the ancillae As which do not store the state of another qubit but the parity of a pair. The initial logical state can be initialized in a straightforward way by starting the system in a physical product state and making sure that any change performed to the state of the links connected to a given ancilla are also applied to the latter. For example, when implementing a hopping term which changes the flux on one of the links, the same change has to be enacted on the ancilla touching that link before continuing. In the \({{\mathbb{Z}}}_{2}\) case these extended operations can be achieved with just Clifford gates as they correspond simply to doubling the number of CNOT required.

The total qubit count for a square system with 4NxNy sites and 8NxNy links using a standard [5, 1, 3] code, and neglecting ancillae required for the stabilizer measurements, would be 60NxNy while the scheme proposed in this work requires only 48NxNy qubits. Similarly to the 1D case discussed in previous sections, the proposed mapping has the additional benefit of allowing simpler implementations of transversal operations. The savings afforded by this scheme can be improved in a similar way as what we did for the one-dimensional case: if one can tolerate a single fault in a larger region than the one depicted in Fig. 8a, then some of the ancilla registers As could be removed. For instance, if one extends the region where we can tolerate one error to enclose the four plaquettes neighboring a specific plaquette, a fault-tolerant scheme can be devised using only half of the As registers.

The present discussion of the 2D case can serve as a guideline to design similar error correction codes for higher dimensional geometries by adding additional ancilla registers to store the parity of subsets of links. Finally, extensions of the present scheme to \({{\mathbb{Z}}}_{N}\) or to U(1) with larger flux cutoffs could be constructed in principle using the same unary encoding map proposed for the one-dimensional case.

Discussion

Error correction involves extending the original Hilbert space of the system to a larger one and endowing the larger Hilbert space with local symmetries that define the codespace. Stabilizers of the codespace are in effect Gauss’ law operators of that symmetry. We have outlined a simple fault-tolerant algorithm which exploits local symmetries to reduce the space requirements for performing error correction on \({{\mathbb{Z}}}_{2}\) or U(1) LGT systems with a flux cutoff of 1. The logical qubits were concatenated within a phase flip code to attain fault tolerance since phase flip errors commute with the Gauss’ law of these theories.

As we have primarily investigated 1+1 dimensional systems with a flux cutoff of 1, we outline the difficulties one encounters when attempting to generalize these procedures to arbitrary dimensions and flux cutoffs.

We first note that for further levels of concatenation, our techniques incorporating Gauss’s law can only be applied at the highest logical level where the bit-flip encoding is implemented instead of within every other level of the concatenation. Our approaches can conceivably be used to suppress simulation errors resulting from the approximation of the true time-evolution via methods such as Trotterization, but the impact of our approach on these errors is left for future work as not all them will lead to violations of Gauss’s law.

For arbitrary flux cutoffs and with non-dynamical matter fields on the sites, the classical CNOT gates in Fig. 5b must be replaced with a classically controlled version of the \({\hat{W}}_{s}\) operation described in “Integrating the repetition code with Gauss’ law”. These are controlled on the state of an appropriate site qubit and can be implemented with adder circuits such as those described in refs. 16,33. A fault-tolerant adder will however require non-Clifford operations for a binary integer encoding. In principle, these can be applied using standard techniques like state injection34 even with our logical encoding. A more scalable solution however is to instead use a unary integer encoding, for which a fault-tolerant incrementer can be implemented using only Clifford gates. The more efficient construction relying on ancilla qubits to compute the XOR between a site and a link variable shown in Fig. 4b can also be implemented in a straightforward way when using unary encoding. It has been shown recently that in the context of dynamical simulations, the cutoff only grows as \({{{\rm{polylog}}}}(1/\varepsilon )\) in many physical situations35 for a fixed error ε. Thus the scaling in the number of qubits needed for integrating our error correction procedures with quantum simulation of such systems in a unary encoding is more optimal than the naive expectation of linear in the cutoff. However, existing unary encodings require non-stabilizer codes, so constructing generalized unary encodings which are stabilizer codes and exploring how the constructions given in Fig. 6 generalize to this setting is currently under investigation.

As discussed in “Integrating the repetition code with Gauss’ law”, the construction proposed here for the 1D case using an alternating encoding with two qubits per even link and one qubit per odd link requires 9N qubits (excluding ancillas) for the theory with non-dynamical fermions and for pure gauge theory. This improvement in space complexity can also be extended to accommodate dynamical fermions by using Gauss’ law to fix errors on the sites and requires 15N qubits, excluding ancillas. The 2D scheme presented in “Extension to two dimensions” allows for an even more compact encoding where only 48NxNy qubits are required in the dynamical case and 36NxNy for the pure gauge case for a lattice with 8NxNy links and 4NxNy sites. Such costs cannot be attained from error-correcting individual qubits only. Moreover, while we considered only local Gauss’s law checks, examining the links coming in and out of larger spatial regions can be used identify errors of Pauli weight more than 2. It would be interesting to investigate how the present constructions can be generalized to increase the distance of the effective bit-flip code that LGTs provide via Gauss’s law. We also note that when multiple logical qubits are encoded together, an even lower physical-to-logical qubit ratio is achievable31,32. The question of whether more efficient encodings could be found by following a more holistic approach as opposed to those using only Gauss’ law on local degrees of freedom like sites, links, and plaquettes is left for future work.

Most importantly, we do not claim to encode the full continuous gauge group, as this would violate the fact that finite dimensional quantum systems which correct erasure have no continuous symmetries but only a discrete subgroup thereof36. As such, we only encode the U(1) symmetry group with a finite cutoff approximation. The construction of error-correcting codes analogous to the ones presented here for other structure groups will therefore need to be tailored to their admissible discrete subgroups.

We make the final observation that the loop string hadron formalism allows the diagonalization of Gauss’ law for non-abelian gauge theories, converting them into analogs of those in abelian gauge theories17,37. It is expected that this will be an important step in extending these algorithms to more complex theories where additional commuting constraints are needed.