# VQE¶

class VQE(estimator, ansatz, optimizer, *, gradient=None, initial_point=None, callback=None)[source]

Bases : VariationalAlgorithm, MinimumEigensolver

The variational quantum eigensolver (VQE) algorithm.

VQE is a hybrid quantum-classical algorithm that uses a variational technique to find the minimum eigenvalue of a given Hamiltonian operator $$H$$.

The VQE algorithm is executed using an estimator primitive, which computes expectation values of operators (observables).

An instance of VQE also requires an ansatz, a parameterized QuantumCircuit, to prepare the trial state $$|\psi(\vec\theta)\rangle$$. It also needs a classical optimizer which varies the circuit parameters $$\vec\theta$$ such that the expectation value of the operator on the corresponding state approaches a minimum,

$\min_{\vec\theta} \langle\psi(\vec\theta)|H|\psi(\vec\theta)\rangle.$

The estimator is used to compute this expectation value for every optimization step.

The optimizer can either be one of Qiskit’s optimizers, such as SPSA or a callable with the following signature:

from qiskit.algorithms.optimizers import OptimizerResult

def my_minimizer(fun, x0, jac=None, bounds=None) -> OptimizerResult:
# Note that the callable *must* have these argument names!
# Args:
#     fun (callable): the function to minimize
#     x0 (np.ndarray): the initial point for the optimization
#     jac (callable, optional): the gradient of the objective function
#     bounds (list, optional): a list of tuples specifying the parameter bounds

result = OptimizerResult()
result.x = # optimal parameters
result.fun = # optimal function value
return result


The above signature also allows one to use any SciPy minimizer, for instance as

from functools import partial
from scipy.optimize import minimize

optimizer = partial(minimize, method="L-BFGS-B")


The following attributes can be set via the initializer but can also be read and updated once the VQE object has been constructed.

estimator

The estimator primitive to compute the expectation value of the Hamiltonian operator.

Type

BaseEstimator

ansatz

A parameterized quantum circuit to prepare the trial state.

Type

QuantumCircuit

optimizer

A classical optimizer to find the minimum energy. This can either be a Qiskit Optimizer or a callable implementing the Minimizer protocol.

Type

An optional estimator gradient to be used with the optimizer.

Type

callback

A callback that can access the intermediate data at each optimization step. These data are: the evaluation count, the optimizer parameters for the ansatz, the evaluated mean, and the metadata dictionary.

Type

Callable[[int, np.ndarray, float, dict[str, Any]], None] | None

Références

[1]: Peruzzo, A., et al, « A variational eigenvalue solver on a quantum processor »

arXiv:1304.3061

Paramètres
• estimator (BaseEstimator) – The estimator primitive to compute the expectation value of the Hamiltonian operator.

• ansatz (QuantumCircuit) – A parameterized quantum circuit to prepare the trial state.

• optimizer (Optimizer | Minimizer) – A classical optimizer to find the minimum energy. This can either be a Qiskit Optimizer or a callable implementing the Minimizer protocol.

• initial_point (Sequence[float] | None) – An optional initial point (i.e. initial parameter values) for the optimizer. The length of the initial point must match the number of ansatz parameters. If None, a random point will be generated within certain parameter bounds. VQE will look to the ansatz for these bounds. If the ansatz does not specify bounds, bounds of $$-2\pi$$, $$2\pi$$ will be used.
 compute_minimum_eigenvalue Computes the minimum eigenvalue. supports_aux_operators Whether computing the expectation value of auxiliary operators is supported.