English
Languages
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

BackendSampler

class BackendSampler(backend, options=None, bound_pass_manager=None, skip_transpilation=False)[source]

Bases: qiskit.primitives.base.base_sampler.BaseSampler

A BaseSampler implementation that provides an interface for leveraging the sampler interface from any backend.

This class provides a sampler interface from any backend and doesn’t do any measurement mitigation, it just computes the probability distribution from the counts. It facilitates using backends that do not provide a native BaseSampler implementation in places that work with BaseSampler, such as algorithms in qiskit.algorithms including SamplingVQE. However, if you’re using a provider that has a native implementation of BaseSampler, it is a better choice to leverage that native implementation as it will likely include additional optimizations and be a more efficient implementation. The generic nature of this class precludes doing any provider- or backend-specific optimizations.

Initialize a new BackendSampler

Parameters
  • backend (BackendV1 | BackendV2) – Required: the backend to run the sampler primitive on

  • options (dict | None) – Default options.

  • bound_pass_manager (PassManager | None) – An optional pass manager to run after parameter binding.

  • skip_transpilation (bool) – If this is set to True the internal compilation of the input circuits is skipped and the circuit objects will be directly executed when this objected is called.

Raises

ValueError – If backend is not provided

Methods

close

Close the session and free resources

run

Run the job of the sampling of bitstrings.

set_options

Set options values for the estimator.

set_transpile_options

Set the transpiler options for transpiler.

Attributes

backend

Returns: The backend which this sampler object based on

Return type

BackendV1 | BackendV2

circuits

Quantum circuits to be sampled.

Returns

The quantum circuits to be sampled.

options

Return options values for the estimator.

Return type

Options

Returns

options

parameters

Parameters of quantum circuits.

Returns

List of the parameters in each quantum circuit.

preprocessed_circuits

Preprocessed quantum circuits produced by preprocessing :returns: List of the transpiled quantum circuit

Raises

QiskitError – if the instance has been closed.

transpile_options

Return the transpiler options for transpiling the circuits.

Return type

Options

transpiled_circuits

Transpiled quantum circuits. :returns: List of the transpiled quantum circuit

Raises

QiskitError – if the instance has been closed.