qrunch.quantum.groupers.groupers_protocols
Module containing groupers for grouping operators into groups of commuting operators.
Classes
Grouper for grouping Pauli string into groups of mutually commuting groups. |
- class MeasurementGrouper
Bases:
ProtocolGrouper for grouping Pauli string into groups of mutually commuting groups.
- __init__(*args, **kwargs)
- change_shot_distributor(shot_distributor: ShotDistributor) MeasurementGrouper | None
Return a copy of this grouper with the given shot distributor or None if not supported.
- Parameters:
shot_distributor (ShotDistributor) – The shot distributor to use in the new grouper.
- Return type:
MeasurementGrouper | None
- group(pauli_sums: Sequence[HermitianPauliSum], shots: int | None, circuit: Circuit | None = None) tuple[MeasurementGroup, ...]
Group the terms in the pauli sums into groups of Pauli strings of mutually commuting strings.
- Parameters:
pauli_sums (Sequence[HermitianPauliSum]) – Pauli sums to group.
shots (int | None) – Total number of shots available for measurement.
circuit (Circuit | None) – Circuit for the pauli sums to be measured on. Most groupers do not require or use this.
- Returns:
A list of measurement groups which can be measured simultaneously.
- Return type:
tuple[MeasurementGroup, …]
- validate_shots_type(shots_type: Type[int | ShotsPerGroup | None]) list[str]
Validate that the grouper supports the given shots type. Return a list of error messages if not supported.
- Parameters:
shots_type (Type[int | ShotsPerGroup | None])
- Return type:
list[str]