PassManager#
- class PassManager(passes: list[CircuitPass] | None = None)[source]#
A manager for organizing and applying quantum circuit transformation passes.
The PassManager maintains an ordered list of
CircuitPassinstances and applies them sequentially to quantum circuits.Only
CircuitPassinstances are accepted — raw functions must be wrapped first, for example with the@CircuitPassdecorator or by callingCircuitPass(my_func).Examples
Build a pipeline with
+=, then inspect, insert, and remove passes:>>> from qrisp import PassManager >>> from qrisp import convert_to_cz, fuse_adjacents, remove_barriers >>> >>> pm = PassManager() >>> pm += convert_to_cz() >>> pm += fuse_adjacents >>> pm += remove_barriers >>> >>> print(pm) PassManager(['convert_to_cz', 'fuse_adjacents', 'remove_barriers']) >>> >>> # Insert a pass at a specific position >>> from qrisp import decompose >>> pm.insert_pass(1, decompose) >>> print(pm) PassManager(['convert_to_cz', 'decompose', 'fuse_adjacents', 'remove_barriers']) >>> >>> # Remove the last pass >>> pm.remove_pass(len(pm) - 1) >>> print(pm) PassManager(['convert_to_cz', 'decompose', 'fuse_adjacents']) >>> >>> transpiled_qc = pm.run(qc)
Methods#
|
Add a pass or extend with the passes of another PassManager in-place. |
|
Add a transformation pass to the manager. |
|
Insert a pass at a specific position. |
|
Remove a pass at the specified index. |
Remove all passes from the manager. |
|
|
Apply all passes in sequence to the quantum circuit. |
|
Verify every pass in the manager against qc one by one. |