qiskit/releasenotes/notes/0.22/add-gradients-with-primitiv...

35 lines
1.3 KiB
YAML

---
features:
- |
Added a new module :mod:`qiskit.algorithms.gradients` that contains
classes which are used to compute gradients using the primitive
interfaces defined in :mod:`qiskit.primitives`. There are 4 types of
gradient classes: Finite Difference, Parameter Shift, Linear
Combination of Unitary, and SPSA with implementations that either use
an instance of the :class:`~.BaseEstimator` interface:
* :class:`~.ParamShiftEstimatorGradient`
* :class:`~.LinCombEstimatorGradient`
* :class:`~.FiniteDiffEstimatorGradient`
* :class:`~.SPSAEstimatorGradient`
or an instance of the :class:`~.BaseSampler` interface:
* :class:`~.ParamShiftSamplerGradient`
* :class:`~.LinCombSamplerGradient`
* :class:`~.FiniteDiffSamplerGradient`
* :class:`~.SPSASamplerGradient`
The estimator-based gradients compute the gradient of expectation
values, while the sampler-based gradients return gradients of the
measurement outcomes (also referred to as "probability gradients").
For example:
.. code-block:: python
estimator = Estimator(...)
gradient = ParamShiftEstimatorGradient(estimator)
job = gradient.run(circuits, observables, parameters)
gradients = job.result().gradients