FermionicStagedPassManager

class FermionicStagedPassManager

Bases: StagedPassManager

The staged fermion-to-qubit transpilation pipeline.

This

Note

Qiskit is currently working on native support of transpiler pipelines involving more than a single intermediate representation. Once that gets more formalized, the implementation here will be aligned with the resulting interfaces. See also this tracking issue.

Inherited Attributes

expanded_stages

Expanded Pass manager stages including pre_ and post_ phases.

invalid_stage_regex = re.compile('\\s|\\+|\\-|\\*|\\/|\\\\|\\%|\\<|\\>|\\@|\\!|\\~|\\^|\\&|\\:|\\[|\\]|\\{|\\}|\\(|\\)')
stages

Pass manager stages

Methods

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

Run all the passes on the specified circuits.

Parameters:
  • circuits – Circuit(s) to transform via all the registered passes.

  • output_name – The output circuit name. If None, it will be set to the same as the input circuit name.

  • callback (Callable | None) –

    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
    

    Note

    Beware that the keyword arguments here are different to those used by the generic 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:

    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 | 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[str, object] | None) – If given, the initial value to use as the 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, so you should take a lot of care when using this argument.

  • in_programs (FermionicCircuit | list[FermionicCircuit])

Returns:

The transformed circuit(s).

Return type:

QuantumCircuit

Inherited Methods

append(passes)

Append a Pass Set to the schedule of passes.

Parameters:

passes (Task | list[Task]) – A set of transpiler passes to be added to schedule.

Raises:

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

Return type:

None

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

Draw the staged pass manager.

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) – 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.

remove(index)

Removes a particular pass in the scheduler.

Parameters:

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

Raises:

PassManagerError – If the index is not found.

Return type:

None

replace(index, passes)

Replace a particular pass in the scheduler.

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

  • passes (BasePass | list[BasePass]) – A pass set to be added to the pass manager schedule.

Return type:

None

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