Skip to main content
IBM Quantum Platform
翻訳情報

このページの追加言語翻訳は近日公開予定です。

SamplerV2

class SamplerV2(mode=None, options=None)

GitHub

Bases: BasePrimitiveV2[SamplerOptions], Sampler, 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() method can be used to submit circuits and parameters to the Sampler primitive.

Parameters


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

Return options.

version

Default value: 2


Methods

backend

backend()

GitHub

Return the backend the primitive query will be run on.

Return type

BackendV2

run

run(pubs, *, shots=None, dry_run=False)

GitHub

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.
  • dry_run (bool) – If True, performs a dry run without executing the job on a QPU. This mode can be used to validate the job, estimate usage consumption, and retrieve circuit timing metadata. Returned results preserve the expected schema but contain randomized mock data rather than actual or simulated measurement results. Unlike the fake backends, the processing of this dry run happens on the server-side, so the job may not finish immediately and access to this feature may be restricted.

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

このページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。