# Understanding surface code diagrams

I originally posted this question on the Physics StackExchange site (see here), but I realized it would be better suited on this one.

I'm trying to understand the diagrams used in the following paper. I'm new to the area so I don't have experience with the stabilizer formalism, but I'm trying to figure out what's going on in the diagrams (Figures 1 and 2, specifically). I have a few specific questions:

1. Each vertex has a physical data qubit. But what exactly do the operators (green circles) represent? Is there an X and Z operator on every vertex site, or only some of them (Figure 1b)?

2. Relatedly, the logical X and Z operators are specified as chains of single-qubit operators (the green circles, I presume) connecting top to bottom (logical X) or left to right (logical Z). Do these chains have to be straight lines, or can they twist and turn?

3. Do the semi-circular plaquettes (which have only two single-qubit operators on them) represent the fact that we are wrapping around the surface (so we are on a torus), or is it something else?

4. I don't understand the single-qubit Pauli flips described in Figure 2. I can't see how we get an error (red dot). Any explanation for this would be helpful.

If someone could also explain to me the relationship between the Figure 1 in the above paper and Figure 1 of this paper, I think it would help makes things clearer.

Each vertex has a physical data qubit. But what exactly do the operators (green circles) represent? Is there an X and Z operator on every vertex site, or only some of them (Figure 1b)?

The circles on, e.g. the bottom-left of Fig. 1, show you how to describe each of the stabilizers. So, for every mustard yellow square in the top-left diagram, there is a stabilizer comprising a tensor product of 4 $$Z$$s, acting on the 4 vertices that that square touches. Similarly for the cyan squares with $$X$$ operators. So, every vertex in the bulk of the system is touched by 4 stabilizers, 2 with $$Z$$s and 2 with $$X$$s. On the edge, some of those squares are replaced by lines, i.e. pairs of terms.

Relatedly, the logical X and Z operators are specified as chains of single-qubit operators (the green circles, I presume) connecting top to bottom (logical X) or left to right (logical Z). Do these chains have to be straight lines, or can they twist and turn?

They can twist and turn. Logical $$X$$ is any continuous line of Pauli-$$X$$s going from top to bottom, with arbitrary twists and turns. Similarly for $$Z$$s going from left to right.

Do the semi-circular plaquettes (which have only two single-qubit operators on them) represent the fact that we are wrapping around the surface (so we are on a torus), or is it something else?

No. This is the surface code, not the Toric code. The surface code is the same as the Toric code but with open (rather than periodic) boundary conditions. The stabilizers have to be changed. So, the stabilizers act on pairs of qubits. Again, this is explicitly given in the bottom-left panel. The only reason for making them semi-circles is to that there;s a fill colour. If you just depicted it as a line, you wouldn't be able to colour it, and therefore wouldn't be able to tell what type it was.

I don't understand the single-qubit Pauli flips described in Figure 2. I can't see how we get an error (red dot). Any explanation for this would be helpful.

The red dots simply describe which stabilizers anti-commute with a given sequence of operations (the letters in green circles). So, if I act an $$X$$ operation on a single qubit, that commutes with all the $$X$$-type stabilizers. It commutes with all the $$Z$$-type stabilizers that do not act on that site. However, it anti-commutes with the two $$Z$$-type stabilizers which touch that site. So, they put a red dot on the corresponding two mustard yellow squares.

When you do multiple operations, red dots add up modulo 2. So, if I do two $$X$$ operations on neighbouring vertices, I still only have two red dots (rather than 4) because two act on the same yellow square, and cancel (Basically because $$XX$$ commutes with $$ZZZZ$$ if the two $$X$$s act on two of the sites that $$Z$$s act on)

If someone could also explain to me the relationship between the Figure 1 in the above paper and Figure 1 of this paper, I think it would help makes things clearer.

In the second paper, ignore the black circles. The yellow + shapes in that paper correspond to the cyan squares, and the green + shapes correspond to the mustard yellow squares. However, I don't think the correspondence is exact. I think (without having spent a long time carefully checking) that the two lattices are rotated by $$45^{\circ}$$ relative to each other, and that lets them have different boundary terms.

• Thank you for a nice, detailed answer. I do have some follow-up questions. It has to do with the logical operators on the lattice. It seems like I could have multiple lines going from the top to the bottom, or from the left to the right, since each vertex has 2 $X$'s and 2 $Z$'s. So are only expecting one logical $X$ and one logical $Z$, or can we have multiple? Also, I don't quite see why the logical $X$ is a vertical string and logical $Z$ is the horizontal ones. Can you explain that? – Germ Jan 8 at 19:14
• What is a logical operator? It is a tensor product of Pauli operators which (i) commutes with every stabilizer and (ii) cannot be written as a product of the stabilizers. You want to verify that about a single line of $X$s. Why different operations are different logical gates is a matter of definition. We choose to specify that the logical Z is the horizontal row of Zs. We then have to find another logical operator (e.g. column of Xs) that anti-commutes with that operator (because Paulis Z and X anti-commute) and we choose to call that logical X. – DaftWullie Jan 9 at 7:44