Skip to main contentIBM Quantum Documentation

DoWhileController

class qiskit.passmanager.DoWhileController(tasks=(), do_while=None, *, options=None)

GitHub

Bases: BaseController

Run the given tasks in a loop until the do_while condition on the property set becomes False.

The given tasks will always run at least once, and on iteration of the loop, all the tasks will be run (with the exception of a failure state being set).

Create new flow controller.

Parameters

options (dict[str, Any] | None) – Option for this flow controller.


Attributes

passes

Alias of tasks for backward compatibility.


Methods

execute

execute(passmanager_ir, state, callback=None)

GitHub

Execute optimization task for input Qiskit IR.

Parameters

  • passmanager_ir (Any) – Qiskit IR to optimize.
  • state (PassManagerState) – State associated with workflow execution by the pass manager itself.
  • callback (Callable | None) – A callback function which is caller per execution of optimization task.

Returns

Optimized Qiskit IR and state of the workflow.

Return type

tuple[Any, qiskit.passmanager.compilation_status.PassManagerState]

iter_tasks

iter_tasks(state)

GitHub

A custom logic to choose a next task to run.

Controller subclass can consume the state to build a proper task pipeline. The updated state after a task execution will be fed back in as the “return” value of any yield statements. This indicates the order of task execution is only determined at running time. This method is not allowed to mutate the given state object.

Parameters

  • state (PassManagerState) – The state of the passmanager workflow at the beginning of this flow controller’s execution.
  • state – the state of pass manager after the execution of the last task that was yielded. The generator does not need to inspect this if it is irrelevant to its logic, nor update it.

Yields

Task – Next task to run.

Return type

Generator[Task, PassManagerState, None]

Was this page helpful?
Report a bug or request content on GitHub.