qiskit-documentation/docs/api/qiskit/1.2/qiskit.primitives.BaseSampl...

42 lines
2.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: BaseSamplerV2 (v1.2)
description: API reference for qiskit.primitives.BaseSamplerV2 in qiskit v1.2
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.primitives.BaseSamplerV2
---
# BaseSamplerV2
<Class id="qiskit.primitives.BaseSamplerV2" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/primitives/base/base_sampler.py#L180-L204" signature="qiskit.primitives.BaseSamplerV2" modifiers="class">
Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "(in Python v3.13)")
Sampler V2 base class.
A Sampler returns samples of quantum circuit outputs.
All sampler implementations must implement default value for the `shots` in the [`run()`](#qiskit.primitives.BaseSamplerV2.run "qiskit.primitives.BaseSamplerV2.run") method if `None` is given both as a `kwarg` and in all of the pubs.
## Methods
### run
<Function id="qiskit.primitives.BaseSamplerV2.run" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/primitives/base/base_sampler.py#L189-L204" signature="run(pubs, *, shots=None)" modifiers="abstract">
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*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) The total number of shots to sample for each sampler pub that does not specify its own shots. If `None`, the primitives default shots value will be used, which can vary by implementation.
**Returns**
The job object of Samplers result.
**Return type**
[BasePrimitiveJob](qiskit.primitives.BasePrimitiveJob "qiskit.primitives.BasePrimitiveJob")\[[PrimitiveResult](qiskit.primitives.PrimitiveResult "qiskit.primitives.PrimitiveResult")\[[SamplerPubResult](qiskit.primitives.SamplerPubResult "qiskit.primitives.SamplerPubResult")]]
</Function>
</Class>