qrunch.quantum.samplers.tensor_network_sampler
Module for tensor network sampler.
Classes
Sampler implementation using tensor network contraction. |
- class TensorNetworkSampler
Bases:
SamplerSampler implementation using tensor network contraction.
This sampler generates measurement outcomes by representing quantum circuits as tensor networks and computing probability distributions or sampling from them. Supports both exact probability computation (shots=None) and finite sampling.
- __init__(sampler_algorithm: TensorNetworkSamplerAlgorithm, error_mitigator: SamplerErrorMitigator | None = None, measurement_cache: MeasurementCache | None = None) None
Initialize a tensor network sampler.
- Parameters:
sampler_algorithm (TensorNetworkSamplerAlgorithm) – Algorithm for tensor network contraction and sampling.
error_mitigator (SamplerErrorMitigator | 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
- run(circuits: MeasurementCircuit | Sequence[MeasurementCircuit]) QuantumMeasurement | list[QuantumMeasurement]
Start job for sampling on the given circuits a given number of times.
- Parameters:
circuits (MeasurementCircuit | Sequence[MeasurementCircuit]) – Measurement circuit or sequence of circuits to be sampled.
- Return type:
QuantumMeasurement | list[QuantumMeasurement]
- validate_shots_type(shots_type: Type[int | 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 | None])
- Return type:
list[str]