Quantum Circuit Compilation#

The main functionality for mapping quantum circuits is the compile method.

Note

This method assumes that the input quantum circuit is already decomposed into elementary gates for the specified architecture.

compile(circ, arch, calibration=None, method='heuristic', heuristic='gate_count_max_distance', initial_layout='dynamic', iterative_bidirectional_routing_passes=None, layering='individual_gates', automatic_layer_splits_node_limit=5000, early_termination='none', early_termination_limit=0, lookahead_heuristic='gate_count_max_distance', lookaheads=15, lookahead_factor=0.5, use_teleportation=False, teleportation_fake=False, teleportation_seed=0, encoding='commander', commander_grouping='fixed3', swap_reduction='coupling_limit', swap_limit=0, include_WCNF=False, use_subsets=True, subgraph=None, pre_mapping_optimizations=True, post_mapping_optimizations=True, add_measurements_to_mapped_circuit=True, add_barriers_between_layers=False, verbose=False, debug=False, visualizer=None)[source]#

Interface to the MQT QMAP tool for mapping quantum circuits.

Parameters:
  • circ (QuantumCircuit | str) – The circuit to map.

  • arch (str | Arch | Architecture | Backend | None) – The architecture to map to.

  • calibration (str | BackendProperties | Target | None) – The calibration to use.

  • method (str | Method) – The mapping method to use. Either “heuristic” or “exact”. Defaults to “heuristic”.

  • heuristic (str | Heuristic) – The heuristic function to use for the routing search. Defaults to “gate_count_max_distance”.

  • initial_layout (str | InitialLayout) – The initial layout to use. Defaults to “dynamic”.

  • iterative_bidirectional_routing_passes (int | None) – Number of iterative bidirectional routing passes to perform or None to disable. Defaults to None.

  • layering (str | Layering) – The layering strategy to use. Defaults to “individual_gates”.

  • automatic_layer_splits_node_limit (int | None) – The number of expanded nodes after which to split a layer or None to disable automatic layer splitting. Defaults to 5000.

  • early_termination (str | EarlyTermination) – The early termination strategy to use, i.e. terminating the search after a goal node has been found, but before it is guarantueed to be optimal. Defaults to “none”.

  • early_termination_limit (int) – The number of nodes (counted according to the early termination strategy) after which to terminate the search early. Defaults to 0.

  • lookahead_heuristic (str | LookaheadHeuristic | None) – The heuristic function to use as a lookahead penalty during search or None to disable lookahead. Defaults to “gate_count_max_distance”.

  • lookaheads (int) – The number of lookaheads to be used or None if no lookahead should be used. Defaults to 15.

  • lookahead_factor (float) – The rate at which the contribution of future layers to the lookahead decreases. Defaults to 0.5.

  • encoding (str | Encoding) – The encoding to use for the AMO and exactly one constraints. Defaults to “naive”.

  • commander_grouping (str | CommanderGrouping) – The grouping strategy to use for the commander and bimander encoding. Defaults to “halves”.

  • swap_reduction (str | SwapReduction) – The swap reduction strategy to use. Defaults to “coupling_limit”.

  • swap_limit (int) – Set a custom limit for max swaps per layer, for the increasing reduction strategy it sets the max swaps per layer. Defaults to 0.

  • include_WCNF (bool) – Include WCNF file in the results. Defaults to False.

  • use_subsets (bool) – Use qubit subsets, or consider all available physical qubits at once. Defaults to True.

  • subgraph (set[int] | None) – List of qubits to consider for mapping (in exact mapper), if None all qubits are considered. Defaults to None.

  • use_teleportation (bool) – Use teleportation in addition to swaps. Defaults to False.

  • teleportation_fake (bool) – Assign qubits as ancillary for teleportation in the initial placement but don’t actually use them (used for comparisons). Defaults to False.

  • teleportation_seed (int) – Fix a seed for the RNG in the initial ancilla placement (0 means the RNG will be seeded from /dev/urandom/ or similar). Defaults to 0.

  • pre_mapping_optimizations (bool) – Run pre-mapping optimizations. Defaults to True.

  • post_mapping_optimizations (bool) – Run post-mapping optimizations. Defaults to True.

  • add_measurements_to_mapped_circuit (bool) – Whether to add measurements at the end of the mapped circuit. Defaults to True.

  • add_barriers_between_layers (bool) – Whether to add barriers between layers to make them apparent after mapping. Defaults to False.

  • verbose (bool) – Print more detailed information during the mapping process. Defaults to False.

  • debug (bool) – Gather additional information during the mapping process (e.g. number of generated nodes, branching factors, …). Defaults to False.

  • visualizer (SearchVisualizer | None) – A SearchVisualizer object to log the search process to. Defaults to None.

Returns:

tuple[QuantumCircuit, MappingResults] – The mapped circuit and the mapping results.

Compile Setting Enumerations#

The following classes provide a more explicit way of initializing the respective parameters of the compile method. Instead of setting parameters via str members, they can be set with Enumeration.member where Enumeration is the enumeration class.

class Method#

Members:

heuristic

exact

class Heuristic#

Members:

gate_count_max_distance

gate_count_sum_distance

gate_count_sum_distance_minus_shared_swaps

gate_count_max_distance_or_sum_distance_minus_shared_swaps

fidelity_best_location

class LookaheadHeuristic#

Members:

none

gate_count_max_distance

gate_count_sum_distance

class Layering#

Members:

individual_gates

disjoint_qubits

odd_gates

qubit_triangle

disjoint_2q_blocks

class InitialLayout#

Members:

identity

static

dynamic

class Encoding#

Members:

naive

commander

bimander

class CommanderGrouping#

Members:

fixed2

fixed3

halves

logarithm

class SwapReduction#

Members:

none

coupling_limit

custom

increasing