# How do we create logical qubits in the surface code: understanding check

I am learning the basics of surface code theory through this paper

I am trying to understand how we create multiple logical qubits. The goal of my post is to check my understanding.

## What I understood so far:

One possible way to create a logical qubit is to create holes in the array, i.e we remove some Z and X stabilizer. One requirement we like to have is to avoid the use of logical operator which require applying Pauli operator from one edge of the surface to the holes. For this reason, we usually create a logical qubit by creating a pair of holes in the surface such as on the image below. On the left, we removed two $$Z$$ stabilizer measurement (this is called a double $$Z$$-cut). In principle we then removed two constraints and hence we added two logical qubits (on a conceptual level, but as written after we will not use both of them). The total dimension of the stabilized space is then $$2^3$$ (as the surface without holes could contain one logical qubit, and we now added two extra logical qubit conceptually).

Now, in practice we will consider storing only one logical qubit on this surface, where the Pauli are the $$X_L$$ and $$Z_L$$ represented.

In this example we then only use $$2$$ dimensions out of the $$2^3$$ conceptually available (one logical qubit out of the three conceptually available). Is that correct?

If we want to add logical qubits, we create more pair of holes. Hence for $$N$$ logical qubits that we want to store, we will create $$N$$ pairs of holes on the surface. Conceptually we could store $$2N+1$$ logical qubits with this construction but we will only manipulate $$N$$ out of them. Is that correct?

This answer provides a "combinatorial" approach to computing the dimension of the logical subspace and is meant to complement the "topological" approach described in Craig Gidney's answer.

## Importance of generator independence

Our starting point is the fact that a stabilizer group $$S$$ on $$n$$ physical qubits generated by $$g$$ independent generators stabilizes a $$2^{n-g}$$-dimensional subspace. See for example proposition $$10.5$$ on page $$458$$ in Nielsen & Chuang. This fact supports the general rule alluded to in the question that removing one of the independent generators adds a logical qubit.

The surface code is a stabilizer code so the above rule applies. However, careless application of the rule may lead to the incorrect conclusion that punching a hole in the surface code always adds a logical qubit. This is only true if the generator removed is independent of the other generators. For example, the $$Z_c$$ generator at the center of the code pictured below is easily seen to be equal to the product of all the other $$Z$$ (dark) generators and therefore is not independent. Consequently, removing $$Z_c$$ fails to introduce a degree of freedom necessary for the formation of a logical qubit.

## Topological interpretation

This fact has a topological interpretation. Note that the hole formed by the removal of $$Z_c$$ has boundary type opposite to the outer boundary of the code. Therefore, it is impossible to find two anti-commuting logical observables, as described in Craig's answer.

## Planar codes with two or more corners

It turns out that in a planar hole-free surface code all plaquettes correspond to independent generators if and only if the code has at least two corners defined here as data qubits incident on exactly two stabilizer generators (one of each type). Such a code possesses at least one boundary of each type. Introducing a pair of corners is associated with the net loss of one independent stabilizer generator. Therefore, a planar hole-free surface code with $$c\ge 2$$ corners encodes

$$k=\frac{c-2}{2}\tag1$$

logical qubits. Moreover, removal of any generator from the bulk (so that the number of corners is unaffected) is associated with the loss of a single independent generator. Therefore, a planar surface code with $$c\ge 2$$ corners and $$h$$ bulk generators removed encodes

$$k = h + \frac{c-2}{2}\tag2$$

logical qubits. The effect of punching a hole larger than a single plaquette depends on the number of removed generators and data qubits, but it is possible to punch a hole of any size while removing $$q$$ data qubits and $$q+1$$ generators leading to the introduction of exactly one degree of freedom.

## Dimension of the logical subspace

In this example we then only use $$2$$ dimensions out of the $$2^3$$ conceptually available (one logical qubit out of the three conceptually available). Is that correct?

