Pauli operator simplification (qiskit_addon_obp.utils.simplify
)¶
Functions for simplifying Pauli operators.
- class OperatorBudget(max_paulis=None, max_qwc_groups=None, simplify=True)[source]¶
A class for storing the constants that determine how large an operator may grow.
Backpropagation will stop if either of the following conditions is met:
The number of Pauli terms across all of the observables exceeds
max_paulis
. Whenmax_paulis = None
, the number of Pauli terms in the observables is not constrained.The number of qubit-wise commuting Pauli groups across all of the observables exceed
max_qwc_groups
. Whenmax_qwc_groups = None
, the number of qubit-wise commuting Pauli groups in the observables is not constrained.
- max_paulis: int | None = None¶
The maximum number of Pauli terms the backpropagated operator may contain.
- max_qwc_groups: int | None = None¶
The maximum number of qubit-wise commuting Pauli groups the backpropagated operator may contain.
- simplify: bool = True¶
A flag denoting whether to call
simplify()
at every iteration.
- class SimplifyMetadata(num_unique_paulis, num_duplicate_paulis, num_trimmed_paulis, sum_trimmed_coeffs)[source]¶
A simple dataclass for returning the tracked attributes during operator simplification.
- Parameters:
- simplify(operator, *, atol=None, rtol=None)[source]¶
Simplifies the provided Pauli operator.
This is an adaption of
SparsePauliOp.simplify()
which tracks metadata of the simplified terms.- Parameters:
operator (SparsePauliOp) – the
SparsePauliOp
to simplify.atol (float | None) – the absolute tolerance for checking if coefficients are zero. If
None
, this will fallback to usingSparsePauliOp.atol
.rtol (float | None) – the relative tolerance for checking if coefficients are zero. If
None
, this will fallback to usingSparsePauliOp.rtol
.
- Returns:
The simplified Pauli operator.
- Return type: