Skip to content

Commit c6d52a0

Browse files
Lower limits on VF2PostLayout in exact mode (Qiskit#15068) (Qiskit#15075)
We currently run `VF2PostLayout(strict=True)` after the optimisation loop at optimisation level 3. We use the same values for `call_limit` and `max_trials` as we do for the averaging methods, but the averaging methods are pure Rust with no semantic matching, whereas the exact-match have Python-space semantic matching, so are far slower. We can look at raising the limits back to much higher values when these paths are in Rust and use the branch-and-bound scoring. (cherry picked from commit 7052dfe) Co-authored-by: Jake Lishman <[email protected]>
1 parent 7ecf1ed commit c6d52a0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

qiskit/transpiler/preset_passmanagers/builtin_plugins.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ def _unroll_condition(property_set):
616616
optimization_level,
617617
pass_manager_config.layout_method,
618618
pass_manager_config.initial_layout,
619+
exact_match=True,
619620
)
620621
is_vf2_fully_bounded = vf2_call_limit and vf2_max_trials
621622
if pass_manager_config.target is not None and is_vf2_fully_bounded:

qiskit/transpiler/preset_passmanagers/common.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ def get_vf2_limits(
728728
optimization_level: int,
729729
layout_method: Optional[str] = None,
730730
initial_layout: Optional[Layout] = None,
731+
exact_match: bool = False,
731732
) -> VF2Limits:
732733
"""Get the VF2 limits for VF2-based layout passes.
733734
@@ -739,13 +740,20 @@ def get_vf2_limits(
739740
if layout_method is None and initial_layout is None:
740741
if optimization_level in {1, 2}:
741742
limits = VF2Limits(
742-
int(5e4), # Set call limit to ~100ms with rustworkx 0.10.2
743-
2500, # Limits layout scoring to < 600ms on ~400 qubit devices
743+
50_000, # Set call limit to ~100ms with rustworkx 0.10.2
744+
2_500, # Limits layout scoring to < 600ms on ~400 qubit devices
744745
)
745746
elif optimization_level == 3:
746747
limits = VF2Limits(
747-
int(3e7), # Set call limit to ~60 sec with rustworkx 0.10.2
748-
250000, # Limits layout scoring to < 60 sec on ~400 qubit devices
748+
30_000_000, # Set call limit to ~60 sec with rustworkx 0.10.2
749+
250_000, # Limits layout scoring to < 60 sec on ~400 qubit devices
750+
)
751+
# In Qiskit 2.2, strict mode still includes heavy Python usage for the semantics and
752+
# scoring, so we dial the limits way down.
753+
if exact_match:
754+
limits = VF2Limits(
755+
((limits.call_limit // 100) or 1) if limits.call_limit is not None else None,
756+
((limits.max_trials // 100) or 1) if limits.max_trials is not None else None,
749757
)
750758
return limits
751759

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
upgrade_transpiler:
3+
- |
4+
The maximum call and trial limits for the exact-matching run of :class:`.VF2PostLayout` at
5+
``optimization_level=3`` have been reduced to avoid excessive runtimes for highly symmetric
6+
trial circuits being mapped to large coupling maps.

0 commit comments

Comments
 (0)