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. When max_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. When max_qwc_groups = None, the number of qubit-wise commuting Pauli groups in the observables is not constrained.

Parameters:
  • max_paulis (int | None)

  • max_qwc_groups (int | None)

  • simplify (bool)

is_active()[source]

Return whether self places any bounds on operator size.

Return type:

bool

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:
  • num_unique_paulis (int)

  • num_duplicate_paulis (int)

  • num_trimmed_paulis (int)

  • sum_trimmed_coeffs (float)

num_duplicate_paulis: int

The number of duplicate Pauli terms. See also num_duplicate_paulis.

num_trimmed_paulis: int

The number of trimmed Pauli terms. See also num_trimmed_paulis.

num_unique_paulis: int

The number of unique Pauli terms. See also num_unique_paulis.

sum_trimmed_coeffs: float

The sum of the trimmed coefficients. See also sum_trimmed_coeffs.

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 using SparsePauliOp.atol.

  • rtol (float | None) – the relative tolerance for checking if coefficients are zero. If None, this will fallback to using SparsePauliOp.rtol.

Returns:

The simplified Pauli operator.

Return type:

tuple[SparsePauliOp, SimplifyMetadata]