qrunch.quantum.estimators.backend_estimator

Module with implementations of estimator.

Classes

BackendEstimator

Class for estimating observables.

class BackendEstimator

Bases: Estimator

Class for estimating observables.

__init__(sampler: Sampler, grouper: MeasurementGrouper | None = None, error_mitigator: EstimatorErrorMitigator | None = None, measurement_cache: MeasurementCache | None = None) None

Initialize estimator on the specified backend.

Parameters:
  • sampler (Sampler) – The sampler used for the calculations.

  • grouper (MeasurementGrouper | None) – How to group the terms in the observable.

  • error_mitigator (EstimatorErrorMitigator | None) – Error mitigator to be used for encoding the observable or circuit more error resistantly.

  • measurement_cache (MeasurementCache | None) – Cache to use for storing and reusing measurements and expectation values.

Return type:

None

clear_cache() None

Clear the measurement cache.

Return type:

None

get_sampler() Sampler

Get the sampler used in the estimator.

Return type:

Sampler

has_spin_particle_conservation() bool

Return True, if the estimator is set to use spin particle conservation.

Return type:

bool

has_total_particle_conservation() bool

Return True, if the estimator is set to use total particle conservation.

Return type:

bool

run(observables: Sequence[int | float | complex | Expression[PauliOperators]] | int | float | complex | Expression[PauliOperators] | Sequence[HermitianPauliSum] | HermitianPauliSum, circuits: Circuit | Sequence[Circuit], shots: int | ShotsPerGroup | None) ExpectationValue | list[ExpectationValue] | EstimatorResults

Estimate the value of the observables using the circuit state.

For each observable the following will be calculated: <circuit|observable|circuit>.

Parameters:
Return type:

ExpectationValue | list[ExpectationValue] | EstimatorResults

validate_shots_type(shots_type: Type[int | ShotsPerGroup | None]) list[str]

Validate that the sampler 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]

verify_backend_works() None

Verify that the backend works by running a simple circuit.

The circuit is run on the actual hardware, so this requires a valid token and may take some time and cost a small number of credits.

Return type:

None