---
title: QDrift (v1.3)
description: API reference for qiskit.synthesis.QDrift in qiskit v1.3
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/1.3/qiskit.synthesis.QDrift
---

# QDrift

*class* `qiskit.synthesis.QDrift(reps=1, insert_barriers=False, cx_structure='chain', atomic_evolution=None, seed=None, wrap=False, preserve_order=True)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.3/qiskit/synthesis/evolution/qdrift.py#L34-L138)

Bases: [`ProductFormula`](/docs/api/qiskit/1.3/qiskit.synthesis.ProductFormula "qiskit.synthesis.evolution.product_formula.ProductFormula")

The QDrift Trotterization method, which selects each each term in the Trotterization randomly, with a probability proportional to its weight. Based on the work of Earl Campbell in Ref. \[1].

**References**

\[1]: E. Campbell, “A random compiler for fast Hamiltonian simulation” (2018). [arXiv:quant-ph/1811.08017](https://arxiv.org/abs/1811.08017)

> **Deprecated since version 1.2\_pending**
>
> The ‘Callable\[\[Pauli | SparsePauliOp, float], QuantumCircuit]’ signature of the ‘atomic\_evolution’ argument is pending deprecation as of qiskit 1.2. It will be marked deprecated in a future release, and then removed no earlier than 3 months after the release date. Instead you should update your ‘atomic\_evolution’ function to be of the following type: ‘Callable\[\[QuantumCircuit, Pauli | SparsePauliOp, float], None]’.

**Parameters**

- **reps** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The number of times to repeat the Trotterization circuit.
- **insert\_barriers** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – Whether to insert barriers between the atomic evolutions.
- **cx\_structure** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – How to arrange the CX gates for the Pauli evolutions, can be `"chain"`, where next neighbor connections are used, or `"fountain"`, where all qubits are connected to one. This only takes effect when `atomic_evolution is None`.
- **atomic\_evolution** (*Callable\[\[*[*Pauli*](/docs/api/qiskit/1.3/qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")  *|*[*SparsePauliOp*](/docs/api/qiskit/1.3/qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")*,* [*float*](https://docs.python.org/3/library/functions.html#float)*],* [*QuantumCircuit*](/docs/api/qiskit/1.3/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")*] | Callable\[\[*[*QuantumCircuit*](/docs/api/qiskit/1.3/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")*,* [*Pauli*](/docs/api/qiskit/1.3/qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")  *|*[*SparsePauliOp*](/docs/api/qiskit/1.3/qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp")*,* [*float*](https://docs.python.org/3/library/functions.html#float)*], None] | None*) – A function to apply the evolution of a single [`Pauli`](/docs/api/qiskit/1.3/qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli"), or [`SparsePauliOp`](/docs/api/qiskit/1.3/qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp") of only commuting terms, to a circuit. The function takes in three arguments: the circuit to append the evolution to, the Pauli operator to evolve, and the evolution time. By default, a single Pauli evolution is decomposed into a chain of `CX` gates and a single `RZ` gate. Alternatively, the function can also take Pauli operator and evolution time as inputs and returns the circuit that will be appended to the overall circuit being built.
- **seed** ([*int*](https://docs.python.org/3/library/functions.html#int) *| None*) – An optional seed for reproducibility of the random sampling process.
- **wrap** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – Whether to wrap the atomic evolutions into custom gate objects. This only takes effect when `atomic_evolution is None`.
- **preserve\_order** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If `False`, allows reordering the terms of the operator to potentially yield a shallower evolution circuit. Not relevant when synthesizing operator with a single term.

## Attributes

### settings

Return the settings in a dictionary, which can be used to reconstruct the object.

**Returns**

A dictionary containing the settings of this product formula.

**Raises**

[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError) – If a custom atomic evolution is set, which cannot be serialized.

## Methods

### expand

`expand(evolution)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.3/qiskit/synthesis/evolution/qdrift.py#L102-L138)

Apply the product formula to expand the Hamiltonian in the evolution gate.

**Parameters**

**evolution** ([*PauliEvolutionGate*](/docs/api/qiskit/1.3/qiskit.circuit.library.PauliEvolutionGate "qiskit.circuit.library.PauliEvolutionGate")) – The [`PauliEvolutionGate`](/docs/api/qiskit/1.3/qiskit.circuit.library.PauliEvolutionGate "qiskit.circuit.library.PauliEvolutionGate"), whose Hamiltonian we expand.

**Returns**

A list of Pauli rotations in a sparse format, where each element is `(paulistring, qubits, coefficient)`. For example, the Lie-Trotter expansion of `H = XI + ZZ` would return `[("X", [1], 1), ("ZZ", [0, 1], 1)]`.

**Return type**

[list](https://docs.python.org/3/library/stdtypes.html#list)\[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple)\[[int](https://docs.python.org/3/library/functions.html#int)], [float](https://docs.python.org/3/library/functions.html#float)]]

### synthesize

`synthesize(evolution)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.3/qiskit/synthesis/evolution/product_formula.py#L146-L168)

Synthesize a [`PauliEvolutionGate`](/docs/api/qiskit/1.3/qiskit.circuit.library.PauliEvolutionGate "qiskit.circuit.library.PauliEvolutionGate").

**Parameters**

**evolution** ([*PauliEvolutionGate*](/docs/api/qiskit/1.3/qiskit.circuit.library.PauliEvolutionGate "qiskit.circuit.library.PauliEvolutionGate")) – The evolution gate to synthesize.

**Returns**

A circuit implementing the evolution.

**Return type**

[QuantumCircuit](/docs/api/qiskit/1.3/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
