From df478357b9c59fe88f8d464c361de7a2e0c03976 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 11 Nov 2021 14:15:17 -0500 Subject: [PATCH] Remove initial layout default from level 1 Now that vf2 layout has limited noise awareness and multiple trials it no longer will be defaulting to the worst qubits like it was with only a single sample when vf2++ is used. This commit removes the implicit trivial layout attempt as it's no longer needed. --- .../transpiler/preset_passmanagers/level1.py | 28 ------------------- ...t-preset-passmanager-db46513a24e79aa9.yaml | 9 ++---- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/qiskit/transpiler/preset_passmanagers/level1.py b/qiskit/transpiler/preset_passmanagers/level1.py index a771f9a099b3..029fa3c96503 100644 --- a/qiskit/transpiler/preset_passmanagers/level1.py +++ b/qiskit/transpiler/preset_passmanagers/level1.py @@ -110,24 +110,6 @@ def level_1_pass_manager(pass_manager_config: PassManagerConfig) -> PassManager: def _choose_layout_condition(property_set): return not property_set["layout"] - def _trivial_not_perfect(property_set): - # Verify that a trivial layout is perfect. If trivial_layout_score > 0 - # the layout is not perfect. The layout is unconditionally set by trivial - # layout so we need to clear it before contuing. - if property_set["trivial_layout_score"] is not None: - if property_set["trivial_layout_score"] != 0: - property_set["layout"]._wrapped = None - return True - warnings.warn( - "The current implicit default of using a trivial layout if it's a " - "perfect layout will change in a future release, if you're " - "depending on this behavior it is better to explicit set " - "layout_method='trivial' when calling transpile()", - FutureWarning, - stacklevel=4, # stack_level=4 to target caller of transpile() - ) - return False - def _vf2_match_not_found(property_set): # If a layout hasn't been set by the time we run vf2 layout we need to # run layout @@ -147,15 +129,6 @@ def _vf2_match_not_found(property_set): vf2_seed = -1 _choose_layout_0 = ( - [] - if pass_manager_config.layout_method - else [ - TrivialLayout(coupling_map), - Layout2qDistance(coupling_map, property_name="trivial_layout_score"), - ] - ) - - _choose_layout_1 = ( [] if pass_manager_config.layout_method else VF2Layout( @@ -328,7 +301,6 @@ def _contains_delay(property_set): pm1.append(_unroll3q) pm1.append(_given_layout) pm1.append(_choose_layout_0, condition=_choose_layout_condition) - pm1.append(_choose_layout_1, condition=_trivial_not_perfect) pm1.append(_improve_layout, condition=_vf2_match_not_found) pm1.append(_embed) pm1.append(_swap_check) diff --git a/releasenotes/notes/vf2layout-preset-passmanager-db46513a24e79aa9.yaml b/releasenotes/notes/vf2layout-preset-passmanager-db46513a24e79aa9.yaml index 03fb5730a74d..0d48b8f3a48c 100644 --- a/releasenotes/notes/vf2layout-preset-passmanager-db46513a24e79aa9.yaml +++ b/releasenotes/notes/vf2layout-preset-passmanager-db46513a24e79aa9.yaml @@ -31,18 +31,13 @@ upgrade: unlike with optimization level 2 and 3 a trivial layout is attempted prior to running :class:`~qiskit.transpiler.passes.VF2Layout` and if it's a perfect mapping this will be used instead. -deprecations: - | For the preset pass manager for optimization level 1 (when calling :func:`~qiskit.compiler.transpile` with ``optimization_level=1`` or no ``optimization_level`` argument set) as generated by :func:`~qiskit.transpiler.preset_passmanagers.level_1_pass_manager` the implict default of running ::class:`~qiskit.transpiler.passes.TrivialLayout` - and using the trivial layout if it's a perfect match is deprecated - and this behavior will change in a future release. A ``FutureWarning`` is - now emitted whenever a trivial layout is used by default with optimization - level 1. This means that :func:`~qiskit.compiler.transpile` by default may - emit a ``FutureWarning`` if it picks a trivial layout as a result of this - current behavior. If this default towards a trivial layout is desired you + and using the trivial layout if it's a perfect match is no longer the + behavior. If this default towards a trivial layout is desired you can explicitly request it when transpiling by specifying ``layout_method="trivial"`` when calling :func:`~qiskit.compiler.transpile`.