qrunch.quantum.estimators.tensor_network_estimator

Tensor network estimator.

Classes

TensorNetworkEstimator

Estimator implementation using tensor network contraction.

class TensorNetworkEstimator

Bases: Estimator

Estimator implementation using tensor network contraction.

This estimator computes expectation values of observables by representing quantum circuits as tensor networks and contracting them. Exact estimation (shots=None) uses the estimator algorithm, while estimation with shots samples the circuit using the sampler algorithm.

__init__(estimator_algorithm: TensorNetworkEstimatorAlgorithm, sampler_algorithm: TensorNetworkSamplerAlgorithm, grouper: MeasurementGrouper | None = None, error_mitigator: EstimatorErrorMitigator | None = None, measurement_cache: MeasurementCache | None = None) → None

Initialize a tensor network estimator.

Parameters:
  • estimator_algorithm (TensorNetworkEstimatorAlgorithm) – Algorithm for tensor network contraction and estimation.

  • sampler_algorithm (TensorNetworkSamplerAlgorithm) – Algorithm for tensor network sampling.

  • grouper (MeasurementGrouper | None) – Grouper used to group the observables into measurable partitions when estimating with shots.

  • error_mitigator (EstimatorErrorMitigator | None) – Optional error mitigation strategy to apply.

  • measurement_cache (MeasurementCache | None) – Optional cache for storing and reusing measurement results.

Return type:

None

clear_cache() → None

Clear the measurement cache.

Return type:

None

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

supports_diagonal_weighted_z_strings(shots: int | ShotsPerGroup | None) → bool

Return whether _run_diagonal_weighted_z_strings() can be used with the given shots.

Parameters:

shots (int | ShotsPerGroup | None) – The shots that would be used in the estimation.

Return type:

bool

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]