qrunch.quantum.groupers.qubit_wise
Module containing the qubit-wise closest grouper based on distance-between-Paulis heuristic.
Classes
Grouper that uses a distance-between-Paulis heuristic for qubit-wise commutation. |
|
Options for the QubitWiseGrouper. |
- class QubitWiseGrouper
Bases:
MeasurementGrouperGrouper that uses a distance-between-Paulis heuristic for qubit-wise commutation.
This grouper groups Pauli strings by measuring the “distance” between them based on qubit-wise compatibility. Pauli strings that are closer (more compatible) are grouped together, allowing measurement in the same basis.
The method is inherently qubit-wise, meaning it considers commutation on a per-qubit basis rather than global commutation of the entire Pauli string.
- __init__(shot_distributor: ShotDistributor | None = None, options: QubitWiseGrouperOptions | None = None) None
Initialize an instance of the QubitWiseGrouper.
- Parameters:
shot_distributor (ShotDistributor | None) – Optional custom shot distributor to use for distributing shots among the groups.
options (QubitWiseGrouperOptions | None) – Options for the qubit-wise grouper.
- Return type:
None
- change_shot_distributor(shot_distributor: ShotDistributor) MeasurementGrouper | None
Change shot distributor.
- Parameters:
shot_distributor (ShotDistributor)
- Return type:
MeasurementGrouper | None
- group(pauli_sums: Sequence[HermitianPauliSum], shots: int | None, circuit: Circuit | None = None) tuple[MeasurementGroup, ...]
Group Pauli strings using distance-between-Paulis heuristic.
- Parameters:
pauli_sums (Sequence[HermitianPauliSum]) – Pauli sums to group.
shots (int | None) – Number of shots to distribute among the groups.
circuit (Circuit | None) – Circuit for the pauli sums to be measured on. Not used for this grouper.
- 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]
- class QubitWiseGrouperOptions
Bases:
DataclassPublicAPIOptions for the QubitWiseGrouper.
- Parameters:
saturate_groups – If True, the groups are saturated with all compatible Pauli strings after grouping. (default=False)
- __init__(*, saturate_groups: bool = False) None
- Parameters:
saturate_groups (bool)
- Return type:
None
- saturate_groups: bool = False