- class CircuitSampler(backend, statevector=None, param_qobj=False, attach_results=False, caching='last')¶
Deprecated: The CircuitSampler traverses an Operator and converts any CircuitStateFns into approximations of the state function by a DictStateFn or VectorStateFn using a quantum backend. Note that in order to approximate the value of the CircuitStateFn, it must 1) send state function through a depolarizing channel, which will destroy all phase information and 2) replace the sampled frequencies with square roots of the frequency, rather than the raw probability of sampling (which would be the equivalent of sampling the square of the state function, per the Born rule.
The CircuitSampler aggressively caches transpiled circuits to handle re-parameterization of the same circuit efficiently. If you are converting multiple different Operators, you are better off using a different CircuitSampler for each Operator to avoid cache thrashing.
Obsolète depuis la version 0.24.0: The class
qiskit.opflow.converters.circuit_sampler.CircuitSampleris deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit https://qisk.it/opflow_migration.
statevector (Optional[bool]) – If backend is a statevector backend, whether to replace the CircuitStateFns with DictStateFns (from the counts) or VectorStateFns (from the statevector).
Nonewill set this argument automatically based on the backend.
attach_results (bool) – Whether to attach the data from the backend
Resultsobject for a given
execution_resultsfield added the converted
param_qobj (bool) – Whether to use Aer’s parameterized Qobj capability to avoid re-assembling the circuits.
caching (str) – The caching strategy. Can be “last” (default) to store the last operator that was converted, set to “all” to cache all processed operators.
ValueError – Set statevector or param_qobj True when not supported by backend.
Methods Defined Here
Clear the cache of sampled operator expressions.
Converts the Operator to one in which the CircuitStateFns are replaced by DictStateFns or VectorStateFns.
Samples the CircuitStateFns and returns a dict associating their
id()values to their replacement DictStateFn or VectorStateFn.
Returns the quantum instance.
The QuantumInstance used by the CircuitSampler