Observable grouping (qiskit_addon_cutting.utils.observable_grouping)

Module for conducting Pauli observable grouping.

observables_restricted_to_subsystem(qubits, global_observables, /)[source]

Restrict each observable to its support on a given subsystem.

A PauliList will be returned if a PauliList is provided; otherwise, a list[Pauli] will be returned.

Any phase information will be discarded, consistent with the standard behavior when slicing a Pauli.

Parameters:
  • qubits (Sequence[int]) – The qubits in a subsystem

  • global_observables (Sequence[Pauli] | PauliList) – The list of observables

Return type:

list[Pauli] | PauliList

Returns:

Each Pauli restricted to the subsystem.

>>> observables_restricted_to_subsystem([1, 3], PauliList(["IXYZ", "iZZXX"]))
PauliList(['IY', 'ZX'])
class CommutingObservableGroup(general_observable, commuting_observables)[source]

Bases: object

Set of mutually qubit-wise commuting observables.

Parameters:
commuting_observables: list[Pauli]

Observables that can be measured simultaneously.

general_observable: Pauli

A single Pauli string that contains all qubit-wise measurements needed to measure everything in commuting_observables.

pauli_bitmasks: list[int]

A bitmask for each observable in commuting_observables; given an element, each bit corresponds to whether the corresponding entry in pauli_indices is relevant to that observable.

pauli_indices: list[int]

The indices of non-identity Paulis in general_observable.

class ObservableCollection(observables, /)[source]

Bases: object

Collection of observables organized for efficient taking of measurements.

The observables are automatically organized into sets of mutually qubit-wise commuting observables, each represented by a CommutingObservableGroup.

Assign member variables.

Parameters:

observables (PauliList | Iterable[Pauli]) – Observables of interest

static construct_general_observables(commuting_subobservables, /)[source]

Construct the most general observable from each set of mutually commuting observables.

In special cases, advanced users may want to subclass and override this staticmethod in order to measure additional qubits than the default for each general observable.

Return type:

list[Pauli]

Parameters:

commuting_subobservables (list[list[Pauli]])

property groups: list[CommutingObservableGroup]

List of CommutingObservableGroups which, together, contain all desired observables.

property lookup: dict[Pauli, list[tuple[int, int]]]

Get dict which maps each Pauli observable to a list of indices, (i, j), to commuting observables in groups.

For each element of the list, it means that the Pauli is given by the j-th commuting observable in the i-th group.

This list will be of length 1 at minimum, but may potentially be longer if multiple CommutingObservableGroup objects are compatible with the given Pauli.