This site uses cookies. By continuing to use this site you agree to our use of cookies. To find out more, see our Privacy and Cookies policy.
Paper The following article is Open access

Local tensor-network codes

, and

Published 12 April 2022 © 2022 The Author(s). Published by IOP Publishing Ltd on behalf of the Institute of Physics and Deutsche Physikalische Gesellschaft
, , Citation Terry Farrelly et al 2022 New J. Phys. 24 043015 DOI 10.1088/1367-2630/ac5e87

Download Article PDF
DownloadArticle ePub

You need an eReader or compatible software to experience the benefits of the ePub3 file format.

1367-2630/24/4/043015

Abstract

Tensor-network codes enable the construction of large stabilizer codes out of tensors describing smaller stabilizer codes. An application of tensor-network codes was an efficient and exact decoder for holographic codes. Here, we show how to write some topological codes, including the surface code and colour code, as simple tensor-network codes. We also show how to calculate distances of stabilizer codes by contracting a tensor network. The algorithm actually gives more information, including a histogram of all logical coset weights. We prove that this method is efficient in the case of stabilizer codes encoded via local log-depth circuits in one dimension and holographic codes. Using our tensor-network distance calculator, we find a modification of the rotated surface code that has the same distance but fewer minimum-weight logical operators by 'doping' the tensor network, i.e., we break the homogeneity of the tensor network by locally replacing tensors. For this example, this corresponds to an improvement in successful error correction of almost 2% against depolarizing noise (in the perfect-measurement setting), but comes at the cost of introducing three higher-weight stabilizers. Our general construction lets us pick a network geometry (e.g., a Euclidean lattice in the case of the surface code), and, using only a small set of seed codes (constituent tensors), build extensive codes with the potential for optimisation.

Export citation and abstract BibTeX RIS

Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.

1. Introduction

Tensor networks [1] have been useful in many areas in physics. In particular, they have found application in quantum error correction, primarily for decoding [29]. In [2], Ferris and Poulin created a decoder by representing the encoding circuit of the code as a tensor network for circuits based on the MERA tensor network. Using a different approach, the surface code was decoded by contracting a two-dimensional tensor network in [3]. This method was applied to several different noise models [7, 10, 11] and also expanded to general codes with local stabilizers in two dimensions [9]. Non unitary and correlated noise were decoded for the surface code using a PEPO representation of the state [5, 6]. Tensor networks have also been instrumental for constructing holographic error correcting codes [1223].

More recently, 'tensor-network codes' [8, 24] were introduced, which use tensors to describe stabilizer codes. This allows one to easily construct new larger codes by connecting many tensors (i.e., by contracting tensor indices) to form a new code. Trivial examples are concatenated and convolutional codes, but more interesting examples include holographic codes [8]. In principle, there is no restriction on the geometry of the tensor network, though some geometries lend themselves to efficient tensor contraction, which naturally produces an efficient decoder [8].

In this work, we look at tensor-network codes. Our first main result is a method that uses tensor networks to calculate distances for stabilizer codes. The method is actually a bit more general, allowing the calculation of the distribution of the weights of logical operators and stabilizers. We show that this method is efficient for stabilizer codes encoded via local log-depth circuits and for holographic codes.

We then show that codes on regular lattices, like the surface code, are examples that represent a homogeneous application of local tensor networks, in which the same seed code is represented uniformly across the regular lattice. (We also show how to represent the colour code by a tensor-network code.) By analogy with doped crystal lattices, we then show how we can 'dope' these otherwise homogeneous codes with a few 'impurity' codes to produce new codes with potentially desirable properties. This approach opens a new avenue to optimising codes to suit specific needs. We examine these doped tensor-network codes using the tensor-network distance calculator, finding a code with the same distance as the surface code but with fewer minimal-weight logical operators. This doped code has an improved success probability of correcting depolarizing noise of up to 1.6% for code sizes 5 × 5 and 7 × 7.

2. Stabilizer codes

In this paper, we focus on stabilizer codes [2528], in which stabilizers and logical operators are elements of ${\mathcal{G}}_{n}$, which is the n-qubit Pauli group. The group ${\mathcal{G}}_{n}$ comprises all operators of the form $z{\sigma }^{{i}_{1}}\otimes \cdots \otimes {\sigma }^{{i}_{n}}$, with z ∈ {±1, ±i}. Here, we are denoting the identity and three Pauli operators via ${\sigma }^{0}=\mathbb{1}$, σ1 = X, σ2 = Y and σ3 = Z.

The codespace, which is the subspace of the Hilbert space used to encode logical information, is fully determined by the stabilizers, an abelian group of Pauli operators, i.e., $\mathcal{S}\subset {\mathcal{G}}_{n}$. The codespace is determined by the fact that every state |ψ⟩ in the codespace satisfies S|ψ⟩ = |ψ⟩ for all stabilizers $S\in \mathcal{S}$. If we denote the number of independent generators of $\mathcal{S}$ by r, then the dimension of the codespace is 2nr , which corresponds to k = nr encoded logical qubits [27]. We denote generators by Si .

The logical operators of the code generate a group $\mathcal{L}\subset {\mathcal{G}}_{n}$, which is non-abelian. One set of generators for the group is the k Z-type and k X-type operators. (By Z-type and X-type, we mean that these operators are canonically conjugate to each other, not that they only consist of σ1 or σ3 Pauli operators.) We denote these by Zα and Xα respectively, with α ∈ {1, ..., k}. These operators commute with all stabilizers, while anticommuting pairwise, i.e., ${X}_{\alpha }{Z}_{\beta }={(-1)}^{{\delta }_{\alpha \beta }}{Z}_{\beta }{X}_{\alpha }$.

