qiskit/releasenotes/notes/0.22/vqe-with-estimator-primitiv...

41 lines
1.6 KiB
YAML

---
features:
- |
Added the :class:`qiskit.algorithms.minimum_eigensolvers` package to include interfaces for
primitive-enabled algorithms. :class:`~qiskit.algorithms.minimum_eigensolvers.VQE` has been
refactored in this implementation to leverage primitives.
To use the new implementation with a reference primitive, one can do, for example:
.. code-block:: python
from qiskit.algorithms.minimum_eigensolvers import VQE
from qiskit.algorithms.optimizers import SLSQP
from qiskit.circuit.library import TwoLocal
from qiskit.primitives import Estimator
from qiskit.quantum_info import SparsePauliOp
h2_op = SparsePauliOp(
["II", "IZ", "ZI", "ZZ", "XX"],
coeffs=[
-1.052373245772859,
0.39793742484318045,
-0.39793742484318045,
-0.01128010425623538,
0.18093119978423156,
],
)
estimator = Estimator()
ansatz = TwoLocal(rotation_blocks=["ry", "rz"], entanglement_blocks="cz")
optimizer = SLSQP()
vqe = VQE(estimator, ansatz, optimizer)
result = vqe.compute_minimum_eigenvalue(h2_op)
eigenvalue = result.eigenvalue
Note that the evaluated auxillary operators are now obtained via the
``aux_operators_evaluated`` field on the results. This will consist of a list or dict of
tuples containing the expectation values for these operators, as we well as the metadata from
primitive run. ``aux_operator_eigenvalues`` is no longer a valid field.