qrunch.quantum.groupers.creators

Module containing creators for measurement groupers and presets for measurement groupers and shot distributors.

Classes

MeasurementGrouperAndShotDistributorPresetsSubCreator

Creator for measurement grouper and shot distributor presets.

MeasurementGrouperSubCreator

Creator for measurement groupers.

class MeasurementGrouperAndShotDistributorPresetsSubCreator

Bases: Generic[T]

Creator for measurement grouper and shot distributor presets.

__init__(parent: T, grouper_field_name: str, shot_distributor_field_name: str) None

Initialize the sub-creator.

Parameters:
  • parent (T) – The parent object to which the preset will be added.

  • grouper_field_name (str) – The name of the field in the parent object to which the grouper will be added.

  • shot_distributor_field_name (str) – The name of the field in the parent object to which the shot distributor will be added.

Return type:

None

balanced_defaults() T

Choose the balanced default.

This preset is updated to at all times reflect the most balanced preset available in qrunch, which may be updated over time. The current balanced default is:

ShadowGrouper with L2NormShotDistributor.

Return type:

T

beast_defaults() T

Set the measurement grouper and shot distributor preset to the BEAST or hardcore bosonic hamiltonian.

Return type:

T

precise_defaults() T

Choose the precise default.

This preset is updated to at all times reflect the most precise preset available in qrunch, which may be updated over time. The current precise default is:

ShadowGrouper with L2NormShotDistributor.

Return type:

T

quick_defaults() T

Choose the quick default.

This preset is updated to at all times reflect the most quick preset available in qrunch, which may be updated over time. The current quick default is:

QubitWiseGrouper with L2NormShotDistributor.

Return type:

T

class MeasurementGrouperSubCreator

Bases: Generic[T]

Creator for measurement groupers.

__init__(parent: T, field_name: str) None

Initialize the sub-creator.

Parameters:
  • parent (T) – The parent object to which the grouper will be added.

  • field_name (str) – The name of the field in the parent object to which the grouper will be added.

Return type:

None

beast() T

Set the measurement grouper to the BEAST measurement grouper.

This grouper is designed specifically for the BEAST-VQE chemistry algorithm.

Return type:

T

identity() T

Set the measurement grouper to the identity measurement grouper.

The simple grouper groups every pauli string into their own group.

Return type:

T

qubit_wise(options: QubitWiseGrouperOptions | None = None) T

Set the measurement grouper to the qubit-wise measurement grouper.

In this gouper, the pauli strings contained in the observables are grouped by comparing each pauli operator in the string.

\[\{ Z_1, Z_0 Z_1 Z_2, X_0 Y_1, Y_1 X_2\} \rightarrow \{ Z_1, Z_0 Z_1 Z_2 \}\,\text{and}\,\{X_0 Y_1, Y_1 X_2\}\]

The grouper prioritizes groups where no additional measurements are needed, e.g., the pauli string \(X_2\) commutes with all pauli strings in the groups \(\{Z_0 Z_1\}\) and \(\{Y_0, X_1 X_2\}\). However, all measurements needed for measuring \(X_2\) are already performed in the second group, so it is preferred.

The basis identifier is a list of strings, where each string is either “I”, “X”, “Y”, or “Z”. “X”, “Y”, and “Z” represent measurements in the X-, Y-, and Z-basis, respectively, for the corresponding qubit. “I” reflects that the basis does not matter and can be picked freely. For “I”, nothing is added to the circuit corresponding to a measurement in the Z-basis.

Parameters:

options (QubitWiseGrouperOptions | None)

Return type:

T

shadow(options: ShadowGrouperOptions | None = None) T

Set the measurement grouper to the shadow measurement grouper.

The shadow grouper iteratively forms measurement groups by taking into account previously generated groups and reweighing Pauli strings based on how well they are already covered by existing groups.

Parameters:

options (ShadowGrouperOptions | None)

Return type:

T