---
title: BasePassManager (v2.2)
description: API reference for qiskit.passmanager.BasePassManager in qiskit v2.2
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/2.2/qiskit.passmanager.BasePassManager
---

# BasePassManager

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

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/passmanager/passmanager.py#L33-L280)

Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC)

Pass manager base class.

Initialize an empty pass manager object.

**Parameters**

- **tasks** (*Task |* [*list*](https://docs.python.org/3/library/stdtypes.html#list)*\[Task]*) – A pass set to be added to the pass manager schedule.
- **max\_iteration** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The maximum number of iterations the schedule will be looped if the condition is not met.

## Methods

### append

`append(tasks)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/passmanager/passmanager.py#L57-L74)

Append tasks to the schedule of passes.

**Parameters**

**tasks** (*Task |* [*list*](https://docs.python.org/3/library/stdtypes.html#list)*\[Task]*) – A set of pass manager tasks to be added to schedule.

**Raises**

[**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – When any element of tasks is not a subclass of passmanager Task.

**Return type**

None

### remove

`remove(index)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/passmanager/passmanager.py#L96-L108)

Removes a particular pass in the scheduler.

**Parameters**

**index** ([*int*](https://docs.python.org/3/library/functions.html#int)) – Pass index to remove, based on the position in `passes()`.

**Raises**

[**PassManagerError**](/docs/api/qiskit/2.2/passmanager#qiskit.passmanager.PassManagerError "qiskit.passmanager.PassManagerError") – If the index is not found.

**Return type**

None

### replace

`replace(index, tasks)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/passmanager/passmanager.py#L76-L94)

Replace a particular pass in the scheduler.

**Parameters**

- **index** ([*int*](https://docs.python.org/3/library/functions.html#int)) – Task index to replace, based on the position in `tasks()`
- **tasks** (*Task |* [*list*](https://docs.python.org/3/library/stdtypes.html#list)*\[Task]*) – A set of pass manager tasks to be added to schedule.

**Raises**

- [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – When any element of tasks is not a subclass of passmanager Task.
- [**PassManagerError**](/docs/api/qiskit/2.2/passmanager#qiskit.passmanager.PassManagerError "qiskit.passmanager.PassManagerError") – If the index is not found.

**Return type**

None

### run

`run(in_programs, callback=None, num_processes=None, *, property_set=None, **kwargs)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/passmanager/passmanager.py#L172-L264)

Run all the passes on the specified `in_programs`.

**Parameters**

- **in\_programs** (*Any |* [*list*](https://docs.python.org/3/library/stdtypes.html#list)*\[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:

  ```python
  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:

  ```python
  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']
      ...
  ```

- **num\_processes** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The maximum number of parallel processes to launch if parallel execution is enabled. This argument overrides `num_processes` in the user configuration file, and the `QISKIT_NUM_PROCS` environment variable. If set to `None` the system default or local user configuration will be used.

- **property\_set** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict)*\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str)*,* [*object*](https://docs.python.org/3/library/functions.html#object)*] | None*) – If given, the initial value to use as the [`PropertySet`](/docs/api/qiskit/2.2/qiskit.passmanager.PropertySet "qiskit.passmanager.PropertySet") for the pass manager pipeline. This can be used to persist analysis from one run to another, in cases where you know the analysis is safe to share. Beware that some analysis will be specific to the input circuit and the particular [`Target`](/docs/api/qiskit/2.2/qiskit.transpiler.Target "qiskit.transpiler.Target"), so you should take a lot of care when using this argument.

- **kwargs** – Arbitrary arguments passed to the compiler frontend and backend.

**Returns**

The transformed program(s).

**Return type**

Any

### to\_flow\_controller

`to_flow_controller()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/passmanager/passmanager.py#L266-L274)

Linearize this manager into a single [`FlowControllerLinear`](/docs/api/qiskit/2.2/qiskit.passmanager.FlowControllerLinear "qiskit.passmanager.FlowControllerLinear"), so that it can be nested inside another pass manager.

**Returns**

A linearized pass manager.

**Return type**

[*FlowControllerLinear*](/docs/api/qiskit/2.2/qiskit.passmanager.FlowControllerLinear "qiskit.passmanager.flow_controllers.FlowControllerLinear")
