Shortcuts

qiskit.transpiler.PassManager

class PassManager(passes=None, max_iteration=1000, callback=None)[ソース]

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

Initialize an empty PassManager object (with no passes scheduled).

パラメータ
  • passes (Union[BasePass, List[BasePass], None]) – A pass set (as defined in qiskit.transpiler.PassManager.append()) to be added to the pass manager schedule.

  • max_iteration (int) – The maximum number of iterations the schedule will be looped if the condition is not met.

  • callback (Optional[Callable]) – DEPRECATED - A callback function that will be called after each pass execution.

バージョン 0.13.0 で非推奨: The callback parameter is deprecated in favor of PassManager.run(..., callback=callback, ...).

__init__(passes=None, max_iteration=1000, callback=None)[ソース]

Initialize an empty PassManager object (with no passes scheduled).

パラメータ
  • passes (Union[BasePass, List[BasePass], None]) – A pass set (as defined in qiskit.transpiler.PassManager.append()) to be added to the pass manager schedule.

  • max_iteration (int) – The maximum number of iterations the schedule will be looped if the condition is not met.

  • callback (Optional[Callable]) – DEPRECATED - A callback function that will be called after each pass execution.

バージョン 0.13.0 で非推奨: The callback parameter is deprecated in favor of PassManager.run(..., callback=callback, ...).

Methods

__init__([passes, max_iteration, callback])

Initialize an empty PassManager object (with no passes scheduled).

append(passes[, max_iteration])

Append a Pass Set to the schedule of passes.

draw([filename, style, raw])

Draw the pass manager.

passes()

Return a list structure of the appended passes and its options.

remove(index)

Removes a particular pass in the scheduler.

replace(index, passes[, max_iteration])

Replace a particular pass in the scheduler.

run(circuits[, output_name, callback])

Run all the passes on the specified circuits.

append(passes, max_iteration=None, **flow_controller_conditions)[ソース]

Append a Pass Set to the schedule of passes.

パラメータ
  • passes (Union[BasePass, List[BasePass]]) – A set of passes (a pass set) to be added to schedule. A pass set is a list of passes that are controlled by the same flow controller. If a single pass is provided, the pass set will only have that pass a single element.

  • max_iteration (Optional[int]) – max number of iterations of passes.

  • flow_controller_conditions (Any) – control flow plugins.

例外

TranspilerError – if a pass in passes is not a proper pass.

参考

RunningPassManager.add_flow_controller() for more information about the control flow plugins.

戻り値の型

None

draw(filename=None, style=None, raw=False)[ソース]

Draw the pass manager.

This function needs pydot, which in turn needs Graphviz to be installed.

パラメータ
  • filename (str) – file path to save image to.

  • style (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) – If True, save the raw Dot output instead of the image.

戻り値

an in-memory representation of the pass manager, or None if no image was generated or Pillow is not installed.

戻り値の型

Optional[PassManager]

例外

ImportError – when nxpd or pydot not installed.

passes()[ソース]

Return a list structure of the appended passes and its options.

戻り値の型

List[Dict[str, BasePass]]

戻り値

A list of pass sets, as defined in append().

remove(index)[ソース]

Removes a particular pass in the scheduler.

パラメータ

index (int) – Pass index to replace, based on the position in passes().

例外

TranspilerError – if the index is not found.

戻り値の型

None

replace(index, passes, max_iteration=None, **flow_controller_conditions)[ソース]

Replace a particular pass in the scheduler.

パラメータ
  • index (int) – Pass index to replace, based on the position in passes().

  • passes (Union[BasePass, List[BasePass]]) – A pass set (as defined in qiskit.transpiler.PassManager.append()) to be added to the pass manager schedule.

  • max_iteration (Optional[int]) – max number of iterations of passes.

  • flow_controller_conditions (Any) – control flow plugins.

例外

TranspilerError – if a pass in passes is not a proper pass or index not found.

参考

RunningPassManager.add_flow_controller() for more information about the control flow plugins.

戻り値の型

None

run(circuits, output_name=None, callback=None)[ソース]

Run all the passes on the specified circuits.

パラメータ
  • circuits (Union[QuantumCircuit, List[QuantumCircuit]]) – Circuit(s) to transform via all the registered passes.

  • output_name (Optional[str]) – The output circuit name. If None, it will be set to the same as the input circuit name.

  • callback (Optional[Callable]) –

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

    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
    

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

戻り値の型

Union[QuantumCircuit, List[QuantumCircuit]]

戻り値

The transformed circuit(s).

表示 lang: Japanese
言語
English
Japanese
German
Korean