Skip to content

Commit

Permalink
Remove deprecated feature in 0.45 in unroller (#11581)
Browse files Browse the repository at this point in the history
* Removed unroller

* Additional removals where unroller appears

* Fix lint and remove unroller test

* Fixed test_controlled_gate

* Fix test_preset_passmanagers

* Fixed lint

* Fixed test_circuit_methods

* Fixed lint

* Fixed lint again

* Fixed test_circuit_methods again

* Fixed test_pass_manager_drawer

* Undo change in requirements.txt

* Fix test_controlled_gate

* Updated release note

* Fix test_circuit_methods

* Update releasenotes/notes/remove-deprecated-unroller-4693330708c681e0.yaml

Co-authored-by: Julien Gacon <[email protected]>

* Reverted change to requirements

* Added seperate function for equality check to test_controlled_gate

* Fixed requirements.txt

---------

Co-authored-by: Julien Gacon <[email protected]>
  • Loading branch information
henryzou50 and Cryoris authored Jan 30, 2024
1 parent 8002a3e commit cfb13c9
Show file tree
Hide file tree
Showing 22 changed files with 179 additions and 1,177 deletions.
9 changes: 0 additions & 9 deletions qiskit/compiler/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,6 @@ def callback_func(**kwargs):
target = copy.deepcopy(target)
target.update_from_instruction_schedule_map(inst_map)

if translation_method == "unroller":
warnings.warn(
"The 'unroller' translation_method plugin is deprecated as of Qiskit 0.45.0 and "
"will be removed in a future release. Instead you should use the default "
"'translator' method or another plugin.",
DeprecationWarning,
stacklevel=2,
)

if not ignore_backend_supplied_default_methods:
if scheduling_method is None and hasattr(backend, "get_scheduling_stage_plugin"):
scheduling_method = backend.get_scheduling_stage_plugin()
Expand Down
2 changes: 0 additions & 2 deletions qiskit/transpiler/passes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
TranslateParameterizedGates
Unroll3qOrMore
UnrollCustomDefinitions
Unroller
Optimizations
=============
Expand Down Expand Up @@ -204,7 +203,6 @@

# basis change
from .basis import Decompose
from .basis import Unroller
from .basis import UnrollCustomDefinitions
from .basis import Unroll3qOrMore
from .basis import BasisTranslator
Expand Down
1 change: 0 additions & 1 deletion qiskit/transpiler/passes/basis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"""Module containing basis change passes."""

from .decompose import Decompose
from .unroller import Unroller
from .unroll_custom_definitions import UnrollCustomDefinitions
from .unroll_3q_or_more import Unroll3qOrMore
from .basis_translator import BasisTranslator
Expand Down
145 changes: 0 additions & 145 deletions qiskit/transpiler/passes/basis/unroller.py

This file was deleted.

19 changes: 5 additions & 14 deletions qiskit/transpiler/preset_passmanagers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,11 @@ def generate_preset_pass_manager(
You can see a list of installed plugins by using :func:`~.list_stage_plugins` with
``"routing"`` for the ``stage_name`` argument.
translation_method (str): The method to use for translating gates to
basis gates. Valid choices ``'unroller'``, ``'translator'``, ``'synthesis'``
representing :class:`~.Unroller`, :class:`~.BasisTranslator`, and
:class:`~.UnitarySynthesis` respectively. This can also be the external plugin
name to use for the ``translation`` stage of the output :class:`~.StagedPassManager`.
You can see a list of installed plugins by using :func:`~.list_stage_plugins` with
``"translation"`` for the ``stage_name`` argument.
basis gates. Valid choices ``'translator'``, ``'synthesis'`` representing
:class:`~.BasisTranslator`, and :class:`~.UnitarySynthesis` respectively. This can
also be the external plugin name to use for the ``translation`` stage of the output
:class:`~.StagedPassManager`. You can see a list of installed plugins by using
:func:`~.list_stage_plugins` with ``"translation"`` for the ``stage_name`` argument.
scheduling_method (str): The pass to use for scheduling instructions. Valid choices
are ``'alap'`` and ``'asap'``. This can also be the external plugin name to use
for the ``scheduling`` stage of the output :class:`~.StagedPassManager`. You can
Expand Down Expand Up @@ -205,14 +204,6 @@ def generate_preset_pass_manager(
Raises:
ValueError: if an invalid value for ``optimization_level`` is passed in.
"""
if translation_method == "unroller":
warnings.warn(
"The 'unroller' translation_method plugin is deprecated as of Qiskit 0.45.0 and "
"will be removed in a future release. Instead you should use the default "
"'translator' method or another plugin.",
DeprecationWarning,
stacklevel=2,
)

if coupling_map is not None and not isinstance(coupling_map, CouplingMap):
coupling_map = CouplingMap(coupling_map)
Expand Down
17 changes: 0 additions & 17 deletions qiskit/transpiler/preset_passmanagers/builtin_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,6 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
)


class UnrollerPassManager(PassManagerStagePlugin):
"""Plugin class for translation stage with :class:`~.BasisTranslator`"""

def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager:
return common.generate_translation_passmanager(
pass_manager_config.target,
basis_gates=pass_manager_config.basis_gates,
method="unroller",
approximation_degree=pass_manager_config.approximation_degree,
coupling_map=pass_manager_config.coupling_map,
backend_props=pass_manager_config.backend_properties,
unitary_synthesis_method=pass_manager_config.unitary_synthesis_method,
unitary_synthesis_plugin_config=pass_manager_config.unitary_synthesis_plugin_config,
hls_config=pass_manager_config.hls_config,
)


class UnitarySynthesisPassManager(PassManagerStagePlugin):
"""Plugin class for translation stage with :class:`~.BasisTranslator`"""

Expand Down
7 changes: 2 additions & 5 deletions qiskit/transpiler/preset_passmanagers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from qiskit.passmanager.flow_controllers import ConditionalController
from qiskit.transpiler.passmanager import PassManager
from qiskit.transpiler.passes import Error
from qiskit.transpiler.passes import Unroller
from qiskit.transpiler.passes import BasisTranslator
from qiskit.transpiler.passes import Unroll3qOrMore
from qiskit.transpiler.passes import Collect2qBlocks
Expand Down Expand Up @@ -65,7 +64,7 @@
working={"none", "stochastic", "sabre"}, not_working={"lookahead", "basic"}
),
"translation_method": _ControlFlowState(
working={"translator", "synthesis", "unroller"},
working={"translator", "synthesis"},
not_working=set(),
),
"optimization_method": _ControlFlowState(working=set(), not_working=set()),
Expand Down Expand Up @@ -447,9 +446,7 @@ def generate_translation_passmanager(
Raises:
TranspilerError: If the ``method`` kwarg is not a valid value
"""
if method == "unroller":
unroll = [Unroller(basis=basis_gates, target=target)]
elif method == "translator":
if method == "translator":
unroll = [
# Use unitary synthesis for basis aware decomposition of
# UnitaryGates before custom unrolling
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
upgrade:
- |
Removes the deprecated ``Unroller`` class in :mod:`qiskit.transpiler.passes.basis`.
This class was deprecated in Qiskit Terra 0.45 and has been replaced by
the combination usage of :class:`.BasisTranslator` and :class:`.UnrollCustomDefinitions`.
Note that :class:`.BasisTranslator` and :class:`.UnrollCustomDefinitions` take different
arguments than ``Unroller``, as they requires a `EquivalenceLibrary` object to be passed in.
Where previously ``Unroller(basis_gates)`` could be used,
you can now use::
from qiskit.circuit.library.standard_gates.equivalence_library import (
StandardEquivalenceLibrary as std_eqlib,
)
pm = PassManager([
UnrollCustomDefinitions(std_eqlib, basis_gates)
BasisTranslator(std_eqlib, basis_gates),
])
translated = pm.run(circuit)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ dill>=0.3
python-dateutil>=2.8.0
stevedore>=3.0.0
typing-extensions
symengine>=0.11
symengine>=0.11
22 changes: 0 additions & 22 deletions test/benchmarks/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,6 @@ def time_commutative_cancellation(self, _, __):
_pass.run(self.dag)


class UnrolledPassBenchmarks:
params = ([5, 14, 20], [1024])

param_names = ["n_qubits", "depth"]
timeout = 300

def setup(self, n_qubits, depth):
seed = 42
self.circuit = random_circuit(
n_qubits, depth, measure=True, conditional=True, reset=True, seed=seed
)
self.dag = circuit_to_dag(self.circuit)
self.basis_gates = ["u1", "u2", "u3", "cx", "id"]
self.unrolled_dag = Unroller(self.basis_gates).run(self.dag)

def time_optimize_1q(self, _, __):
Optimize1qGates().run(self.unrolled_dag)


class MultipleBasisPassBenchmarks:
params = (
[5, 14, 20],
Expand Down Expand Up @@ -125,9 +106,6 @@ def setup(self, n_qubits, depth):
self.dag = circuit_to_dag(self.circuit)
self.basis_gates = ["u1", "u2", "u3", "cx", "id"]

def time_unroller(self, _, __):
Unroller(self.basis_gates).run(self.dag)

def time_depth_pass(self, _, __):
Depth().run(self.dag)

Expand Down
Loading

0 comments on commit cfb13c9

Please sign in to comment.