tqecd.fragment.split_stim_circuit_into_fragments#

split_stim_circuit_into_fragments(circuit: Circuit) list[Fragment | FragmentLoop][source]#

Split the circuit into fragments.

The provided circuit should check a few pre-conditions:

  • If there is one measurement (resp. reset) instruction between two TICK annotation, then no reset (resp. measurement) instruction should appear between these two TICK.

  • The circuit should be (recursively if it contains one or more instance of stim.CircuitRepeatBlock) composed of a succession of layers that should have the same shape:

    • starts with zero or more moments containing reset and non-measurement operations,

    • continuing with zero or more moments containing any non-collapsing operation (i.e., anything except reset and measurement operations).

    • ends with one moment containing measurement and non-reset operations.

    For the above reasons, be careful with reset/measurement combined operations (e.g., the stim instruction MR that performs in one instruction a measurement and a reset in the Z basis). These instructions are not supported by the tqec library and it is up to the user to check that the input circuit does not contain combined measurements/resets instructions.

Parameters:

circuit (stim.Circuit) – the circuit to split into Fragment instances.

Raises:
  • TQECDException – If the circuit contains at least one moment (i.e., group of instructions between two TICK annotations) that are composed of both measurement and reset instructions.

  • TQECDException – If the circuit contains combined measurement/reset instructions.

  • TQECDException – If the provided circuit could not be split into fragments due to an invalid structure.

Returns:

the resulting fragments.