mirror of https://github.com/Qiskit/qiskit.git
51 lines
2.1 KiB
YAML
51 lines
2.1 KiB
YAML
---
|
|
features:
|
|
- |
|
|
Added :mod:`qiskit.algorithms.eigensolvers` package to include
|
|
interfaces for primitive-enabled algorithms. This new module
|
|
will eventually replace the previous ``qiskit.algorithms.eigen_solvers``.
|
|
This new module contains an alternative implementation of the
|
|
:class:`~qiskit.algorithms.eigensolvers.VQD` which instead of taking
|
|
a backend or :class:`~.QuantumInstance` instead takes an instance of
|
|
:class:`~.BaseEstimator`, including :class:`~.Estimator`,
|
|
:class:`~.BackendEstimator`, or any provider implementations such as
|
|
those as those present in ``qiskit-ibm-runtime`` and ``qiskit-aer``.
|
|
|
|
For example, to use the new implementation with an instance of
|
|
:class:`~.Estimator` class:
|
|
|
|
.. code-block:: python
|
|
|
|
from qiskit.algorithms.eigensolvers import VQD
|
|
from qiskit.algorithms.optimizers import SLSQP
|
|
from qiskit.circuit.library import TwoLocal
|
|
from qiskit.primitives import Sampler, Estimator
|
|
from qiskit.algorithms.state_fidelities import ComputeUncompute
|
|
from qiskit.opflow import PauliSumOp
|
|
from qiskit.quantum_info import SparsePauliOp
|
|
|
|
h2_op = PauliSumOp(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()
|
|
fidelity = ComputeUncompute(Sampler())
|
|
|
|
vqd = VQD(estimator, fidelity, ansatz, optimizer, k=2)
|
|
result = vqd.compute_eigenvalues(h2_op)
|
|
eigenvalues = result.eigenvalues
|
|
|
|
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.
|