This page was generated from docs/tutorials/12_gradients_framework.ipynb.
This tutorial demonstrates the use of the
qiskit_algorithms.gradients module to evaluate quantum gradients using the Qiskit Primitives.
and sampling probabilities of the form
A quick refresher on Qiskit Primitives#
The Qiskit Primitives work as an abstraction level between algorithms and (real/simulated) quantum devices. Instead of having to manually deal with tasks such as parameter binding or circuit transpilation, the
primitives module offers a
Sampler and an
Estimator class that take the circuits, the observable Hamiltonians, and the circuit parameters and return the sampling distribution and the computed expectation values respectively.
qiskit.primitives provides two classes for evaluating the circuit: - The
Estimator class allows to evaluate expectation values of observables with respect to states prepared by quantum circuits. - The
Sampler class returns quasi-probability distributions as a result of sampling quantum circuits.
qiskit_algorithms.gradients module contains tools to compute both circuit gradients and circuit metrics. The gradients extend the
BaseSamplerGradient base classes. These are abstract classes on top of which different gradient methods have been implemented. The methods currently available in this module are: - Parameter Shift Gradients - Finite Difference Gradients - Linear Combination of Unitaries Gradients - Simultaneous Perturbation Stochastic
Approximation (SPSA) Gradients
Additionally, the module offers reverse gradients for efficient classical computations.
The metrics available are based on the notion of the Quantum Geometric Tensor (QGT). There is a
BaseQGT class (
Estimator-based) on top of which different QGT methods have been implemented: - Linear Combination of Unitaries QGT - Reverse QGT (classical) As well as a Quantum Fisher Information class (QFI) that is initialized with a reference QGT implementation from the above list.