QDriftTrotterization

class QDriftTrotterization(num_terms, *, filter_diagonal_terms=False, rng=None)

Bases: GenericPass[DAGCircuit, DAGCircuit]

A transpilation pass to Trotterize Evolution gates via the qDRIFT protocol.

This pass replaces the exact evolution \(e^{-i t H}\) of each Evolution gate by a randomized product formula: it draws num_terms samples from the Hamiltonian’s terms (or groups, if assigned), with each term sampled with a probability proportional to the magnitude of its coefficient, and emits one Evolution gate per sample. Every sampled gate evolves its (unit-magnitude, sign-preserving) term for the same time

\[\delta = \frac{\lambda t}{\texttt{num\_terms}}, \qquad \lambda = \sum_j |c_j|,\]

where the \(c_j\) are the coefficients of the sampled terms/groups. The ordered product of the sampled evolutions does not reproduce \(e^{-i t H}\) exactly; rather, its expectation over the sampling approximates the exact evolution, with an error that decreases as num_terms grows. Because the output depends on the random draws, it differs from run to run unless a fixed rng is supplied.

See also

The qDRIFT protocol was introduced in arXiv:1811.08017.

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

Parameters:
  • num_terms (int) – the number of terms to sample for the qDRIFT Trotterization. This equals the number of Evolution gates emitted per input gate; a larger value reduces the Trotterization error at the cost of a deeper circuit.

  • filter_diagonal_terms (bool) – when set to True, terms that are diagonal in the occupation-number basis (i.e. products of number operators) are removed from the Hamiltonian before the qDRIFT sampling. The time evolution of such terms does not affect the sampled bitstrings, so including them would only increase the sampling overhead. This automates the manual filtering otherwise required when preparing a Hamiltonian for SqDRIFT. The Hamiltonian is assumed to be normal-ordered. See also filter_diagonal_terms(). Because diagonal-term filtering is defined in terms of fermionic number operators, it is only supported for Evolution gates whose operator is a FermionOperator; run() raises TypeError otherwise.

  • rng (np.random.Generator | int | None) – the random number generator (rng) to be used. When this is an int, the internal rng will be initialized with np.random.default_rng(seed=rng).

Attributes

num_terms

The number of terms to include in the qDRIFT Trotterization.

filter_diagonal_terms

Whether to filter out diagonal terms before the qDRIFT sampling.

Methods

run(dag)

Runs this transpilation pass.

Each Evolution node is replaced by num_terms sampled single-term Evolution gates (see the class docstring). Nodes that are not Evolution gates are copied to the output unchanged. Since the sampling is random, the output varies between runs unless the rng was seeded.

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.

Raises:

TypeError – if filter_diagonal_terms is True but an Evolution gate carries an operator that is not a FermionOperator (diagonal-term filtering is only defined for fermionic operators).

Return type:

DAGCircuit

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]

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