It will be useful to also consider the (abelian) group of operators called pure errors (a.k.a. destabilizers) $\mathcal{P}\subset {\mathcal{G}}_{n}$. This group is defined by nk operators Pi which satisfy ${P}_{i}{S}_{j}={(-1)}^{{\delta }_{ij}}{S}_{j}{P}_{i}$ and ${P}_{i}^{2}=\mathbb{1}$. The Pauli group on n physical qubits is generated by products of Pi , Si , Xα and Zα .

Finally, during error correction, we measure each of the stabilizer generators (which have eigenvalues ±1), giving the error syndrome. This is a length-r vector $\vec{s}$ of the measurement outcomes, with si = 0 if the error commuted and si = 1 if the error anticommuted with stabilizer Si . Finding the optimal correction operator given the syndrome is extremely difficult in general [29, 30], though some algorithms work well for some codes (e.g., minimum-weight perfect matching for the surface code). It is always straightforward to find an error consistent with a given syndrome by using the pure errors, i.e., the operator $P(\vec{s}\,)={\prod }_{i}{P}_{i}^{{s}_{i}}$ gives rise to the syndrome $\vec{s}$. But quantum codes are degenerate, meaning multiple different errors can have the same syndrome, e.g., $P(\vec{s}\,)$ and $P(\vec{s}\,)S$ for any stabilizer S will give rise to the same error syndrome.

3. Stabilizer codes from tensor networks

As introduced in [8], we represent small 'seed' stabilizer codes by tensors and use them to build up bigger stabilizer codes. This works as follows. We can represent Pauli operators by strings of integers, so the operator $XZZX\mathbb{1}={\sigma }^{1}{\sigma }^{3}{\sigma }^{3}{\sigma }^{1}{\sigma }^{0}$ would be represented by the string (1, 3, 3, 1, 0).

For a stabilizer code with n physical and k logical qubits, we define the rank-n tensor

Equation (1)

for each logical operator L. Here the indices gj ∈ {0, 1, 2, 3}, and $\mathcal{S}L$ is the set of all operators SL with $S\in \mathcal{S}$. In other words, $\mathcal{S}L$ is the coset of $\mathcal{S}$ with respect to logical L. We can also think of $T{(L)}_{{g}_{1},\dots ,{g}_{n}}$ as the indicator function for all operators in the class L.

As an example, $T{(\mathbb{1})}_{{g}_{1},\dots ,{g}_{n}}$ describes the stabilizer group, as it is non zero only if ${\sigma }^{{g}_{1}}\otimes \cdots \otimes {\sigma }^{{g}_{n}}$ corresponds to a stabilizer. This does not include the signs of the stabilizers, though once these are fixed for a set of generators, then they are fully determined for the rest of the group. Also, for a stabilizer code that has only a single logical qubit, the tensor $T{(X)}_{{g}_{1},\dots ,{g}_{n}}$ describes the coset corresponding to the logical X operator.

As explained in [8], contracting seed tensors generates larger codes, which come with a natural tensor-network decoder. A useful idea then is to start with a tensor-network geometry that is efficiently contractible and use this to construct codes that we know we can decode efficiently since we can contract the tensor network. We can then vary the code tensors within this geometry to search for good codes.

To see how to contract code tensors to get new stabilizer codes is straightforward. First, the tensor describing a tensor product of two stabilizer codes is just the product of the code tensors:

Equation (2)

Second, we contract two indices (say g1 and h1 above). To understand when the resulting tensor describes a bona fide stabilizer code, we look at the more general case of contracting two indices of a code tensor. Take code tensor $T{(L)}_{{j}_{1},\dots ,{j}_{n}}$ with n physical qubits and k logical qubits. Suppose we contract two indices (take the first two indices for simplicity), i.e.,

Equation (3)

It is straightforward to check if the left-hand side is a code tensor describing a stabilizer code, as shown in more detail in appendix A. In short, a sufficient condition ensuring that the resulting tensor also describes a stabilizer code is if we can find two stabilizers of the original code S1 and S2 that have the following form. Writing ${S}_{1}={\sigma }^{{j}_{1}}\otimes {\sigma }^{{j}_{2}}\otimes {\sigma }^{{j}_{3}}\otimes \dots $ and ${S}_{2}={\sigma }^{{i}_{1}}\otimes {\sigma }^{{i}_{2}}\otimes {\sigma }^{{i}_{3}}\otimes \dots $, we require that i1i2 and j1j2. We also require that after taking their product ${S}_{1}{S}_{2}={\sigma }^{{k}_{1}}\otimes {\sigma }^{{k}_{2}}\otimes {\sigma }^{{k}_{3}}\otimes \dots $ with k1k2. This condition is sufficient but not necessary in some cases, as explained in appendix A. From a numerical perspective, two stabilizers satisfying the conditions above can be found quickly (in O(n) time), and stabilizer generators and logical operators for the new stabilizer code can also be found quickly (also in O(n) time).

With this formalism it is straightforward to build larger error correcting codes using smaller seed code tensors as building blocks. These tensor-network codes include many holographic codes as well as concatenated codes and generalized concatenated codes [32, 33]. However, there is no restriction on the geometry of the network or the number of logical qubits.

Physically, in a photonic setting we can think of the contraction of two tensor indices as type-II fusion [34, 35], where we are measuring ${\sigma }^{1}\otimes {\sigma }^{1}\otimes \mathbb{1}\dots $ and ${\sigma }^{3}\otimes {\sigma }^{3}\otimes \mathbb{1}\dots .$

In figure 1(a), we give an example of a simple tensor-network code composed of three five-qubit code tensors (see table 1 for a description of the five-qubit code). This is a [[8, 3, 3]] code, which is the maximum distance for a code with eight physical and three logical qubits [31].

