---
title: PassManager (latest version)
description: API reference for qiskit.transpiler.PassManager in the latest version of qiskit
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/qiskit.transpiler.PassManager
---

# PassManager

*class* `qiskit.transpiler.PassManager(passes=(), max_iteration=1000)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/transpiler/passmanager.py#L37-L233)

Bases: [`BasePassManager`](/docs/api/qiskit/qiskit.passmanager.BasePassManager "qiskit.passmanager.passmanager.BasePassManager")

Manager for a set of Passes and their scheduling during transpilation.

Initialize an empty pass manager object.

**Parameters**

- **passes** (*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(passes)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/transpiler/passmanager.py#L99-L111)

Append a Pass Set to the schedule of passes.

**Parameters**

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

**Raises**

[**TranspilerError**](/docs/api/qiskit/transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") – if a pass in passes is not a proper pass.

**Return type**

None

### draw

`draw(filename=None, style=None, raw=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/transpiler/passmanager.py#L204-L233)

Draw the pass manager.

This function needs [pydot](https://github.com/erocarrera/pydot), which in turn needs [Graphviz](https://www.graphviz.org/) to be installed.

> **Warning**
>
> This function will call the system Graphviz tool on a file involving user-controllable strings (such as pass names). It is recommended to only call this function on trusted input.

**Parameters**

- **filename** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – file path to save image to.
- **style** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict)) – keys are the pass classes and the values are the colors to make them. An example can be seen in the DEFAULT\_STYLE. An ordered dict can be used to ensure a priority coloring when pass falls into multiple categories. Any values not included in the provided dict will be filled in from the default dict.
- **raw** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If `True`, save the raw Dot output instead of the image.

**Returns**

an in-memory representation of the pass manager, or `None` if no image was generated or [Pillow](https://pypi.org/project/Pillow/) is not installed.

**Return type**

Optional\[[PassManager](#qiskit.transpiler.PassManager "qiskit.transpiler.PassManager")]

**Raises**

[**ImportError**](https://docs.python.org/3/library/exceptions.html#ImportError) – when nxpd or pydot not installed.

### remove

`remove(index)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/passmanager/passmanager.py#L97-L109)

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()`](/docs/api/qiskit/transpiler_passes#module-qiskit.transpiler.passes "qiskit.transpiler.passes").

**Raises**

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

**Return type**

None

### replace

`replace(index, passes)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/transpiler/passmanager.py#L113-L124)

Replace a particular pass in the scheduler.

**Parameters**

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

**Return type**

None

### run

`run(circuits, output_name=None, callback=None, num_processes=None, *, property_set=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/transpiler/passmanager.py#L126-L202)

Run all the passes on the specified `circuits`.

**Parameters**

- **circuits** (*\_CircuitsT*) – Circuit(s) to transform via all the registered passes.

- **output\_name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str) *| None*) – The output circuit name. If `None`, it will be set to the same as the input circuit name.

- **callback** ([*Callable*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable) *| None*) –

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

  ```python
  pass_ (Pass): the pass being run
  dag (DAGCircuit): the dag output of the pass
  time (float): the time to execute the pass
  property_set (PropertySet): the property set
  count (int): the index for the pass execution
  ```

  > **Note**
  >
  > Beware that the keyword arguments here are different to those used by the generic [`BasePassManager`](/docs/api/qiskit/qiskit.passmanager.BasePassManager "qiskit.passmanager.BasePassManager"). This pass manager will translate those arguments into the form described above.

  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):
      pass_ = kwargs['pass_']
      dag = kwargs['dag']
      time = kwargs['time']
      property_set = kwargs['property_set']
      count = kwargs['count']
      ...
  ```

  > **Note**
  >
  > When running transpilation with multi-processing, the callback function is invoked within the context of each sub-process, independently of the parent process.

- **num\_processes** ([*int*](https://docs.python.org/3/library/functions.html#int) *| None*) – 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/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/qiskit.transpiler.Target "qiskit.transpiler.Target"), so you should take a lot of care when using this argument.

**Returns**

The transformed circuit(s).

**Return type**

*\_CircuitsT*

### to\_flow\_controller

`to_flow_controller()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/passmanager/passmanager.py#L267-L275)

Linearize this manager into a single [`FlowControllerLinear`](/docs/api/qiskit/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/qiskit.passmanager.FlowControllerLinear "qiskit.passmanager.flow_controllers.FlowControllerLinear")\[*IR*, *IR*]
