Skip to main contentIBM Quantum Documentation Mirror

PauliEvolutionGate

class qiskit.circuit.library.PauliEvolutionGate(operator, time=1.0, label=None, synthesis=None)

GitHub

Bases: Gate

Time-evolution of an operator consisting of Paulis.

For an Hermitian operator HH consisting of Pauli terms and (real) evolution time tt this gate represents the unitary

U(t)=eitH.U(t) = e^{-itH}.

The evolution gates are related to the Pauli rotation gates by a factor of 2. For example the time evolution of the Pauli XX operator is connected to the Pauli XX rotation RXR_X by

U(t)=eitX=RX(2t).U(t) = e^{-itX} = R_X(2t).

Compilation:

This gate represents the exact evolution U(t)U(t). Implementing this operation exactly, however, generally requires an exponential number of gates. The compiler therefore typically implements an approximation of the unitary U(t)U(t), e.g. using a product formula such as defined by LieTrotter. By passing the synthesis argument, you can specify which method the compiler should use, see qiskit.synthesis for the available options.

Note that the order in which the approximation and methods like control() and power() are called matters. Changing the order can lead to different unitaries.

Examples:

from qiskit.circuit import QuantumCircuit
from qiskit.circuit.library import PauliEvolutionGate
from qiskit.quantum_info import SparsePauliOp
 
X = SparsePauliOp("X")
Z = SparsePauliOp("Z")
I = SparsePauliOp("I")
 
# build the evolution gate
operator = (Z ^ Z) - 0.1 * (X ^ I)
evo = PauliEvolutionGate(operator, time=0.2)
 
# plug it into a circuit
circuit = QuantumCircuit(2)
circuit.append(evo, range(2))
print(circuit.draw())

The above will print (note that the -0.1 coefficient is not printed!):

     ┌──────────────────────────┐
q_0: ┤0                         ├
     │  exp(-it (ZZ + XI))(0.2) │
q_1: ┤1                         ├
     └──────────────────────────┘

References:

[1] G. Li et al. Paulihedral: A Generalized Block-Wise Compiler Optimization Framework For Quantum Simulation Kernels (2021). arXiv:2109.03371

Parameters

  • operator (qiskit.quantum_info.Pauli |SparsePauliOp |SparseObservable |list[qiskit.quantum_info.Pauli |SparsePauliOp |SparseObservable]) – The operator to evolve. Can also be provided as list of non-commuting operators where the elements are sums of commuting operators. For example: [XY + YX, ZZ + ZI + IZ, YY].
  • time (ParameterValueType) – The evolution time.
  • label (str | None) – A label for the gate to display in visualizations. Per default, the label is set to exp(-it <operators>) where <operators> is the sum of the Paulis. Note that the label does not include any coefficients of the Paulis. See the class docstring for an example.
  • synthesis (EvolutionSynthesis | None) – A synthesis strategy. If None, the default synthesis is the Lie-Trotter product formula with a single repetition.

Attributes

base_class

Get the base class of this instruction. This is guaranteed to be in the inheritance tree of self.

The “base class” of an instruction is the lowest class in its inheritance tree that the object should be considered entirely compatible with for _all_ circuit applications. This typically means that the subclass is defined purely to offer some sort of programmer convenience over the base class, and the base class is the “true” class for a behavioral perspective. In particular, you should not override base_class if you are defining a custom version of an instruction that will be implemented differently by hardware, such as an alternative measurement strategy, or a version of a parametrized gate with a particular set of parameters for the purposes of distinguishing it in a Target from the full parametrized gate.

This is often exactly equivalent to type(obj), except in the case of singleton instances of standard-library instructions. These singleton instances are special subclasses of their base class, and this property will return that base. For example:

>>> isinstance(XGate(), XGate)
True
>>> type(XGate()) is XGate
False
>>> XGate().base_class is XGate
True

In general, you should not rely on the precise class of an instruction; within a given circuit, it is expected that Instruction.name should be a more suitable discriminator in most situations.

decompositions

Get the decompositions of the instruction from the SessionEquivalenceLibrary.

definition

Return definition in terms of other basic gates.

label

Return instruction label

mutable

Is this instance is a mutable unique instance or not.

If this attribute is False the gate instance is a shared singleton and is not mutable.

name

Return the name.

num_clbits

Return the number of clbits.

num_qubits

Return the number of qubits.

params

The parameters of this Instruction. Ideally these will be gate angles.

time

Return the evolution time as stored in the gate parameters.

Returns

The evolution time.


Methods

add_decomposition

add_decomposition(decomposition)

GitHub

Add a decomposition of the instruction to the SessionEquivalenceLibrary.

broadcast_arguments

broadcast_arguments(qargs, cargs)

GitHub

Validation and handling of the arguments and its relationship.