Figure 1.

Figure 1. Example tensor-network code graphs. Code tensors introducing one logical qubit per code are shown in blue, code tensors with no logicals are green, and physical qubits are shown in red. (a) Each code tensor is a five-qubit code tensor, which gives rise to a [[8, 3, 3]] code. (b) Shows a larger tensor-network code with 13 physical qubits and one logical qubit. The central blue tensor is a five-qubit code tensor, and the remaining code tensors are purified five-qubit code tensors. (c) Histogram of operator weights for the code in (b). Stabilizers (the identity coset) are shown in red and logical operators (not including the identity) are shown in blue. Note that only one bar (red or blue) appears for, e.g., weight-five operators because there are no weight-five stabilizers, only weight-five logical operators. Here we see that the code in (b) is a [[13, 1, 5]] code. (In fact, contracting indices corresponding to qubits two and three generates a [[11, 1, 5]] code, which is the maximum distance possible with 11 physical qubits and one logical qubit [31].)

Standard image High-resolution image

Table 1. Logical operators and stabilizer generators for the five-qubit code. The operators on physical qubits are shown in columns 1–5, and the action on the codespace is in column 0. We can think of all six operators on 0–6 as stabilizing a six-qubit stabilizer state, i.e., a purified five-qubit code.

Qubit012345
S1 $\mathbb{1}$ X Z Z X $\mathbb{1}$
S2 $\mathbb{1}$ $\mathbb{1}$ X Z Z X
S3 $\mathbb{1}$ X $\mathbb{1}$ X Z Z
S4 $\mathbb{1}$ Z X $\mathbb{1}$ X Z
X1 X X X X X X
Z1 Z Z Z Z Z Z

4. Calculating code distance via tensor networks

The tensor-network code construction naturally gives rise to an algorithm for computing the code distance. In fact, we can calculate more information: by contracting a tensor network, we generate a histogram of operators (logicals and/or stabilizers) according to their weight. If the tensor-network is efficiently contractible, then this histogram can be generated efficiently.

To see this, start by defining a weight tensor:

Equation (4)

where the function $\mathsf{w}\mathsf{e}\mathsf{i}\mathsf{g}\mathsf{h}\mathsf{t}$ returns the weight of a Pauli operator, i.e., the number of locations where it acts non trivially. To find the distribution of operator weights of a tensor-network code, we use the representation ${T}_{{g}_{1},\dots ,{g}_{n}}^{{l}_{1},\dots ,{l}_{k}}=T{(L)}_{{g}_{1},\dots ,{g}_{n}}$, where li = 0, 1, 2, 3 indicates the logical identity, X, Y and Z operator on the ith logical qubit. Then the number of operators of each weight for each logical coset is given by

Equation (5)

where repeated indices are summed. For example, ${C}_{w}^{0,\dots ,0}$ is a list of the numbers of stabilizers of each weight. Then we calculate the distance of the code using

Equation (6)

Here we sum over all logical cosets and then subtract the identity coset (the stabilizer group). The code distance is then given by the first value of the index w for which Dw ≠ 0.

On its own, this is not particularly useful, as the tensors T or W will become unwieldy for large n. However, we split W into a product of smaller tensors by first generalizing it:

Equation (7)

We note that ${W}_{{w}_{\text{out}}}^{{g}_{1},\dots ,{g}_{n}}={W}_{{w}_{\text{out}},0}^{{g}_{1},\dots ,{g}_{n}}$. It follows that these tensors can be chained in a natural way.

Equation (8)

We can chain these tensors in a way that mimics the tensor-network geometry of the original code. As a result if the original code tensor network can be contracted easily, so can the tensor network to calculate weights.

Let us consider a simple example. As shown in figure 1(b), we have contracted five code tensors, with one corresponding to the five-qubit code, and the rest corresponding to the purified five-qubit code (see table 1), so there is a single logical qubit. By using our tensor-network method, we find the distribution of operator weights as shown in figure 1(c). We see that the distance is five, so this is a [[13, 1, 5]] code.

This is a promising new way to find code distances, provided we can contract the tensor network. This method can also be expanded to find the distribution of logical operators by weight restricted to those of a certain form, e.g., those that have only identity and Pauli Z components. This can be used to identify codes that perform well in the presence of biased noise, much like the tailored code in [10].

A useful idea is to start with tensor-network geometries that we know we can easily contract and then try (possibly random) different choices of seed code tensors to find high-distance codes. We can also look for codes that not only have high distance but also have many low-weight stabilizers, since we also know the weight distribution of stabilizers. One good starting point would be the following: tensor networks or quantum circuits with low enough treewidth (constant or in some cases log-depth) can be contracted efficiently [36]. (A trivial example is concatenated codes, which are described by a tree tensor network.) This means that any tensor-network code with a low enough treewidth or code with an encoding circuit with low enough treewidth will have an efficient method to calculate distance. (This also applies to decoding, as was seen for codes with encoding circuits based on the MERA tensor network [2].) An interesting example of codes for which distance can be efficiently calculated using this tensor-network method are stabilizer codes encoded by local log-depth circuits in one dimension (appendix B). In fact, using such circuits with gates chosen at random, these codes perform very well against erasure noise on average [37]. A similar argument to the proof in appendix B shows that decoding is also efficient. This distance calculation method is also efficient for holographic codes (see appendix B).

5. Maximum likelihood decoding via tensor networks

Maximum likelihood decoding is optimal, as it uses the syndrome to find the correction operator that is most likely to return the code to the correct code state. For general quantum codes, this is a very difficult computational task [30]. One method that works well for some codes uses tensor networks [2, 3, 79].

