In Stim, an example circuit for rotated surface code is provided:
surface_code_circuit = stim.Circuit.generated(
"surface_code:rotated_memory_z",
rounds=3,
distance=3,
after_clifford_depolarization=0.001,
after_reset_flip_probability=0.001,
before_measure_flip_probability=0.001,
before_round_data_depolarization=0.001)
In this circuit, in the first round, the instructions
DETECTOR(0, 4, 0) rec[-4]
DETECTOR(2, 2, 0) rec[-7]
DETECTOR(4, 4, 0) rec[-2]
DETECTOR(6, 2, 0) rec[-5]
are inserted. I think these instructions correspond to the syndrome values of the Z-type stabilizers.
At the end of the circuit, the instructions
DETECTOR(0, 4, 1) rec[-3] rec[-6] rec[-13]
DETECTOR(2, 2, 1) rec[-5] rec[-6] rec[-8] rec[-9] rec[-16]
DETECTOR(4, 4, 1) rec[-1] rec[-2] rec[-4] rec[-5] rec[-11]
DETECTOR(6, 2, 1) rec[-4] rec[-7] rec[-14]
are inserted. I think these instructions correspond to the detectors for measurement errors in the final round of measuring Z-type stabilizers, i.e. time-like boundary nodes in the detector graph.
Now I have two questions:
1. In the middle of the circuit, the instructions
DETECTOR(2, 0, 0) rec[-8] rec[-16]
DETECTOR(2, 2, 0) rec[-7] rec[-15]
DETECTOR(4, 2, 0) rec[-6] rec[-14]
DETECTOR(6, 2, 0) rec[-5] rec[-13]
DETECTOR(0, 4, 0) rec[-4] rec[-12]
DETECTOR(2, 4, 0) rec[-3] rec[-11]
DETECTOR(4, 4, 0) rec[-2] rec[-10]
DETECTOR(4, 6, 0) rec[-1] rec[-9]
are inserted. It looks like these instructions define syndrome values of both X-type and Z-type as detectors. Here, we intend to decode only X errors, so we need detectors for only Z-type stabilizers. I do not understand why both X-type and Z-type detectors are included as detectors.
2.
In the rotated surface code, we need space-like boundary nodes in the detector graph, so we should define DETECTORs
that correspond to the space-like boundary nodes. It seems that those detectors are not included in the surface_code:rotated_memory_z
provided in Stim. Is there a reason of that, or am I misunderstanding something?