For example, cx([q[0],q[1]], q[2]) means cx(q[0], q[2]); cx(q[1], q[2]). This method yields the arguments in the right grouping. In the given example:

in: [[q[0],q[1]], q[2]],[]
outs: [q[0], q[2]], []
      [q[1], q[2]], []

The general broadcasting rules are:

  • If len(qargs) == 1:

    [q[0], q[1]] -> [q[0]],[q[1]]
  • If len(qargs) == 2:

    [[q[0], q[1]], [r[0], r[1]]] -> [q[0], r[0]], [q[1], r[1]]
    [[q[0]], [r[0], r[1]]]       -> [q[0], r[0]], [q[0], r[1]]
    [[q[0], q[1]], [r[0]]]       -> [q[0], r[0]], [q[1], r[0]]
  • If len(qargs) >= 3:

    [q[0], q[1]], [r[0], r[1]],  ...] -> [q[0], r[0], ...], [q[1], r[1], ...]

Parameters

  • qargs (list) – List of quantum bit arguments.
  • cargs (list) – List of classical bit arguments.

Returns

A tuple with single arguments.

Raises

CircuitError – If the input is not valid. For example, the number of arguments does not match the gate expectation.

Return type

Iterable[tuple[list, list]]

control

control(num_ctrl_qubits=1, label=None, ctrl_state=None, annotated=None)

GitHub

Return the controlled version of itself.

The outcome is the specified controlled version of eitHe^{-itH}. The returned gate represents eitHCe^{-it H_C}, where HCH_C is the original operator HH, tensored with 00|0\rangle\langle 0| and 11|1\rangle\langle 1| projectors (depending on the control state).

Parameters

  • num_ctrl_qubits (int) – Number of controls to add to gate (default: 1).
  • label (str | None) – Optional gate label. Ignored if implemented as an annotated operation.
  • ctrl_state (int |str | None) – The control state in decimal or as a bitstring (e.g. "111"). If None, use 2**num_ctrl_qubits - 1.
  • annotated (bool | None) – Not applicable to this class. Usually, when this is True we return an AnnotatedOperation with a control modifier set instead of a concrete Gate. However, we can efficiently represent controlled Pauli evolutions as PauliEvolutionGate, which is used here.

Returns

Controlled version of the given operation.

Return type

Gate

copy

copy(name=None)

GitHub

Copy of the instruction.

Parameters

name (str) – name to be given to the copied circuit, if None then the name stays the same.

Returns

a copy of the current instruction, with the name updated if it was provided

Return type

qiskit.circuit.Instruction

inverse

inverse(annotated=False)

GitHub

Return the inverse, which is obtained by flipping the sign of the evolution time.

Parameters

annotated (bool) –

is_parameterized

is_parameterized()

GitHub

Return whether the Instruction contains compile-time parameters.

power

power(exponent, annotated=False)

GitHub

Raise this gate to the power of exponent.

The outcome represents eitpHe^{-i tp H} where pp equals exponent.

Parameters

  • exponent (float) – The power to raise the gate to.
  • annotated (bool) – Not applicable to this class. Usually, when this is True we return an AnnotatedOperation with a power modifier set instead of a concrete Gate. However, we can efficiently represent powers of Pauli evolutions as PauliEvolutionGate, which is used here.

Returns

An operation implementing gate^exponent.

Return type

Gate

repeat

repeat(n)

GitHub

Creates an instruction with self repeated :math`n` times.

Parameters

n (int) – Number of times to repeat the instruction

Returns

Containing the definition.

Return type

qiskit.circuit.Instruction

Raises

CircuitError – If n < 1.

reverse_ops

reverse_ops()

GitHub

For a composite instruction, reverse the order of sub-instructions.

This is done by recursively reversing all sub-instructions. It does not invert any gate.

Returns

a new instruction with

sub-instructions reversed.

Return type

qiskit.circuit.Instruction

soft_compare

soft_compare(other)

GitHub

Soft comparison between gates. Their names, number of qubits, and classical bit numbers must match. The number of parameters must match. Each parameter is compared. If one is a ParameterExpression then it is not taken into account.

Parameters

other (instruction) – other instruction.

Returns

are self and other equal up to parameter expressions.

Return type

bool

to_matrix

to_matrix()

GitHub

Return the matrix eitHe^{-it H} as numpy.ndarray.

Returns

The matrix this gate represents.

Raises

ValueError – If the time parameters is not numeric.

Return type

ndarray

to_mutable

to_mutable()

GitHub

Return a mutable copy of this gate.

This method will return a new mutable copy of this gate instance. If a singleton instance is being used this will be a new unique instance that can be mutated. If the instance is already mutable it will be a deepcopy of that instance.

validate_parameter

validate_parameter(parameter)

GitHub

Gate parameters should be int, float, or ParameterExpression

Parameters

parameter (ParameterExpression |float) –

Return type

ParameterExpression | float