We can write any error with syndrome $\vec{s}$ as $P(\vec{s}\,)SL$, where $P(\vec{s}\,)$ is the pure error corresponding to syndrome $\vec{s}$, and some $S\in \mathcal{S}$ and $L\in \mathcal{L}$. The key point is that $P(\vec{s}\,)SL$ has the same effect on the codespace regardless of which stabilizer S appears. In contrast, different logicals L will have different effects on the codespace. To find the optimal correction, we need to calculate

Equation (9)

for each logical $L\in \mathcal{L}$. Here $\mathrm{p}\mathrm{r}\mathrm{o}\mathrm{b}(P(\vec{s}\,)SL)$ is the probability that the error $P(\vec{s}\,)SL$ occurred. Then the best correction operator is $\bar{L}P(\vec{s}\,)$, where $\bar{L}={\mathrm{a}\mathrm{r}\mathrm{g}\mathrm{m}\mathrm{a}\mathrm{x}}_{L}\chi (L,\vec{s}\,)$.

Using tensor-network codes, we should think of the noise distribution $\mathrm{p}\mathrm{r}\mathrm{o}\mathrm{b}(P(\vec{s}\,)SL)$ as a tensor. To do this, we write $SL={\sigma }^{{g}_{1}}\otimes \cdots \otimes {\sigma }^{{g}_{n}}$ and $P(\vec{s}\,)={\sigma }^{{e}_{1}}\otimes \cdots \otimes {\sigma }^{{e}_{n}}$. Recall that $P(\vec{s}\,)$ is fixed by the syndrome. Then we define

Equation (10)

For uncorrelated error models (e.g., i.i.d. depolarizing noise), this factorizes simply to a product of rank-one tensors: $\mathcal{E}{(\vec{s}\,)}^{{g}_{1},\dots ,{g}_{n}}={p}_{1}({\sigma }^{{e}_{1}}{\sigma }^{{g}_{1}})\times \cdots \times {p}_{n}({\sigma }^{{e}_{n}}{\sigma }^{{g}_{n}})$, with ${p}_{i}({\sigma }^{{a}_{i}})$ being the probability that the noise will cause ${\sigma }^{{a}_{i}}$ to act on qubit i.

Calculating $\chi (L,\vec{s}\,)$ involves contracting the code tensor with $\mathcal{E}$ to get

Equation (11)

As we saw for the tensor-network distance calculator, this is useful if T and $\mathcal{E}(\vec{s}\,)$ both factorize in a way that is amenable to contraction. This is made especially easy for i.i.d. noise, but correlated noise can also be handled in some cases if, e.g., it has a finite correlation length, as is the case for factored noise [7].

There are some important examples where this decoding approach works well, such as (planar) surface codes [3], codes based on the MERA tensor network [2], and holographic codes [8]. It is also clear that such an approach would work well for concatenated or convolutional codes, but these already have efficient and exact decoders. Typically, this decoding method involves approximations, e.g., in [3] the two-dimensional tensor network was contracted using the matrix-product state (MPS)–MPO method, which uses bond-dimension truncation.

6. Regular tensor network codes on a lattice and tensor network 'doping'

We view several important topological codes as tensor-network codes built from smaller codes. For example, the rotated surface code can be seen as a tensor-network code made of surface code fragments. This is constructed from bulk tensors corresponding to the five-qubit surface code with stabilizers in table 2. The construction is most easily understood from figure 2. Similarly one can construct the colour code, as described in appendix C, and the original (unrotated) surface code.

Table 2. Logical operators and stabilizer generators for the [[5, 1, 2]] surface code fragment.

Figure 2.

