Pauli operator simplification
qiskit_addon_obp.utils.simplify
Functions for simplifying Pauli operators.
OperatorBudget
class OperatorBudget(max_paulis=None, max_qwc_groups=None, simplify=True)
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.
Parameters
is_active
max_paulis
Type: int | None
Default value: None
The maximum number of Pauli terms the backpropagated operator may contain.
max_qwc_groups
Type: int | None
Default value: None
The maximum number of qubit-wise commuting Pauli groups the backpropagated operator may contain.
simplify
SimplifyMetadata
class SimplifyMetadata(num_unique_paulis, num_duplicate_paulis, num_trimmed_paulis, sum_trimmed_coeffs)
A simple dataclass for returning the tracked attributes during operator simplification.
Parameters
- num_unique_paulis (int)
- num_duplicate_paulis (int)
- num_trimmed_paulis (int)
- sum_trimmed_coeffs (float)
num_duplicate_paulis
Type: int
The number of duplicate Pauli terms. See also num_duplicate_paulis
.
num_trimmed_paulis
Type: int
The number of trimmed Pauli terms. See also num_trimmed_paulis
.
num_unique_paulis
Type: int
The number of unique Pauli terms. See also num_unique_paulis
.
sum_trimmed_coeffs
Type: float
The sum of the trimmed coefficients. See also sum_trimmed_coeffs
.
simplify
simplify(operator, *, atol=None, rtol=None)
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