Depends on the boundary. By equation $$(2)$$, the answer is yes if we assume for example that the boundary includes four corners, i.e. the code has two boundaries of each type.

If we want to add logical qubits, we create more pair of holes. Hence for $$N$$ logical qubits that we want to store, we will create $$N$$ pairs of holes on the surface. Conceptually we could store $$2N+1$$ logical qubits with this construction but we will only manipulate $$N$$ out of them. Is that correct?

Yes, but this is wasteful. By equation $$(2)$$, if the boundary has two corners, $$N$$ holes are sufficient. The holes may be of arbitrary type.

If the boundary has no corners, $$N$$ holes turn out to be sufficient as long as they match the boundary type. Finally, with $$N+1$$ holes of the same type, all logical operators on $$N$$ logical qubits may be obtained from chains going around the holes and linking holes to each other so the boundary may be ignored. This is a consequence of the fact that pair-of-holes encoding allows different logical qubits to share one of the holes.

• Very interesting, thank you for this extra information. For the first part of your message: would I be correct by summarizing it by saying that we need to go up to the boundaries to guess if we created or not a logical qubit by removing one generator as this generator might be a product of the others. Such knowledge is only accessible by considering the full surface (which is in a way what Craig Gidney meant but I did not get at the time) ? Jan 12 at 11:21
• Yes, your summary is correct. We can also express it in the topological language by saying that we need to know whether a boundary of type matching the hole exists. Jan 12 at 15:47

In this example we then only use 2 dimensions out of the $$2^3$$ conceptually available (one logical qubit out of the three conceptually available). Is that correct?

You need to specify the boundary conditions in order to do that kind of calculation. If you're using periodic boundaries (a donut) then yes there are two other logical qubits, but they have nothing to do with the holes.

It's actually kind of difficult to come up with simple rules for how many logical qubits are present. The cuts you make can run into each other or form interior spaces or all kinds of other corner cases. It's easy to show a logical qubit is present (you just demonstrate an anticommuting pair of observables that commutes with the stabilizers), but showing no more are present is a global calculation.

for N logical qubits that we want to store, we will create N pair of holes on the surface

You can do that, but you can also use a single-defect representation where you use $$N+1$$ holes instead of $$2N$$ holes. • Hello. Thank you for your answer. I am not sure to understand your first point though. My reasonning was based on the fact that for the full surface with no holes, I would have one logical qubit. By creating two holes, I remove two stabilizers. Hence I increase the dimension of the stabilized space by $2^2$. In the end I stabilize a space of dimension $2^3$ meaning that three logical qubits are stored. I am not sure to see the connection with the boundary conditions (wouldn't what I say work without boundary conditions)? What is wrong in my comment? Jan 11 at 20:15
• For the second point. Ok thanks! At least it can work in principle (but I will probably learn soon in the paper the technique you are thinking of). Jan 11 at 20:15
• @StarBucK What's the "full surface"? You need to specify the boundary types. Are you imagining (start)-X-then-Z-then-X-then-Z-(start) around the outer perimeter? In that case yes there are three logical qubits in the system. Try finding all three. Jan 11 at 21:13
• I am thinking of having for instance X boundary on the left and right, and Z boundary on the top and bottom of the full surface (no periodic boundary conditions). I thought that the surface were always designed in such a way. Aren't the three qubits "easy" to find in this case? I could define a first logical $X$ operator as being a line crossing the surface from the very left to the very right (the $Z$ operator would cross from top to bottom). Of course I have to avoid to touch the holes but this is always possible if the full surface is large enough to make such path exist. Jan 11 at 21:18
• Then the two other logical qubits are associated to the holes and have their $X$ and $Z$ logical as defined on the figure 10 of the paper (the $X_{L_1}, X_{L_2},Z_{L_1},Z_{L_2}$ on this figure). I guess this would work (now for practical reason I am not very aware of it might be very un-practical to consider those) Jan 11 at 21:18