About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
BackendSampler
class qiskit.primitives.BackendSampler(backend, options=None, bound_pass_manager=None, skip_transpilation=False)
Bases: BaseSampler
[PrimitiveJob
[SamplerResult
]]
A BaseSampler
(V1) implementation that provides a wrapper for leveraging the Sampler V1 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
V1 implementation in places that work with BaseSampler
V1. However, if you’re using a provider that has a native implementation of BaseSamplerV1
( BaseSampler
) or BaseESamplerV2
, 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 (V1) instance
Deprecated since version 1.2
The class qiskit.primitives.backend_sampler.BackendSampler
is deprecated as of qiskit 1.2. It will be removed no earlier than 3 months after the release date. All implementations of the BaseSamplerV1 interface have been deprecated in favor of their V2 counterparts. The V2 alternative for the BackendSampler class is BackendSamplerV2.
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
Attributes
backend
Returns: The backend which this sampler object based on
options
Return options values for the estimator.
Returns
options
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.
transpiled_circuits
Transpiled quantum circuits. :returns: List of the transpiled quantum circuit
Raises
QiskitError – if the instance has been closed.
Methods
run
run(circuits, parameter_values=None, **run_options)
Run the job of the sampling of bitstrings.
Parameters
- circuits (QuantumCircuit | Sequence[QuantumCircuit]) – One of more circuit objects.
- parameter_values (Sequence[float] | Sequence[Sequence[float]] | None) – Parameters to be bound to the circuit.
- run_options – Backend runtime options used for circuit execution.
Returns
The job object of the result of the sampler. The i-th result corresponds to circuits[i]
evaluated with parameters bound as parameter_values[i]
.
Raises
ValueError – Invalid arguments are given.
Return type
T
set_options
set_options(**fields)
Set options values for the estimator.
Parameters
**fields – The fields to update the options
set_transpile_options
set_transpile_options(**fields)
Set the transpiler options for transpiler. :param **fields: The fields to update the options.
Returns
self.
Raises
QiskitError – if the instance has been closed.
Was this page helpful?
Report a bug or request content on GitHub.