quri_parts.core.estimator.sampling.estimator_helpers module#

CircuitShotPairPreparationFunction#

A function that returns the sequence of (circuit, shot) pairs for performing sampling estimation on the given state. The default operation is that it concatenates the measurement circuits determined by the grouping scheme to the circuit that prepares the state. This is done with the circuit_shot_pairs_preparation_fn below. Users may customize this function if additional circuit operations needs to be done other than simple concatenation.

alias of Callable[[CircuitQuantumState, Iterable[CommutablePauliSetMeasurement], dict[Set[PauliLabel], int]], Iterable[tuple[NonParametricQuantumCircuit, int]]]

distribute_shots_among_pauli_sets(operator, measurement_groups, shots_allocator, total_shots)#

Distribute shots to each commuting pauli sets.

Parameters:
  • operator (Operator) – The operator to be measured.

  • measurement_groups (Iterable[CommutablePauliSetMeasurement]) – Sequence of CommutablePauliSetMeasurement that corresponds to the grouping result of the operator.

  • shot_allocator – A function that allocates the total shots to Pauli groups to be measured.

  • total_shots (int) – Total number of shots available for sampling measurements.

  • shots_allocator (core.sampling.PauliSamplingShotsAllocator) –

Return type:

dict[core.operator.pauli.CommutablePauliSet, int]

get_sampling_circuits_and_shots(state, measurement_groups, shots_map)#

Sets up the (circuit, shot) pairs for performing sampling estimation. The circuit is given by the measurement circuit concatenated after the circuit held inside the state.

Parameters:
  • state (CircuitQuantumState) – The state on which the expectation value is estimated.

  • measurement_groups (Iterable[CommutablePauliSetMeasurement]) – Sequence of CommutablePauliSetMeasurement that corresponds to the grouping result of the operator.

  • shots_map (dict[core.operator.pauli.CommutablePauliSet, int]) – A dictionary whose key is the commuting pauli set and the value is the shot count assigned to the commuting pauli set.

Return type:

Iterable[tuple[NonParametricQuantumCircuit, int]]