Skip to main contentIBM Quantum Documentation
Important

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

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, atol=None, rtol=None)

GitHub

Bases: object

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)
  • atol (float | None)
  • rtol (float | None)

atol

Type: float | None

Default value: None

Absolute tolerance for checking if coefficients are zero. Defaults to the atol value of SparsePauliOp.

is_active

is_active()

GitHub

Return whether self places any bounds on operator size.

Return type

bool

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.

rtol

Type: float | None

Default value: None

Relative tolerance for checking if coefficients are zero. Defaults to the rtol value of Sparse.

simplify

Type: bool

Default value: True

A flag denoting whether to call simplify() at every iteration.

SimplifyMetadata

class SimplifyMetadata(num_unique_paulis, num_duplicate_paulis, num_trimmed_paulis, sum_trimmed_coeffs)

GitHub

Bases: object

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)

GitHub

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]

Was this page helpful?
Report a bug or request content on GitHub.