F2QSynthesis¶
- class F2QSynthesis(config=None)¶
Bases:
GenericPass[DAGCircuit,DAGCircuit]A transpilation pass to map fermion-based circuit instructions to qubit-based ones.
This transpilation pass works similarly to Qiskit’s
HighLevelSynthesispass; given an inputFermionicDAGCircuit, it iterates the contained instructions and delegates the translation to qubit-based instructions to matchingmethods. The insertion of the qubit-based circuit instructions into the outputDAGCircuitis also left to the plugin method. This pass will merely have prepared theQuantumRegisteraccording to the global transpilationF2QLayoutsetting.Usage
There are two ways to configure the plugins used by this transpiler pass. The examples below show the equivalent configuration to the
generate_preset_jw_pass_manager().Providing a
configduring initialization:>>> from qiskit_fermions.mappers.library import jordan_wigner >>> from qiskit_fermions.transpiler import passes >>> >>> config = { ... "Evolution": ("MapperFn", (jordan_wigner,)), ... "InitializeModes": "TrivialOccupation", ... "OrbitalRotation": "GivensDecomposition", ... } >>> synth = passes.F2QSynthesis(config)
Manually populating the
methodsattribute:>>> from qiskit_fermions.mappers.library import jordan_wigner >>> from qiskit_fermions.transpiler import passes >>> >>> synth = passes.F2QSynthesis() >>> synth.methods["Evolution"] = passes.MapperFnEvolutionSynthesis(jordan_wigner) >>> synth.methods["InitializeModes"] = passes.TrivialOccupationInitializeModesSynthesis() >>> synth.methods["OrbitalRotation"] = passes.GivensDecompositionOrbitalRotationSynthesis()
Through this manual approach it is also possible to inject custom
F2QSynthesisPluginimplementations without requiring them to be registered through an entry-point.
Initializing this transpiler pass can be done with the arguments listed below.
- Parameters:
config (F2QSynthesisConfig | None) – an optional dictionary to pre-populate the
methodswith plugins provided by theF2QSynthesisPluginManager.
Attributes
- methods: dict[str, F2QSynthesisPlugin]¶
A dictionary of fermion-to-qubit circuit instruction transpilation methods.
For this transpilation pass to have any effect, this dictionary must be populated with instances of the
F2QSynthesisPluginprotocol. The keys of this dictionary correspond to the__name__of a circuit instruction.All available transpilation plugins are managed by the
F2QSynthesisPluginManager.Note
This dictionary is empty by default! You can pre-populate it with plugins provided by the
F2QSynthesisPluginManagerby providing aconfigargument during initialization of this transpiler pass instance.
Methods
- run(dag)¶
Runs this transpilation pass.
- Parameters:
dag (DAGCircuit) – the input circuit with fermion-based instructions. Only
DAGOpNodewithFermionicGateinstances as theiropare supported.- Returns:
The output circuit with qubit-based instructions.
- Raises:
ValueError – when a
DAGOpNodeis encountered whoseopis not of typeFermionicGate.TypeError – when a
FermionicGatetype is encountered for which no translation plugin is present inmethods.
- Return type:
Inherited Methods
- execute(passmanager_ir, state, callback=None)¶
Execute optimization task for input Qiskit IR.
- Parameters:
passmanager_ir (IR) – Qiskit IR to optimize.
state (PassManagerState) – State associated with workflow execution by the pass manager itself.
callback (Callable[[Task, IR_OUT, PropertySet, float, int], None] | None) – A callback function which is called per execution of optimization task.
- Returns:
Optimized Qiskit IR and state of the workflow.
- Return type:
tuple[IR_OUT, PassManagerState]
- 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: