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

BasePassManager

class qiskit.passmanager.BasePassManager(tasks=(), max_iteration=1000)

GitHub(opens in a new tab)

Bases: ABC(opens in a new tab)

Pass manager base class.

Initialize an empty pass manager object.

Parameters

  • tasks (Task | list(opens in a new tab)[Task]) – A pass set to be added to the pass manager schedule.
  • max_iteration (int(opens in a new tab)) – The maximum number of iterations the schedule will be looped if the condition is not met.

Methods

append

append(tasks)

Append tasks to the schedule of passes.

Parameters

tasks (Task | list(opens in a new tab)[Task]) – A set of pass manager tasks to be added to schedule.

Raises

TypeError(opens in a new tab) – When any element of tasks is not a subclass of passmanager Task.

remove

remove(index)

Removes a particular pass in the scheduler.

Parameters

index (int(opens in a new tab)) – Pass index to remove, based on the position in passes().

Raises

PassManagerError – If the index is not found.

replace

replace(index, tasks)

Replace a particular pass in the scheduler.

Parameters

Raises

run

run(in_programs, callback=None, **kwargs)

Run all the passes on the specified in_programs.

Parameters

  • in_programs (Any | list(opens in a new tab)[Any]) – Input programs to transform via all the registered passes. A single input object cannot be a Python builtin list object. A list object is considered as multiple input objects to optimize.

  • callback (Callable) –

    A callback function that will be called after each pass execution. The function will be called with 4 keyword arguments:

    task (GenericPass): the pass being run
    passmanager_ir (Any): depending on pass manager subclass
    property_set (PropertySet): the property set
    running_time (float): the time to execute the pass
    count (int): the index for the pass execution

    The exact arguments pass expose the internals of the pass manager and are subject to change as the pass manager internals change. If you intend to reuse a callback function over multiple releases be sure to check that the arguments being passed are the same.

    To use the callback feature you define a function that will take in kwargs dict and access the variables. For example:

    def callback_func(**kwargs):
        task = kwargs['task']
        passmanager_ir = kwargs['passmanager_ir']
        property_set = kwargs['property_set']
        running_time = kwargs['running_time']
        count = kwargs['count']
        ...
  • kwargs – Arbitrary arguments passed to the compiler frontend and backend.

Returns

The transformed program(s).

Return type

Any

to_flow_controller

to_flow_controller()

Linearize this manager into a single FlowControllerLinear, so that it can be nested inside another pass manager.

Returns

A linearized pass manager.

Return type

FlowControllerLinear

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