qrunch.quantum.estimators.creators

Contains builders for all available estimators .

Classes

BackendEstimatorCreator

Builder for the backend estimator.

ExcitationGateEstimatorCreator

Builder for the excitation gate estimator.

MemoryRestrictedEstimatorCreator

Builder for the memory restricted estimator.

QiskitStateVectorEstimatorCreator

Builder for the Qiskit state vector estimator.

class BackendEstimatorCreator

Bases: object

Builder for the backend estimator.

__init__() None

Initialize a backend estimator builder.

Return type:

None

choose_backend() BackendSubCreator[Self]

Choose the backend to use for the estimator.

Return type:

BackendSubCreator[Self]

choose_estimator_error_mitigator() EstimatorErrorMitigatorSubCreator[Self]

Add an error mitigator to use with the estimation.

Return type:

EstimatorErrorMitigatorSubCreator[Self]

choose_grouper() MeasurementGrouperSubCreator[Self]

Choose the grouper to use for the estimator.

Return type:

MeasurementGrouperSubCreator[Self]

choose_sampler_error_mitigator() SamplerErrorMitigatorSubCreator[Self]

Choose the error mitigator to use with the backend.

Return type:

SamplerErrorMitigatorSubCreator[Self]

create(*, with_shot_counter: Literal[False] = False) BackendEstimator
create(*, with_shot_counter: Literal[True]) EstimatorShotCounter

Create the configured estimator.

Parameters:

with_shot_counter – Whether to include a shot counter in the estimator. This will instead return a EstimatorShotCounter wrapped around the BackendEstimator.

with_measurement_cache(measurement_cache: MeasurementCache) Self

Add an cache to use with the estimator.

Parameters:

measurement_cache (MeasurementCache) – The cache to use.

Return type:

Self

class ExcitationGateEstimatorCreator

Bases: object

Builder for the excitation gate estimator.

__init__() None

Initialize an excitation gate estimator builder.

Return type:

None

choose_estimator_error_mitigator() EstimatorErrorMitigatorSubCreator[Self]

Add an error mitigator to use with the estimation.

Return type:

EstimatorErrorMitigatorSubCreator[Self]

choose_grouper() MeasurementGrouperSubCreator[Self]

Choose the grouper to use for the estimator.

Return type:

MeasurementGrouperSubCreator[Self]

create(*, with_shot_counter: Literal[False] = False) ExcitationGateEstimator
create(*, with_shot_counter: Literal[True]) EstimatorShotCounter

Create the configured estimator.

Parameters:

with_shot_counter – Whether to include a shot counter in the estimator. This will instead return a EstimatorShotCounter wrapped around the ExcitationGateEstimator.

with_eps(eps: float | None) Self

Choose epsilon to use as lower bound for absolute value of amplitude when sampling in the estimator.

Parameters:

eps (float | None) – Epsilon to use as lower bound for absolute amplitude when sampling.

Return type:

Self

with_float_type(float_type: Literal['f32', 'f64']) Self

Chose the float type precision used in the estimator.

Parameters:

float_type (Literal['f32', 'f64']) – Float type to use.

Return type:

Self

with_parallel_setting(parallel_setting: Literal['serial', 'parallel']) Self

Choose parallel setting to use in the estimator.

Parameters:

parallel_setting (Literal['serial', 'parallel']) – Parallel setting to use.

Return type:

Self

with_seed(seed: int | None) Self

Choose seed to use for randomness in the estimator.

Parameters:

seed (int | None) – Seed used to initialize internal randomness in the simulator.

Return type:

Self

with_spin_particle_conservation() Self

Specify that the number of spin up and spin down particles are conserved separately (fermionic encoding).

Excitation gates are expected to conserve the number of particles in each half of the circuit.

This is the case of fermionic encoding where half the number of qubits represent spin up orbitals, while the other half represent spin down orbitals. Thus excitation gates represents spin conserving gates.

In case of hard-core bosonic encoding the qubits represent spatial orbitals (occupied by electron pairs) and thus the total number of (electron-pair) particles are conserved, thus total particle conservation must be used.

Return type:

Self

with_total_particle_conservation() Self

Specify that the total number of particles are conserved (bosonic encoding).

Excitation gates are expected to conserve the total number of particles, but not necessarily the number of particles in each half.

This is the case of hard-core bosonic encoding where the qubits represents spatial orbitals (occupied by electron pairs) and thus the total number of (electron-pair) particles are conserved.

In case of fermionic encoding half the number of qubits represent spin up orbitals, while the other half represent spin down orbitals, and spin particle conservation must be used.

Return type:

Self

class MemoryRestrictedEstimatorCreator

Bases: object

Builder for the memory restricted estimator.

__init__() None

Initialize a memory restricted estimator builder.

Return type:

None

choose_estimator_error_mitigator() EstimatorErrorMitigatorSubCreator[Self]

Add an error mitigator to use with the estimation.

Return type:

EstimatorErrorMitigatorSubCreator[Self]

create(*, with_shot_counter: Literal[False] = False) MemoryRestrictedEstimator
create(*, with_shot_counter: Literal[True]) EstimatorShotCounter

Create the configured estimator.

Parameters:

with_shot_counter – Whether to include a shot counter in the estimator. This will instead return a EstimatorShotCounter wrapped around the MemoryRestrictedEstimator.

with_max_memory(max_memory_usage_in_kb: int) Self

Set the maximum allowed memory for the statevector in the estimator.

Arg:

max_memory_usage_in_kb: Maximum memory allowed by the estimator measured in kilobytes.

Parameters:

max_memory_usage_in_kb (int)

Return type:

Self

with_options(options: MemoryRestrictedSimulatorOptions) Self

Set options for the estimator to use.

Arg:

options: Options for the MemoryRestrictedEstimator to use.

Parameters:

options (MemoryRestrictedSimulatorOptions)

Return type:

Self

with_precise_defaults() Self

Set all options to a precise default version of the MemoryRestrictedEstimator.

This estimator raises a warning if the simulation can not be done accurately enough. The precise default is 1,000,000 amplitudes.

Return type:

Self

with_quick_defaults() Self

Set all options to a quick but imprecise default version of the MemoryRestrictedEstimator.

The quick defaults are 1000 amplitudes and warnings are suppressed.

Return type:

Self

class QiskitStateVectorEstimatorCreator

Bases: object

Builder for the Qiskit state vector estimator.

static create() QiskitStateVectorEstimator

Create an instance of QiskitStateVectorEstimator.

Return type:

QiskitStateVectorEstimator