Skip to main content
IBM Quantum Platform
이 페이지는 Qiskit Runtime client의 이전 버전입니다. 최신 버전으로 이동

SamplerV2

class SamplerV2(mode=None, options=None)

GitHub

Bases: BasePrimitiveV2[SamplerOptions], Sampler, BaseSamplerV2

Class for interacting with Qiskit Runtime Sampler primitive service.

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

Qiskit Runtime 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.

Initializes the Sampler primitive.

Parameters

  • mode (Optional[Union[BackendV2, Session, Batch]]) –

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

    • A Backend if you are using job mode.
    • A Session if you are using session execution mode.
    • A Batch if you are using batch execution mode.

    Refer to the Qiskit Runtime documentation. for more information about the Execution modes.

  • options (Optional[Union[Dict, SamplerOptions]]) – Sampler options, see 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

유형: SamplerOptions

Return options

version

기본값: 2


Methods

backend

backend()

GitHub

Return the backend the primitive query will be run on.

Return type

BackendV2

run

run(pubs, *, shots=None)

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.

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에서 버그, 오타를 보고하거나 컨텐츠를 요청하십시오.