qrunch.quantum.groupers

Module containing groupers for grouping operators into groups of commuting operators.

Classes

MeasurementGrouperSubCreator

Creator for measurement groupers.

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. It first tries to group into only three groups: one measured only in the X basis, one measured only in the Y basis, and one measured only in the Z basis.

If this fails it will try to group into only the seven groups necessary for analytical parameter optimization for Beast. For 5 qubits such groups could be XZXXX, XXZXX, ZXXZZ, YZYYY, YYZYY, ZYYZZ, ZZZZZ, where qubit 2 and 3 are special and need a Z basis in the X-groups or X basis in one of the Z groups. These special qubits are the qubits for the last gate being optimized, and they are extracted from the pauli string. If they can not be determined at runtime the previous gate qubits are used.

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() 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.

Return type:

T

Modules

beast_grouper

Module containing the BEAST measurement grouper which groups into only the three X, Y, and Z groups.

groupers_protocols

Module containing groupers for grouping operators into groups of commuting operators.

identity

Module containing the identity grouper.

qubit_wise

Module containing the qubit wise grouper.