qrunch.quantum.samplers
Contains the logic for quantum state samplers, either through a Backend or simulation.
Classes
Builder for all types of samplers available. |
- class ExcitationGateSampler
Bases:
SamplerSampler class for sampling from an “excitation-gate-circuit”.
- __init__(options: ExcitationGateSimulatorOptions | None = None) None
Initiate an instance of sampler.
- Parameters:
options (ExcitationGateSimulatorOptions | None) – Options for the simulator.
eps – Minimum probability to use when sampling.
- Return type:
None
- run(circuits: MeasurementCircuit | Sequence[MeasurementCircuit], shots: int | None) QuantumMeasurement | list[QuantumMeasurement]
Sample from the given circuits using the given number of shots.
- Parameters:
circuits (MeasurementCircuit | Sequence[MeasurementCircuit]) – Measurement circuit or sequence of circuits to be sampled.
shots (int | None) – Number of measurements to perform.
- Returns:
The measurements of the quantum circuits, or list of measurements if multiple circuits are given.
- Return type:
QuantumMeasurement | list[QuantumMeasurement]
- supports_shots_equals_none() bool
Return whether the sampler supports shots = None.
The ExcitationGateSampler supports shots=None.
- Return type:
bool
- class SamplerCreator
Bases:
objectBuilder for all types of samplers available. Default is the ExcitationGateSampler.
- static backend() BackendSamplerCreator
Narrow the sampler type to a backend sampler.
A backend sampler uses one of the available quantum or simulation backends to run and sample from the quantum circuit.
- Return type:
- static create() ExcitationGateSampler
Create an instance of
ExcitationGateSampler.- Return type:
- static excitation_gate() ExcitationGateSamplerCreator
Narrow the sampler type to an excitation gate sampler.
This sampler uses Kvantify’s proprietary simulator optimized for circuits built from excitation gates, and thus tailored specifically for quantum chemistry applications. It is thus the recommended sampler for simulating quantum algorithms for quantum chemistry.
- Return type:
- static memory_restricted() MemoryRestrictedSamplerCreator
Narrow the sampler type to a memory restricted sampler.
This sampler is a memory-efficient version that uses Kvantify’s of proprietary simulator optimized for circuits built from excitation gates, and thus tailored specifically for quantum chemistry applications. It uses a configurable maximum amount of memory to enable simulation of larger systems than the excitation gate sampler, switching to a more memory-efficient mode when the limit is reached.
For small systems where the full state vector can be stored in memory, the excitation gate sampler will typically be faster, but for larger systems where the full state vector cannot be stored in memory, or is too slow, this simulator will enable simulation of larger systems at the cost of some precision.
- Return type:
- sampler_creator() SamplerCreator
Start creating a sampler.
- Return type:
Modules
Module for backend sampler. |
|
Builder classes for creating samplers for all available samplers. |
|
Module for excitation gate sampler. |
|
Module containing the a memory restricted estimator. |
|
Module for implementing Sampler for counting shots of running on quantum hardware. |
|
Protocols for the samplers. |