MapperFnEvolutionSynthesis

class MapperFnEvolutionSynthesis(mapper_fn, product_formula=None)

Bases: object

A F2QSynthesisPlugin for transpiling Evolution under a custom mapping.

This plugin maps the fermionic Hamiltonian \(H\) of the incoming Evolution gate to a qubit operator using mapper_fn and emits a PauliEvolutionGate. It thereby preserves the \(e^{-i t H}\) convention of the Evolution gate, with the same evolution time \(t\).

How that PauliEvolutionGate is subsequently decomposed into basis gates is governed by the product formula passed as product_formula. Leaving it at its default (None) defers to the PauliEvolutionGate’s own default synthesis (a first-order LieTrotter decomposition with a single repetition). Supplying an explicit EvolutionSynthesis (for example a higher-order SuzukiTrotter or one with several repetitions) selects a different Trotter-Suzuki product formula, trading circuit depth for a smaller Trotter error.

Note

The operator returned by mapper_fn is passed on as-is, in particular without being simplified. A product formula synthesizes the Pauli terms in the order it receives them, so the term order that mapper_fn produces is part of its output and is preserved here. A mapper_fn that maps an operator group by group, for instance, emits the terms of each group together, which lets the terms of one group be scheduled in parallel where their supports are disjoint. See group_wise(), which wraps any mapper to do exactly that.

Caution

A consequence of preserving that order is that the synthesized circuit is only as reproducible as mapper_fn is. The operators of the Rust core do not preserve the order in which their terms were added, so a mapper that walks an operator’s terms can emit them in a different order from one run to the next. The circuits that result are all equally valid (they approximate the same evolution of the same operator) but they need not be identical, and metrics such as depth or gate count can vary between them.

Wrap the mapper in simplify() to pin a canonical order where that matters:

MapperFnEvolutionSynthesis(simplify(jordan_wigner))

Initializing this transpiler pass plugin can be done with the arguments listed below.

Parameters:
  • mapper_fn (MapperFunction) – the fermion-to-qubit operator mapping function.

  • product_formula (EvolutionSynthesis | None) – the product formula with which to synthesize the emitted PauliEvolutionGate. If None (the default), the gate’s own default synthesis is used (a first-order LieTrotter decomposition with a single repetition).

Attributes

mapper_fn: MapperFunction

The fermion-to-qubit operator mapping function.

The two input arguments should be the following:

  1. the operator to be mapped.

  2. the number of qubits that the resulting operator should be defined on.

Note

It is the user’s responsibility to ensure that this function is in-sync with the global transpilation F2QLayout setting.

product_formula: EvolutionSynthesis | None

The product formula used to synthesize the emitted PauliEvolutionGate, or None to defer to that gate’s own default synthesis.

Methods

run(in_node, out_dag, *, f2q_layout)

Runs this transpilation plugin.

The fermionic Hamiltonian of the incoming Evolution gate is mapped to a qubit operator via mapper_fn and appended to out_dag as a PauliEvolutionGate implementing \(e^{-i t H}\) with the original evolution time \(t\) and the product_formula synthesis.

Parameters:
Return type:

None

See also

The documentation of F2QSynthesisPlugin for more detailed explanations of the arguments.

Raises:

NotImplementedError – when in_node acts on fermionic modes that are spread across multiple FermionicRegister instances.

Parameters:
Return type:

None