surface_sim.detectors.Detectors.build_from_data#

detectors.Detectors.build_from_data(get_rec, anc_support, anc_reset, reconstructable_stabs, anc_qubits=None)#

Returns the stim circuit with the corresponding detectors given that the data qubits have been measured.

Note that the detectors for the "pre-gate" and "post-gate" frames are both constructed in the "post-gate" frame! See section Notes for more explanation.

Parameters:
get_rec

Function that given qubit_label, rel_meas_id returns the target_rec integer. The intention is to give the Model.meas_target method.

anc_support

Dictionary descriving the data qubit support on the stabilizers. The keys are the ancilla qubits and the values are the collection of data qubits. See surface_sim.Layout.get_support for more information.

anc_reset

Flag for if the ancillas are being reset in every QEC round.

reconstructable_stabs

Stabilizers that can be reconstructed from the data qubit outcomes.

anc_qubits

List of the ancilla qubits for which to build the detectors. By default, builds all the detectors.

Returns:
detectors_stim

Detectors defined in a stim circuit.

Notes

The reason that the detectors in the "pre-gate" frame are built in the "post-gate" frame is that there can be situations in which the detectors cannot be built in the "pre-gate" frame. For example,

R 0 1 TICK CX 0 1 M 0

As there is no QEC round performed in (logical) qubit 1 and the stabilizer generators of qubit 0 are propagated to qubit 1, we cannot build the detectors in the "pre-gate" frame.

Note that if one always performs (at least) one QEC round after each logical gate, then there is no difference in building the detectors for the measurement in the "pre-gate" or in the "post-gate" frame as one will always have:

TICK M 0