surface_sim.util.merge_operation_layers#

merge_operation_layers(*operation_layers)[source]#

Merges operation layers acting on different qubits to simplify the final circuit. It tries to merge the different blocks if they have the same sequence of operations and noise channels, if not, blocks are stacked together. This ensures that the output circuit has the same effect as the stacking of all blocks.

Parameters:
operation_layers

Each operation layer is a stim.Circuit acting on different qubits. A valid operation layer is a stim.Circuit in which the qubits perform exactly one operation (without including noise channels).

Returns:
merged_blocks

A stim.Circuit having the same effect as stacking all the given operation layers.

Notes

The instructions in merged_blocks have been (correctly) merged so that the lenght of the output circuit is minimal. Correctly means that the order of the instructions has not been changed in a way that changes the output of the circuit.