RelabelModes

class RelabelModes

Bases: TransformationPass

A transpilation pass to relabel the fermionic modes.

Caution

This transpiler pass is known to have the following limitations:

  • handling of gates other than Evolution is currently not implemented

  • handling of gates acting on a local subset of fermionic modes is not implemented

Attributes

permutation

The index permutation used to relabel the fermionic mode indices.

This may either be a list[int] in which case its length has to match the number of fermionic modes of the circuit being transpiled. This scenario therefore requires the transpiler pass to be tailored quite specifically to the user’s circuit.

Being a permutation, each index in this list has to appear exactly once.

Or it may be None, in which case the build_excitation_span_minimization_model() function is used to define an optimization problem which tries to minimize the span of all occurring fermionic excitations.

Note

The use of this optimization model is only implemented for time-evolution gates containing a FermionOperator instance.

solver

The optimization problem solver instance to automatically find permutation.

When permutation is None, the optimization problem defined by build_excitation_span_minimization_model() is used to automatically find a good permutation of mode indices. In such a case, the user must provide an optimizer to solve this model.

Inherited Attributes

is_analysis_pass

Check if the pass is an analysis pass.

If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.

is_transformation_pass

Check if the pass is a transformation pass.

If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).

Methods

find_permutation(dag)

Finds a mode index permutation when not specified by the user.

This function only gets called when permutation is not specified by the user (i.e. it is None). When that is the case, it does the following:

  1. ensure that the optional pyomo dependency is installed. Otherwise, no optimization can be performed and this transpiler pass has no effect.

  2. ensure that a solver is specified. Otherwise, no optimization can be performed and this transpiler pass has no effect.

  3. gather all the fermionic excitations from any Evolution gates containing a FermionOperator instance.

  4. build the optimization problem using build_excitation_span_minimization_model(), forwarding any additional keyword arguments (kwargs) from when this transpiler pass was constructed.

  5. solve the optimization problem using solver and extract the final permutation.

Parameters:

dag (DAGCircuit) – the circuit to be transpiled.

Returns:

The permutation to use. When None, this transpiler pass will have no effect.

Raises:

NotImplementedError – when encountering an Evolution gate containing an operator that is not a FermionOperator instance.

Return type:

tuple[list[int] | None, pyomo.opt.results.results_.SolverResults | None]

run(dag)

Runs this transpilation pass.

Parameters:

dag (DAGCircuit) – the input circuit with fermion-based instructions. Only DAGOpNode with FermionicGate instances as their op are supported.

Returns:

The output circuit which is still acting on a fermionic register.

Return type:

DAGCircuit

Inherited Methods

execute(passmanager_ir, state, callback=None)

Execute optimization task for input Qiskit IR.

Parameters:
  • passmanager_ir (Any) – Qiskit IR to optimize.

  • state (PassManagerState) – State associated with workflow execution by the pass manager itself.

  • callback (Callable | None) – A callback function which is called per execution of optimization task.

Returns:

Optimized Qiskit IR and state of the workflow.

Return type:

tuple[Any, PassManagerState]

name()

Name of the pass.

Return type:

str

update_status(state, run_state)

Update workflow status.

Parameters:
  • state (PassManagerState) – Pass manager state to update.

  • run_state (RunState) – Completion status of current task.

Returns:

Updated pass manager state.

Return type:

PassManagerState