qrunch.quantum.groupers.shot_distributors.l2_norm_shot_distributor
Module containing the L2NormShotDistributor.
The L2NormShotDistributor distributes shots based on the ℓ² norm of the Pauli strings in each group.
Classes
Represent an distribution over groups based on their ℓ² norm. |
|
Options for the L2NormShotDistributor. |
- class L2NormShotDistributor
Bases:
ShotDistributorRepresent an distribution over groups based on their ℓ² norm.
- Parameters:
observables – A list of Pauli sum observables to consider.
- __init__(options: L2NormShotDistributorOptions | None = None) None
Initialize the L2NormShotDistributor with the given options.
- Parameters:
options (L2NormShotDistributorOptions | None) – Options for the L2NormShotDistributor.
- Return type:
None
- distribute_shots(groups: Sequence[PartialMeasurementGroup], total_shots: int | None) tuple[MeasurementGroup, ...]
Build a probability distribution over the given groups.
The weights are proportional to the sum of the ℓ² norms of the Pauli strings in each group.
- Parameters:
groups (Sequence[PartialMeasurementGroup]) – A list of Pauli string groups.
total_shots (int | None) – The total number of shots available for measurement.
- Return type:
tuple[MeasurementGroup, …]
- static get_pauli_string_to_l2_norm_map(groups: Sequence[PartialMeasurementGroup]) dict[PauliString, float]
Get the map from Pauli strings to their l^2 norms based on the coefficients in the observables of the groups.
- Parameters:
groups (Sequence[PartialMeasurementGroup]) – A list of Pauli string groups.
- Return type:
dict[PauliString, float]
- get_shot_distribution(groups: Sequence[PartialMeasurementGroup]) list[float]
Get the shots distribution as a probability distribution.
- Parameters:
groups (Sequence[PartialMeasurementGroup]) – A list of Pauli string groups.
- Return type:
list[float]
- class L2NormShotDistributorOptions
Bases:
DataclassPublicAPIOptions for the L2NormShotDistributor.
All fields are immutable (
frozen=True) so an instance can be safely reused.- Parameters:
shots_batch_size – Number of shots per batch used when distributing shots among groups. (default=1000)
- __init__(*, shots_batch_size: int = 1000) None
- Parameters:
shots_batch_size (int)
- Return type:
None
- shots_batch_size: int = 1000