Observable grouping
qiskit_addon_cutting.utils.observable_grouping
Module for conducting Pauli observable grouping.
observables_restricted_to_subsystem
observables_restricted_to_subsystem(qubits, global_observables, /)
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'])
CommutingObservableGroup
class CommutingObservableGroup(general_observable, commuting_observables)
Bases: object
Set of mutually qubit-wise commuting observables.
Parameters
commuting_observables
Type: list[Pauli]
Observables that can be measured simultaneously.
general_observable
Type: Pauli
A single Pauli string that contains all qubit-wise measurements needed to measure everything in commuting_observables
.
pauli_bitmasks
Type: 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
Type: list[int]
The indices of non-identity Pauli
s in general_observable
.
ObservableCollection
class ObservableCollection(observables, /)
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
construct_general_observables
static construct_general_observables(commuting_subobservables, /)
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
Parameters
groups
Type: list[CommutingObservableGroup]
List of CommutingObservableGroup
s which, together, contain all desired observables.
lookup
Type: 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
.