Skip to content

Commit

Permalink
Remove max_iteration keyword from append and replace
Browse files Browse the repository at this point in the history
  • Loading branch information
nkanazawa1989 committed Dec 20, 2023
1 parent b6b8887 commit 3b1161e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
37 changes: 4 additions & 33 deletions qiskit/transpiler/passmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from qiskit.passmanager.base_tasks import Task, BaseController, GenericPass
from qiskit.passmanager.flow_controllers import FlowControllerLinear
from qiskit.passmanager.exceptions import PassManagerError
from qiskit.utils.deprecation import deprecate_arg
from .basepasses import BasePass
from .exceptions import TranspilerError
from .layout import TranspileLayout
Expand Down Expand Up @@ -97,58 +96,32 @@ def _passmanager_backend(

return out_program

@deprecate_arg(
name="max_iteration",
since="0.25",
additional_msg="'max_iteration' can be set in the constructor.",
pending=True,
package_name="qiskit-terra",
)
def append(
self,
passes: Task | list[Task],
max_iteration: int = None,
) -> None:
"""Append a Pass Set to the schedule of passes.
Args:
passes: A set of passes (a pass set) to be added to schedule. A pass set is a list of
passes that are controlled by the same flow controller. If a single pass is
provided, the pass set will only have that pass a single element.
It is also possible to append a :class:`.BaseFlowController` instance and
the rest of the parameter will be ignored.
max_iteration: max number of iterations of passes.
passes: A set of transpiler passes to be added to schedule.
Raises:
TranspilerError: if a pass in passes is not a proper pass.
"""
if max_iteration:
self.max_iteration = max_iteration
super().append(passes)

@deprecate_arg(
name="max_iteration",
since="0.25",
additional_msg="'max_iteration' can be set in the constructor.",
pending=True,
package_name="qiskit-terra",
)
super().append(tasks=passes)

def replace(
self,
index: int,
passes: Task | list[Task],
max_iteration: int = None,
) -> None:
"""Replace a particular pass in the scheduler.
Args:
index: Pass index to replace, based on the position in passes().
passes: A pass set to be added to the pass manager schedule.
max_iteration: max number of iterations of passes.
"""
if max_iteration:
self.max_iteration = max_iteration
super().replace(index, passes)
super().replace(index, tasks=passes)

# pylint: disable=arguments-differ
def run(
Expand Down Expand Up @@ -382,15 +355,13 @@ def __setattr__(self, attr, value):
def append(
self,
passes: Task | list[Task],
max_iteration: int = None,
) -> None:
raise NotImplementedError

def replace(
self,
index: int,
passes: BasePass | list[BasePass],
max_iteration: int = None,
) -> None:
raise NotImplementedError

Expand Down
2 changes: 1 addition & 1 deletion test/python/transpiler/test_pass_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def test_nested_conditional_in_loop(self):
nested_conditional,
PassF_reduce_dag_property(),
],
do_while=lambda property_set: not property_set["property_fixed_point"]
do_while=lambda property_set: not property_set["property_fixed_point"],
)
)
expected = [
Expand Down
2 changes: 1 addition & 1 deletion test/python/transpiler/test_remove_reset_in_zero_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_two_resets(self):
pass_manager.append(
DoWhileController(
[RemoveResetInZeroState(), DAGFixedPoint()],
do_while=lambda property_set: not property_set["dag_fixed_point"]
do_while=lambda property_set: not property_set["dag_fixed_point"],
)
)
after = pass_manager.run(circuit)
Expand Down

0 comments on commit 3b1161e

Please sign in to comment.