qiskit/releasenotes/notes/0.22/primitive-run-5d1afab365533...

47 lines
2.0 KiB
YAML

---
features:
- |
Added new methods for executing primitives: :meth:`.BaseSampler.run` and :meth:`.BaseEstimator.run`.
These methods execute asynchronously and return :class:`.JobV1` objects which
provide a handle to the exections. These new run methods can be passed :class:`~.QuantumCircuit`
objects (and observables for :class:`~.BaseEstimator`) that are not registered in the constructor.
For example::
estimator = Estimator()
result = estimator.run(circuits, observables, parameter_values).result()
This provides an alternative to the previous execution model (which is now deprecated) for the
:class:`~.BaseSampler` and :class:`~.BaseEstimator` primitives which would take all the inputs via
the constructor and calling the primitive object with the combination of those input parameters
to use in the execution.
deprecations:
- |
The method of executing primitives has been changed.
The :meth:`.BaseSampler.__call__` and
:meth:`.BaseEstimator.__call__` methods were deprecated.
For example::
estimator = Estimator(...)
result = estimator(circuits, observables, parameters)
sampler = Sampler(...)
result = sampler(circuits, observables, parameters)
should be rewritten as
.. code-block:: python
estimator = Estimator()
result = estimator.run(circuits, observables, parameter_values).result()
sampler = Sampler()
result = sampler.run(circuits, parameter_values).result()
Using primitives as context managers is deprecated.
Not all primitives have a context manager available. When available (e.g. in ``qiskit-ibm-runtime``),
the session's context manager provides equivalent functionality.
``circuits``, ``observables``, and ``parameters`` in the constructor was deprecated.
``circuits`` and ``observables`` can be passed from ``run`` methods.
``run`` methods do not support ``parameters``. Users need to resort parameter values by themselves.