iqm.qrisp_iqm.passes.routing.core.sabre_meta_functions.sabre_gen_swaps_parallel#
- iqm.qrisp_iqm.passes.routing.core.sabre_meta_functions.sabre_gen_swaps_parallel(topology: QPUTopology, instruction_dag: CircuitDAG, greediness: int, max_instruction: int, threads: int, depth_array: ndarray, tempering_range: int = 3, congestion_penalty: float = 0.0, selection_exponent: float = 0.0, seed: int = 0) tuple[list[tuple[int16, int16, int16]], ndarray]#
Execute sabre_gen_swaps in parallel with different seeds and greediness values.
Uses parallel tempering across threads, then selects the trial with the lowest score. The score is a weighted geometric mean of swap count and 2-qubit depth:
score = swaps^(1 - e) * depth^e
When
selection_exponentis 0 (default) the selection is purely by swap count; when 1.0 it is purely by depth.- Parameters:
topology (QPUTopology) – Available gates.
instruction_dag (CircuitDAG) – Quantum circuit in DAG format.
greediness (int) – Controls swap selection randomness. The algorithm will skip the best swap candidate with probability 1/greediness. Higher values mean more greedy (deterministic) behavior.
max_instruction (int) – The sabre_gen_swaps will only compile until this threshold is reached.
threads (int) – The amount of instances that should be executed in parallel (recommended to be an integer multiple of the CPU count).
depth_array (ndarray) – Per-physical-qubit depth array. Carried across sections so that depth accounting is continuous. Each parallel trial receives a copy.
tempering_range (int) – Controls parallel tempering. When > 0, each thread uses a different greediness value spread across [max(2, greediness - tempering_range), greediness + tempering_range]. This gives different threads different exploration/exploitation tradeoffs (analogous to running replicas at different temperatures in simulated annealing). When 0, all threads use the same greediness.
congestion_penalty (float) – Strength of the per-physical-qubit congestion penalty in swap scoring. Forwarded to sabre_gen_swaps. 0.0 disables.
selection_exponent (float) – Blending weight for the geometric-mean selection metric (0.0–1.0). 0.0 selects purely by swap count, 1.0 purely by depth.
seed (int) – Base seed for the random number generation. Each parallel thread derives its own seed as
seed + i*173 + 1.
- Returns:
Compiled instructions from the trial with the lowest score. SWAPs have instr_index = -1.
Final logical-to-physical qubit mapping of the best solution. The dtype is inherited from the topology (int16 on NISQ-scale devices).
- Return type: