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?