pyqonvert.routing.insert_single_operation_swaps

pyqonvert.routing.insert_single_operation_swaps(circuit, device, swap_back, only_before_decomposition, initial_layout=None)

Insert SWAP operations in Circuit to enable operations on limited connectivity.

Noise mapping becomes difficult when circuit operations are remapped inside a Decomposition block. On the other hand swapping back after routing for each single operation is highly inefficient.

Often the majority of Decomposition blocks only involve one or two qubit operations. To save the amount of SWAPS and enable remapping without breaking noise mapping, the SWAPS can be inserted only before decomposition blocks that invovle one and two qubits and remapping all following operations. This is activated with the only_before_decomposition option. With this option the SWAPS will also be inserted as decomposition blocks which is necessary for noise mapping when the SWAPS occur between decomposition blocks.

Note that this can not route all operations in the Circuit (especially decomposition blocks involving more qubits in the first place). For full routing a second pass with swap_back=true is necessary.

Parameters:
  • circuit (Circuit) -- The circuit that is routed.

  • device (GenericDevice) -- The device determining the topology.

  • swap_back (bool) -- Whether to insert SWAPS to original layout or remap.

  • only_before_decomposition (bool) -- Only insert SWAPS before two qubit decomposition blocks.

Raises:
  • RuntimeError -- Could not convert inputs.

  • ValueError -- Could not find a suitable routing.

Returns:

The circuit with inserted SWAPs and the corresponding layout.

Return type:

(Circuit, Layout)