# Surface code with measurement errors

I am trying to implement error correction to a surface code with circuit-based noise model. In this model, there is a probability $$p$$ for an error in: initialization, Hadamard, CZ (or CNOT) and measurement. Yet, my question applies also for a simpler model, when there is only possibility of an error in the initialization and measurement.

I know that in order to account for measurement error, one needs to perform $$d$$ rounds of repeated measurements for a surface code of distance $$d$$. In addition, I know that each node in the syndrome graph should be given the value of the difference between two consecutive measurement.

Nevertheless, I have some troubles both regarding the specific realization of the syndrome graph as well as the definition of the logical qubit. Following this paper https://arxiv.org/pdf/1004.0255.pdf, I think my main issue is related to the boundary condition.

Let us assume that we are dealing with the surface code with $$d = 3$$. In addition, for simplicity, let us assume that all qubits are initialized in the $$|0\rangle$$ (i.e. an eigenstate of $$Z$$) and I only consider the $$Z$$-stabilizers, checking if there a logical $$X_{L}$$ error at the end. In addition, in the last layer, there is an ancilla qubit but we can assume it measures the qubit perfectly because in principle we can directly measure the data qubit at the end of the computation.

As far as I understand, we will have 3 layers in time, each acts like a simple surface code. The data qubits from the first layer can have an $$X$$-error during initialization, and this error will continue with them to the next layers (unless there are more error mechanisms, such as CZ, which can add errors during the process).

My first question: where are the nodes of the syndrome located, and how many are there? It seems that for each ancilla qubit, there are 3 nodes in the syndrome graph: the first between layer 1 and 2, the second between layer 2 and 3, and the third after layer 3 which acts like "capping". Is it true? If so, to which qubits are they connected (i.e. which qubits they can 'fix' if their value is 1)? It seems that if I have a measurement error on layer 1, this syndrome wouldn't know if it should correct the measurement error or the attached data qubit.

My second question is regarding the logical operator. For the simple surface code, with no measurement error, the only possible logical $$X$$ errors are those who creates a chain from (say) top to bottom. So, in principle, it is sufficient to consider only the top data qubits, sum their values modulo 2, and conclude that if it is 1 - there is a logical $$X$$ error. Is this is the same case here, just one needs to consider the data qubits at all time, so instead of $$3$$ we will have 9 such qubits, and we again sum their errors modulo 2?

• What do you mean by "capping"?
– AG47
Commented Apr 16 at 8:57
• @AG47 I refer to the fact that the last stabilizer round assumes to be perfect, but one adds a node to the syndrome graph there anyway Commented Apr 16 at 9:35

For each stabilizer (i.e. each ancilla qubit), there will indeed be three nodes in the syndrome graph: between layer 1 and 2, between layer 2 and 3 and between layer 3 and stabilizer reconstruction. Indeed, at the very end of your computation, you have to measure all your data qubits, turning effectively any measurement error occuring at this step into a data error. From these measures, you reconstruct the measurement outcome of the stabilizers by parity checking and deduce the value associated to the nodes in the last layer of the syndrome graph. This final round is what makes "the last stabilizer round is assumed to be perfect" legitimate.

Each node of the syndrome graph is connected by one or two time-like edges to the nodes associated with the same stabilizer that came immediately before and after it. Nodes of the first layer that corresponds to deterministic stabilizer measurement are also linked to imaginary nodes from a perfect 0th round i.e. you place a defect in the first layer in case you read an unexpected result. This is the time-like boundary of your syndrome decoding graph.

In the spatial direction (i.e. in each layer), nodes are connected by space-like edges if their associated stabilizers have intersecting supports (they share some data qubits).

If you have an initialization error in the bulk of the code (not on the boundary), it will flip two stabilizers. Note that the same syndrome at this layer can be seen if two neighboring measurement errors happened instead. However, unless the same measurement errors keep happening until the end, their will be another layer where the same syndrome will occur. You will then either decide they were measurement errors (or two data errors on the same qubit) which is harmless. The same happens with boundary initialization errors.

If a measurement error happens at round 1, you will eventually be able to match it with some syndrome defect in a further round (either the measurement error chain stops, or your final data qubit measurement reveal it to you as a data error).

The smallest undetectable error will be an initialization error on a boundary data qubit where you track your logical state hidden by $$d$$ measurement errors. This is of weight $$d+1$$, which suggest layer 3 might not be necessary.

Regarding the logical operator, once you deduced a plausible set of error locations from the syndrome graph, you count how many times each data qubit of the logical $$Z$$ operator you track was flipped by them (i.e. you count how many space-like go over each data qubits). You finally decide that you should flip the logical outcome you got from the last measurement round if an odd number of data qubits were flipped an odd number of times.

• Thank yo very much! It is actually what I already did, but for some reason I don't get a threshold. I thought this is the problem, but maybe the it's somewhere else. Just regarding the measurement in round 1, I did not understand: suppose you have a measurement error in the ancilla of layer 1, and only there. Then, the syndrome node between layer 1 and 2 is the only one who detect it. But it can either correct the ancilla, which is good, or the data qubit of layer 1 (say on the spatial boundary), which is bad because it leads to a logical error with probability of a single qubit error p. Commented Apr 16 at 10:05
• You might be lacking a layer then. For the $Z$-stabilizers you should have a time-like boundary in your decoding graph. Since everything starts in $|0\rangle$, the first measured $Z$-stabilizers should have determinisitc measurement 1. This means your first nodes are not the difference between two measurement outcomes but the comparison to expected outcome 1. If you were to measure $X$-stabilizers as well, this layer wouldn't exist for them as their first measurement is random until the end of the first measurement round (at this moment only your are in the code space).
– AG47
Commented Apr 16 at 11:09
• What tool are you using for your simulation?
– AG47
Commented Apr 16 at 11:09
• Some home-made simulation, with Pymatching as a decoder. Anyway, you say that actually we have 4 layers in the syndrome graph, for the Z stabilizers. I'll try to see if that's works. Thanks Commented Apr 16 at 11:24
• Depending on your long-term goals, you might want to have a look at stim. It goes with some advantages such as interfacing with Pymatching and trouble-shooting your experiment (see e.g. this question that helps looking for low weight logical errors)
– AG47
Commented Apr 16 at 11:30