About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
BackendSamplerV2
class qiskit.primitives.BackendSamplerV2(*, backend, options=None)
Bases: BaseSamplerV2
Evaluates bitstrings for provided quantum circuits
The BackendSamplerV2
class is a generic implementation of the BaseSamplerV2
interface that is used to wrap a BackendV2
(or BackendV1
) object in the class BaseSamplerV2
API. It facilitates using backends that do not provide a native BaseSamplerV2
implementation in places that work with BaseSamplerV2
. However, if you’re using a provider that has a native implementation of BaseSamplerV2
, it is a better choice to leverage that native implementation as it will likely include additional optimizations and be a more efficient implementation. The generic nature of this class precludes doing any provider- or backend-specific optimizations.
This class does not perform any measurement or gate mitigation.
Each tuple of (circuit, <optional> parameter values, <optional> shots)
, called a sampler primitive unified bloc (PUB), produces its own array-valued result. The run()
method can be given many pubs at once.
The options for BackendSamplerV2
consist of the following items.
default_shots
: The default shots to use if none are specified inrun()
. Default: 1024.seed_simulator
: The seed to use in the simulator. If None, a random seed will be used. Default: None.
Note
This class requires a backend that supports memory
option.
Parameters
- backend (BackendV1 |BackendV2) – The backend to run the primitive on.
- options (dict | None) – The options to control the default shots (
default_shots
) and the random seed for the simulator (seed_simulator
).
Attributes
backend
Returns the backend which this sampler object based on.
options
Return the options
Methods
run
run(pubs, *, shots=None)
Run and collect samples from each pub.
Parameters
- pubs (Iterable[SamplerPubLike]) – An iterable of pub-like objects. For example, a list of circuits or tuples
(circuit, parameter_values)
. - shots (int | None) – The total number of shots to sample for each sampler pub that does not specify its own shots. If
None
, the primitive’s default shots value will be used, which can vary by implementation.
Returns
The job object of Sampler’s result.
Return type
Was this page helpful?
Report a bug or request content on GitHub.