---
title: BaseSamplerV2 (latest version)
description: API reference for qiskit.primitives.BaseSamplerV2 in the latest version of qiskit
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/qiskit.primitives.BaseSamplerV2
---

# BaseSamplerV2

*class* `qiskit.primitives.BaseSamplerV2`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/primitives/base/base_sampler.py#L35-L74)

Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC)

Base class for `SamplerV2` implementations.

A Sampler returns samples of quantum circuit outputs. Implementations of this [`BaseSamplerV2`](#qiskit.primitives.BaseSamplerV2 "qiskit.primitives.BaseSamplerV2") interface must define their own [`run()`](#qiskit.primitives.BaseSamplerV2.run "qiskit.primitives.BaseSamplerV2.run") method, which is designed to take the following inputs:

> - **pubs: list of pubs (Primitive Unified Blocs). A sampler pub is a list or tuple**
>
>   of two to three elements that define the unit of work for the sampler. These are:
>
>   > - A single [`QuantumCircuit`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit"), possibly parameterized.
>   > - A collection parameter value sets to bind the circuit against if it is parametric.
>   > - Optionally, the number of shots to sample.
>
> - **shots: the number of shots to sample. This specification is optional and will be overridden by**
>
>   the pub-wise shots if provided.

All sampler implementations must implement default value for the `shots` in the [`run()`](#qiskit.primitives.BaseSamplerV2.run "qiskit.primitives.BaseSamplerV2.run") method. This default value will be used any time `shots=None` is specified, which can take place in the [`run()`](#qiskit.primitives.BaseSamplerV2.run "qiskit.primitives.BaseSamplerV2.run") kwargs or at the pub level.

## Methods

### run

*abstractmethod* `run(pubs, *, shots=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/primitives/base/base_sampler.py#L59-L74)

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) *| 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**

[BasePrimitiveJob](/docs/api/qiskit/qiskit.primitives.BasePrimitiveJob "qiskit.primitives.BasePrimitiveJob")\[[PrimitiveResult](/docs/api/qiskit/qiskit.primitives.PrimitiveResult "qiskit.primitives.PrimitiveResult")\[[SamplerPubResult](/docs/api/qiskit/qiskit.primitives.SamplerPubResult "qiskit.primitives.SamplerPubResult")]]
