surface_sim.util.merge_logical_operations#

merge_logical_operations(op_iterators, model, detectors, num_prev_meas=None, anc_reset=None, anc_detectors=None, meas_to_obs=None)[source]#

Returns a circuit in which the given logical operation iterators have been merged and idle noise have been added if the iterators have different lenght.

Parameters:
op_iterators

List of logical operations to merge represented as a tuple of the operation function iterator and the layout(s) to be applied to. The functions need to have (model, *layouts) as signature. There must be an entry for each layout except if it is participating in a two-qubit gate, then there must be one entry per pair. Each layout can only appear once, i.e. it can only perform one operation. The TICK instructions must appear at the same time in all iterators when iterating through them.

model

Noise model for the gates.

detectors

Detector definitions to use.

num_prev_meas

Number of logical measurements already included in the circuit. It is used in the definition of the observables. If meas_to_obs is None, an observable is defined for each measurement with observable index starting from num_prev_meas.

anc_reset

If True, ancillas are reset at the beginning of the QEC round.

anc_detectors

List of ancilla qubits for which to define the detectors. If None, adds all detectors. By default None.

meas_to_obs

Dictionary with keys corresponding to the logical measurement indices and values corresponding to the observable indices that the measurement has support on. Note that one only needs to specify the logical measurements involved in the given layer of operations. By default, it defines an observable for every logical measurement.

Returns:
circuit

Circuit from merging the given iterators. The circuit includes an observable for each logical measurement operation.