Skip to content

Commit

Permalink
Remove initial layout default from level 1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtreinish committed Nov 11, 2021
1 parent 6d3e2d1 commit df47835
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
28 changes: 0 additions & 28 deletions qiskit/transpiler/preset_passmanagers/level1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit df47835

Please sign in to comment.