Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

ConditionalController

class qiskit.passmanager.ConditionalController(tasks=(), condition=None, *, options=None)

GitHub(opens in a new tab)

Bases: BaseController

A flow controller runs the pipeline once if the condition is true, or does nothing if the condition is false.

Create new flow controller.

Parameters

options (dict(opens in a new tab)[str(opens in a new tab), Any] | None) – Option for this flow controller.


Attributes

passes

Alias of tasks for backward compatibility.


Methods

append

append(passes)

Add new task to pipeline.

Deprecated since version 0.45.0

The method qiskit.passmanager.flow_controllers.ConditionalController.append() is deprecated as of qiskit 0.45.0. It will be removed no earlier than 3 months after the release date. All tasks must be provided at construction time of the controller object.

Parameters

passes (Task | list(opens in a new tab)[Task]) – A new task or list of tasks to add.

execute

execute(passmanager_ir, state, callback=None)

Execute optimization task for input Qiskit IR.

Parameters

Returns

Optimized Qiskit IR and state of the workflow.

Return type

tuple(opens in a new tab)[Any(opens in a new tab), qiskit.passmanager.compilation_status.PassManagerState]

iter_tasks

iter_tasks(state)

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(opens in a new tab)[Task, PassManagerState, None]

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