From f2e4aebc9941e4b3ce2b7f88202973ad2351f493 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 23 Oct 2024 10:59:35 -0400 Subject: [PATCH] Add more default trials to sabre layout Right now sabre layout uses n random trials (as specified by the user or defaulting to num_cpus) and since #12453 one additional trial taking the qubits of the densest subgraph as a starting point. There are also a couple of other trivial examples to try which may or may not produce better results depending on the circuit, a trivial layout and a reverse trivial layout. In the case of a hardware efficient circuit the trivial layout will map exactly and would always be picked. When running in a preset pass manager sabre should never be called in this scenario because VF2Layout will find the mapping, but the incremental cost of adding the trial is minimal. Similarly the cost of a reversed trivial layout (where virtual qubit 0 -> n, 1 -> n - 1, etc.) is trivial and may in some scenarios produce a better results. --- crates/accelerate/src/sabre/layout.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/accelerate/src/sabre/layout.rs b/crates/accelerate/src/sabre/layout.rs index 5ea568559119..b3f2b35269cd 100644 --- a/crates/accelerate/src/sabre/layout.rs +++ b/crates/accelerate/src/sabre/layout.rs @@ -62,6 +62,8 @@ pub fn sabre_layout_and_routing( &target, run_in_parallel, )); + starting_layouts.push((0..dag.num_qubits as u32).map(Some).collect()); + starting_layouts.push((0..dag.num_qubits as u32).rev().map(Some).collect()); let outer_rng = match seed { Some(seed) => Pcg64Mcg::seed_from_u64(seed), None => Pcg64Mcg::from_entropy(),