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

# SamplerV2

*class* `SamplerV2(mode=None, options=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/sampler.py#L47-L134)

Bases: `BasePrimitiveV2`\[[`SamplerOptions`](/docs/api/qiskit-ibm-runtime/options-sampler-options "qiskit_ibm_runtime.options.sampler_options.SamplerOptions")], `Sampler`, [`BaseSamplerV2`](/docs/api/qiskit/qiskit.primitives.BaseSamplerV2)

SamplerV2 primitive for IBM Quantum Compute (formerly Qiskit Runtime).

This class supports version 2 of the Sampler interface, which uses different input and output formats than version 1.

IBM Quantum Compute Sampler primitive returns the sampled result according to the specified output type. For example, it returns a bitstring for each shot if measurement level 2 (bits) is requested.

The [`run()`](#qiskit_ibm_runtime.SamplerV2.run "qiskit_ibm_runtime.SamplerV2.run") method can be used to submit circuits and parameters to the Sampler primitive.

**Parameters**

- **mode** (*BackendV2 |* [*Session*](/docs/api/qiskit-ibm-runtime/session "qiskit_ibm_runtime.Session")  *|*[*Batch*](/docs/api/qiskit-ibm-runtime/batch "qiskit_ibm_runtime.Batch") *| None*) –

  The execution mode used to make the primitive query. It can be:

  - A `Backend` if you are using job mode.
  - A [`Session`](/docs/api/qiskit-ibm-runtime/session "qiskit_ibm_runtime.Session") if you are using session execution mode.
  - A [`Batch`](/docs/api/qiskit-ibm-runtime/batch "qiskit_ibm_runtime.Batch") if you are using batch execution mode.

  Refer to the [IBM Quantum Compute documentation](/docs/guides/execution-modes) for more information about the `Execution modes`.

- **options** (*dict |* [*SamplerOptions*](/docs/api/qiskit-ibm-runtime/options-sampler-options "qiskit_ibm_runtime.options.SamplerOptions") *| None*) – Sampler options, see [`qiskit_ibm_runtime.options.SamplerOptions`](/docs/api/qiskit-ibm-runtime/options-sampler-options "qiskit_ibm_runtime.options.SamplerOptions") for detailed description.

## Attributes

### mode

Return the execution mode used by this primitive.

**Returns**

Mode used by this primitive, or `None` if an execution mode is not used.

### options

Type: [`SamplerOptions`](/docs/api/qiskit-ibm-runtime/options-sampler-options "qiskit_ibm_runtime.options.SamplerOptions")

Return options.

### version

Default value: `2`

## Methods

### backend

`backend()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/base_primitive.py#L213-L215)

Return the backend the primitive query will be run on.

**Return type**

[*BackendV2*](/docs/api/qiskit/qiskit.providers.BackendV2)

### run

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

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/sampler.py#L90-L121)

Submit a request to the sampler primitive.

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

Submitted job. The result of the job is an instance of `qiskit.primitives.containers.PrimitiveResult`.

**Raises**

**ValueError** – Invalid arguments are given.

**Return type**

[RuntimeJobV2](/docs/api/qiskit-ibm-runtime/runtime-job-v2 "qiskit_ibm_runtime.RuntimeJobV2")