Figure 2. (a) and (b) Show bulk tensors for the surface code. Numbers correspond to qubits in table 2. The code tensor in (a) includes logical X as an additional stabilizer, while the code tensor in (b) includes logical Z as a code stabilizer. (c) Shows stabilizers of code tensors [at the top left corner of the tensor network in (e)] before contraction of indices, and (d) shows the resulting stabilizer after contraction of tensor indices. (e) Shows the [[25, 1, 5]] rotated planar surface code as a tensor-network code. Each green tensor in the bulk is a five-qubit surface code tensor with alternating tensors having logical X or Z as an additional stabilizer as shown in (a) & (b). The central tensor (blue) has a single logical qubit. Yellow and red circles represent physical qubits. Here we see a plaquette stabilizer, with non-trivial Paulis in red, and identities in yellow. Our doped code simply replaces the blue tensor by the same tensor with the legs permuted and single-qubit Clifford applied (these were chosen to match the surface code's distance, while lowering the number of minimal-weight logical operators).

Standard image High-resolution image

Consider a rotated [[L2, 1, L]] surface code with length L. The degeneracy of the lowest-weight logical operators is actually quite high and grows quickly with L, e.g., for L = 7 it is already 896, versus only 14 for the original surface code with L = 7. It seems natural that keeping distance and code size fixed, while lowering the degeneracy of the lowest-weight logical operators may be an interesting avenue to explore to find better performing codes.

To do this, we now use the local tensor-network code construction on a regular lattice to propose an approach to generate new codes. This is inspired by materials science, in which highly regular crystal lattices can be modified by doping with low densities of an impurity species. In a sense, this is complementary to other code constructions which add lattice defects [38] as a means to adapting homogeneous codes—again with analogies in materials science for producing materials with desirable properties. We term these codes 'doped' tensor-network codes.

The simplest example of a doped tensor-network code involves replacing the central tensor encoding the logical qubit by a different code tensor. (We permuted the legs of the central code tensor and applied single-qubit Clifford unitaries.) We then compared the operator weights for this doped code with that of the rotated surface code. For example, for a 7 × 7 code, we see that both codes have the same size n = 49 and the same distance d = 7, but the rotated surface code has a degeneracy of the lowest-weight logical operators of 896, whereas for the doped code, this is only 662. This reduction in the number of low-weight logical operators may be responsible for the improved error correction properties. Indeed, in figure 3, we see that the doped code does perform somewhat better under depolarizing noise using the tensor-network decoder. The price we pay is some (three) of the stabilizers are modified to have higher weight, as shown in figure 6 in appendix C. For this example, it is probable that this improvement does not persist in a fault-tolerant setting, as the higher-weight stabilizers will lead to more errors due to, e.g., imperfect measurements. Nevertheless, this general idea of reducing the degeneracy of the lowest weight logical operators could be useful for discriminating codes that have the same distance.

Figure 3.

Figure 3. Success rates for the doped surface code and the rotated surface code versus the single-qubit error probability p. Here we see an improvement in success probability when using the doped surface code by up to 1.6%. (This maximum improvement occurs for size 7 × 7 codes at p = 0.16. The improvement decreases as p → 0, as we would expect, since the success rate tends to one for all codes.) Interpolating lines are used to distinguish between success rates within a fixed code. Each point corresponds to 10 000 Monte Carlo samples, and error bars correspond to standard errors. (Connecting lines are only to guide the eye.) Choosing relatively small codes allowed us to do the tensor contraction exactly, which ensures that the improvement in performance is not an anomaly due to the choice of bond dimension. Our calculations were done using our Julia package TensorNetworkCodes.jl [39], which uses the ITensors.jl package for tensor-network contractions [40].

Standard image High-resolution image

7. Discussion

Here we have seen a method that creates general tensor-network codes on graphs. The main result is a tensor-network based method to calculate code distances, as well as the full distribution of operator (logical and stabilizer) weights. We showed that this is efficient for two interesting classes of stabilizer codes: those encoded by local log-depth circuits and holographic codes.

Furthermore, we can search for good tensor-network codes by iterating over different networks of (perhaps randomly chosen) code tensors to find the highest distance code, and then among codes with high distance, we can choose one that has the lowest number of minimal-weight logical operators. This is precisely what we did to find the doped surface code in section 6. By replacing the central code tensor with a different code tensor, we found a modification of the rotated surface code with the same distance but fewer minimal-weight logical operators. We found that this new code had a slightly improved successful error correction probability. This came at the price of replacing three of the stabilizers by higher-weight stabilizers. This idea of substituting tensors provides an interesting way to introduce a controlled degree of inhomogeneity into topological codes. This would allow us to investigate the role of non-locality and adapt codes to physical architectures that support some degree of non-locality.

There are many other open possibilities using tensor-network codes. One possibility is to start with tensor-network geometries that are efficiently contractible, as these can be decoded efficiently. Then we can search for error correcting codes that have high thresholds against noise. This could use a reinforcement learning strategy for example, as this has been successfully applied to designing the layout of surface codes to perform well [41]. This would entail fixing a small set of possible choices, i.e., code tensors and options for contraction, e.g., restricting the network to have low treewidth. Then analogously to [41] the learning strategy works by allowing the algorithm to build codes of increasing size and rewarding it more for codes with low logical error rates (for tensor-network codes it may also be possible to use code distance to measure success).

Other questions involve the connection between tensor-network codes and LDPC codes. For example, it is known that the graph separator of connectivity graphs of quantum codes determines their properties (such as distance, rate and fault-tolerant gate set) [42]. It is interesting to ask whether something similar applies to tensor-network codes when considering the properties of the tensor network graph.

Note added

A few days prior to the completion of this paper, a related work appeared on the arXiv [43], where the authors also look at creating larger error correcting codes from smaller code tensors. This work complements ours nicely, as it includes non-stabilizer codes and a treatment of transversal gates, whereas we focus on stabilizer codes and include a method for distance calculation with tensor networks.

Acknowledgments

The authors are grateful to Ben Brown, Chris Dawson, Rob Harris, Ian McCulloch and Jordan Taylor for useful discussions. This work was supported by the Australian Research Council Centres of Excellence for Engineered Quantum Systems (EQUS, CE170100009) and the Asian Office of Aerospace Research and Development (AOARD) Grant FA2386-18-14027.

Data availability statement

The data that support the findings of this study are openly available at the following URL/DOI: https://github.com/qecsim/TensorNetworkCodes.jl. Data will be available from 01 Feburary 2022.

Appendix A.: Code-tensor contraction

To join code tensors to get new stabilizer codes we start by noting that a tensor product of two codes is represented by a product of code tensors:

Equation (A1)

And to understand when we can safely contract indices, we ask when we can contract indices for a general code tensor. Given code tensors $T{(L)}_{{j}_{1},\dots ,{j}_{n}}$ with n physical qubits and k logical qubits. We can contract two indices to find new tensors describing a new stabilizer code (without loss of generality, we will contract the first two indices).

Equation (A2)

Let us now see what constraint we need the original code to satisfy to ensure that this contraction takes a [[n, k]] code to a [[n − 2, k]] code. In a physical sense, we need that the type II fusion measurement does not measure any logical operators, i.e., we require that we can find representatives of each logical operator that commute with ${M}_{1}={\sigma }^{1}\otimes {\sigma }^{1}\otimes \mathbb{1}\dots $ and ${M}_{3}={\sigma }^{3}\otimes {\sigma }^{3}\otimes \mathbb{1}\dots .$

To see how the code is modified by this measurement, we look at which stabilizers S and logicals L survive the measurement. If we write a stabilizer $S={\sigma }^{{i}_{1}}\otimes {\sigma }^{{i}_{2}}\otimes {\sigma }^{{i}_{3}}\otimes \dots ,$ then if i1 = i2, after the measurement we get that $\pm {\sigma }^{{i}_{3}}\otimes \dots $ is a new stabilizer on n − 2 qubits. The sign depends on the result of the measurement of M1 and M3. (For simplicity, from here on we will assume the measurement results are both +1, but if necessary it is simple to keep track of these minus signs, as we only need them for a set of stabilizer generators.)

Case I: neither M1 nor M3 are in the stabilizer group.

In this case for the logical qubits to be preserved after the measurement, it is sufficient that there be two stabilizers in $\mathcal{S}$, say ${S}_{1}={\sigma }^{{i}_{1}}\otimes {\sigma }^{{i}_{2}}\otimes {\sigma }^{{i}_{3}}\otimes \dots $ and ${S}_{2}={\sigma }^{{j}_{1}}\otimes {\sigma }^{{j}_{2}}\otimes {\sigma }^{{j}_{3}}\otimes \dots $ that satisfy

Equation (A3)

and, if we take their product, ${S}_{1}{S}_{2}={\sigma }^{{k}_{1}}\otimes {\sigma }^{{k}_{2}}\otimes {\sigma }^{{k}_{3}}\otimes \dots $, then

Equation (A4)

Next we show that the existence of such S1 and S2 is sufficient for the logical degrees of freedom to be preserved by the measurements. First, each Si must anticommute with one or both of M1 and M3. This follows because i1i2 and j1j2. Furthermore, both S1 and S2 cannot anticommute with both M1 and M3 because that would imply that S1 S2 commutes with both M1 and M3, which is impossible because k1k2.

Given an operator O, which could be another stabilizer, logical operator, or pure error, it may anticommute with one or both of M1 and M3. But we can choose some product of S1 and S2 that has the same commutation relations with M1 and M3. Then multiplying O by this product gives a new operator that commutes with both M1 and M3.

Therefore, the remaining nk − 2 stabilizer generators (we can choose S1 and S2 to be two of the stabilizer generators) can be chosen to commute with M1 and M3. Hence, nk − 2 stabilizer generators survive the measurement. The end result is then a stabilizer code on n − 2 qubits with k logical qubits.

Finally, after contracting the two indices, the values of ${T}_{\text{new}}{(L)}_{{j}_{3},\dots ,{j}_{n}}$ in equation (A2) can only be zero or one, which means we have a valid code tensor. This is because, for fixed j3, ..., jn , there is at most one operator in each of the logical cosets of the original code of the form ${\sigma }^{i}\otimes {\sigma }^{i}\otimes {\sigma }^{{j}_{3}}\otimes \dots $. If there were two, then their product would be a stabilizer of the form ${\sigma }^{k}\otimes {\sigma }^{k}\otimes \mathbb{1}\otimes \dots $ for some k ≠ 0. But this is impossible because this would not commute with S1 and S2.

Case II: exactly one of M1 and M3 is in the stabilizer group.

Suppose M3 is in the stabilizer group. Then a simpler argument than the previous case works. We need only find a stabilizer, say S1, that anticommutes with M1. More specifically, we need to find a stabilizer ${S}_{1}={\sigma }^{{i}_{1}}\otimes {\sigma }^{{i}_{2}}\otimes {\sigma }^{{i}_{3}}\otimes \dots $, with i1i2 and {i1, i2} ≠ {0, 1} and {i1, i2} ≠ {2, 3}. These conditions guarantee that S1 will anticommute with M1. Then, if any of the remaining stabilizers or logical operators anticommute with M1, we can simply multiply by S1 to get an operator that does commute with M1. It already commutes with M3 because that is a stabilizer.

Note that we do need to renormalize the tensor

Equation (A5)

This is because, for every operator of the form ${\sigma }^{i}\otimes {\sigma }^{i}\otimes {\sigma }^{{j}_{3}}\otimes \cdots \otimes {\sigma }^{{j}_{n}}$ in a logical coset, ${M}_{3}({\sigma }^{i}\otimes {\sigma }^{i}\otimes {\sigma }^{{j}_{3}}\otimes \cdots \otimes {\sigma }^{{j}_{n}})={\sigma }^{{i}^{\prime }}\otimes {\sigma }^{{i}^{\prime }}\otimes {\sigma }^{{j}_{3}}\otimes \cdots \otimes {\sigma }^{{j}_{n}}$ is also in the coset, so every nonzero value of Tnew would be two if we did not renormalize. (The factor of two would not actually affect decoding or distance calculation since it is just an overall constant.)

Case III: both M1 and M3 are in the stabilizer group.

The logical operators and stabilizers are already in the right form, so there is nothing to do. Again we need to renormalize:

Equation (A6)

Appendix B.: Distances for codes built from log-depth local circuits and holographic codes

Stabilizer codes built from log-depth local circuits can be viewed as a tensor-network code in a simple way. Let U be a Clifford encoding unitary, i.e., it takes Pauli operators to Pauli operators. We can also represent U by a tensor ${u}_{{i}_{1},\dots ,{i}_{n}}^{{j}_{1},\dots ,{j}_{n}}$, that satisfies

Equation (B1)

Any unitary can be written in this way, but the constraint that this is a Clifford unitary is that, for given indices j1, ..., jn , the tensor ${u}_{{i}_{1},\dots ,{i}_{n}}^{{j}_{1},\dots ,{j}_{n}}\in \left\{1,-1\right\}$ for exactly one set of indices i1, ..., in , with ${u}_{{i}_{1},\dots ,{i}_{n}}^{{j}_{1},\dots ,{j}_{n}}=0$ for all other indices. For simplicity, let us take the first k input qubits to be logical input qubits. Then the image of an operator ${\sigma }^{{j}_{1}}\otimes \cdots \otimes {\sigma }^{{j}_{k}}\otimes {\sigma }^{0}\otimes \cdots \otimes {\sigma }^{0}$ under U is a logical operator on the codespace.

Similarly, the stabilizer generators are the image under U of all operators $\dots \otimes {\sigma }^{0}\otimes {\sigma }^{{j}_{r}}\otimes {\sigma }^{0}\otimes \dots $, with r ∈ {k + 1, ..., n}. This means that the code tensor T(L), defined in equation (1), which represents logical coset $\mathcal{S}L$ with logical operator $L={\sigma }^{{j}_{1}}\otimes \cdots \otimes {\sigma }^{{j}_{k}}$ can be written as

Equation (B2)

We will write $T{({\sigma }^{{j}_{1}}\otimes \cdots \otimes {\sigma }^{{j}_{k}})}_{{i}_{1},\dots ,{i}_{n}}={T}_{{i}_{1},\dots ,{i}_{n}}^{{j}_{1},\dots ,{j}_{k}}$ to simplify the notation.

To use this to calculate code distances, we must contract with the weight tensor as in equation (5). In other words, we need to perform the contraction

Equation (B3)

As we saw in section 4, the trick to do this is to break up the tensor W into smaller tensors. That the contraction is efficient is best explained in figure 4. The reason is essentially that the code tensor is an MPS with polynomial bond dimension, which follows because one can split local gates applied to qubits via singular value decomposition. The weight tensor ${W}_{w}^{{i}_{1},\dots ,{i}_{n}}$ is also equivalent to an MPS with (at most) bond dimension linear in n, so ${C}_{w}^{{j}_{1},\dots ,{j}_{k}}$, which is just the contraction of two MPSs, can be found efficiently.

Figure 4.

Figure 4. Calculation of the operator-weight distribution for a one-dimensional code with a local log-depth encoding circuit. Here the black vertical lines represent the n physical qubits in the Pauli representation, so each corresponds to an index with values in {0, 1, 2, 3} for the identity and three Pauli matrices. Encoding goes from top to bottom, with the pink rectangles representing two-qubit Clifford gates (the argument applies to more general circuits, possibly with periodic boundary conditions). The logical indices j1 to jk (which need not be consecutive) determine the logical coset. The yellow triangle tensors implement the sum over stabilizers, i.e., each is a rank-one tensor tj , with tj = 1 if j ∈ {0, 3} and tj = 0 otherwise. Thus the circuit gives the code tensor ${T}_{{i}_{1},\dots ,{i}_{n}}^{{j}_{1},\dots ,{j}_{k}}$. The final row of tensors is equivalent to ${W}_{w}^{{i}_{1},\dots ,{i}_{n}}$, which counts the weight of the operators. Contracting the whole network calculates ${C}_{w}^{{j}_{1},\dots ,{j}_{k}}={W}_{w}^{{i}_{1},\dots ,{i}_{n}}{T}_{{i}_{1},\dots ,{i}_{n}}^{{j}_{1},\dots ,{j}_{k}}$, which encodes the distribution of operator weights (and hence the distance). To see that this is efficient if the depth is logarithmic in the code size, notice that any vertical cut will cross logarithmically many gates, leading to an MPS with a polynomial bond dimension.

Standard image High-resolution image

If there is an extensive number of logical qubits, then ${C}_{w}^{{j}_{1},\dots ,{j}_{k}}$ will have an extensive number of indices. This is cumbersome to work with, but it is still possible to efficiently find the code distance. This works by doing two contractions. The first is done by contracting the network in figure 4 with j1 =⋯= jk = 0, which gives us ${C}_{w}^{0,\dots ,0}$, the distribution of stabilizer weights. The second contraction is done by summing over all values of j1, ‥, jk , which can be done with rank-one tensors. This allows us to calculate the weight distribution of all nontrivial logical operators via

Equation (B4)

As we saw in section 4, the distance is the first value of the index w for which Dw ≠ 0.

The argument for holographic codes works similarly. Calculating distances for holographic codes using tensor networks is efficient for a similar reason to why tensor-network decoding of holographic codes is exact and efficient [8]. This is because the corresponding tensor network can be contracted efficiently exactly, which follows roughly because the bond dimension is at most O(n). The contraction scheme can be understood from figure 5, where the tensor network is contracted from the outside in. Figure 5(a) shows a holographic code composed of non-CSS five-qubit code tensors (introduced in [12]). As shown in figure 5(b), calculating the distribution of operator weights requires us to contract the boundary tensors with the weight tensors W (shown as yellow boxes), which were defined in equation (4). After performing these boundary contractions, we get the tensor network shown in figure 5(d). To contract this tensor network, we start from the outside and contract inwards. This can be done by locally contracting a tensor at radius r − 1 with several tensors at radius r following the strategy in [8]. The generic form of the intermediate tensor contractions is shown in figure 5(c). All of the intermediate contractions, except for the final contraction with the central tensor take the form of the generic contraction in figure 5(c).

Figure 5.

Figure 5. (a) Shows an example of a holographic code composed of non-CSS five-qubit code tensors (this holographic code was introduced in [12]). This is a radius-three code: the different radii are denoted by numbers in (a). The central blue tensor corresponds to the five-qubit code tensor, and the remaining green tensors correspond to the purified five-qubit code. Both codes are described in table 1. The uncontracted legs correspond to physical qubits. (b) To calculate the distribution of operator weights, we contract the boundary tensors (green) with the weight tensors W (yellow box) defined in equation (4). Black lines correspond to tensor-network code indices, which have dimension 4, whereas red lines correspond to weight-tensor indices, which essentially count weights of Pauli operators. For this example there are five qubits, so w ∈ {0, ..., 5}. The resultant tensor after contracting is shown as a yellow pentagon. After performing these contractions at the boundary, we get the tensor network in (d). To contract this tensor network, we start from the outside and contract inwards. (c) Shows the generic form of the tensor contractions, as seen, e.g., in the shaded region in (d). All contractions, except the final contraction with the central tensor are of this form (also for higher radius codes). The dashed lines represent extra legs that only arise for holographic codes with radius higher than three (due to loops in the tensor network), but the main idea of how the network is contracted is the same.

Standard image High-resolution image

To see that the contraction of the whole network is efficient, the crucial point is that the dimensions of all tensor legs are at most linear in n. This is obvious for the legs from the weight tensors since they count operator weights, and there are only n physical qubits. For the bond legs (dashed lines in figure 5(c)), their dimension being linear in n was proven in [8]. Therefore, it follows that the cost of one such contraction is polynomial in n because there is a fixed number of tensors in each contraction, and the legs between them have dimension at most linear in n. Furthermore, the number of tensors in the network is also polynomial in n, so the number of contractions of the type shown in figure 5(c) is also polynomial. Hence, the total complexity is polynomial in n. Therefore, the exact contraction is efficient, so we can efficiently generate the weights of logical operators and stabilizers, which also provides us with the code distance.

Appendix C.: More on regular tensor-network codes

The doped surface code described in section 6. has all the local stabilizers of the surface code, except that three of the central four plaquette stabilizers are replaced by the three displayed in figure 6.

Figure 6.

Figure 6. (a) and (b) Show the logical Z and X operators of the doped surface code respectively. These are string like, extending from the centre to the code boundary. (c), (d) and (e) Show the three new stabilizers in the doped surface code. (f) Shows the an example of a plaquette stabilizer that is the same as in the normal rotated surface code. All other stabilizers (i.e., on the boundary and on plaquettes other than the central four) are also unchanged. The three new stabilizers for the 7 × 7 code have higher weight than the usual stabilizer code, with two being string like extending to one boundary. As a result, the weight of these two stabilizers is extensive. It is worth bearing in mind that this will likely decrease the effectiveness of the code in a fault-tolerant setting. Whether this or other similar codes still provide an improvement in performance will depend on the architecture, but a useful goal for tensor-network codes would be to modify codes (or engineer new ones) with bounded-weight stabilizer generators.

Standard image High-resolution image

To construct the triangular colour code as a tensor-network code, we use two code tensors: the Steane code and a nine-qubit code with stabilizers and logical operators listed in table 3. While we find that this is a simple tensor-network code, to understand how the construction works, it is easier to use the graphical description shown in figure 7. Contracting code tensor indices is equivalent to a type II fusion measurement on those qubits. After contraction, the stabilizers and logical operators that survive are those that agreed on contracted indices, i.e., on the measured qubits. In figure 7(b), we see examples of two stabilizers that match on the qubits corresponding to indices that will be contracted. The result is the new stabilizer shown in figure 7(c). Repeating the process with Steane code tensors and the nine-qubit code tensor, we get larger colour codes, such as the [[19, 1, 5]] colour code in figure 7(f).

Table 3. (a) Logical operators and stabilizer generators for the [[7, 1, 3]] Steane code. (b) Stabilizer generators for a nine-qubit stabilizer state. Both codes are illustrated in figure 7(a), where qubit numbers in the tables above correspond to numbers in the figure.

(a)1234567
S1 Z Z $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ Z Z
S2 X X $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ X X
S3 $\mathbb{1}$ Z Z Z $\mathbb{1}$ $\mathbb{1}$ Z
S4 $\mathbb{1}$ X X X $\mathbb{1}$ $\mathbb{1}$ X
S5 $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ Z Z Z Z
S6 $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ X X X X
X1 X X X $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$
Z1 Z Z Z $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$
(b)123456789
S1 Z Z $\mathbb{1}$ Z Z $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$
S2 X X $\mathbb{1}$ X X $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$
S3 $\mathbb{1}$ Z Z $\mathbb{1}$ Z Z $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$
S4 $\mathbb{1}$ X X $\mathbb{1}$ X X $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$
S5 $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ Z Z Z Z Z Z
S6 $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ X X X X X X
S7 $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ Z Z $\mathbb{1}$
S8 $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ $\mathbb{1}$ X X $\mathbb{1}$
S9 $\mathbb{1}$ $\mathbb{1}$ X $\mathbb{1}$ $\mathbb{1}$ X $\mathbb{1}$ $\mathbb{1}$ X
Figure 7.

Figure 7. Building up the colour code using the two smaller codes shown in (a). Stabilizers and logical operators for these codes are listed in table 3. In this case, the pairs of qubit indices contracted are [1, 3, 4, 4, 5, 7], where the first qubit in each pair belongs to the Steane code (left in (a)) and the second belongs to the nine-qubit code (right in (a)). (b) Shows an example of two stabilizers from each code that match on the pairs of qubits. (c) Shows the resulting stabilizer after contraction. (d) Shows the addition of another Steane code, with two stabilizers shown that match on the qubits that will get contracted. Any additional Steane codes we contract must have logical Z as an additional stabilizer to reproduce the triangular colour code. (e) Shows the resulting colour code fragment after the contraction in (d). This procedure can be repeated to build up bigger colour codes, such as the 19-qubit code shown in (f).

Standard image High-resolution image
Please wait… references are loading.