VQD#

class VQD(estimator, fidelity, ansatz, optimizer, *, k=2, betas=None, initial_point=None, callback=None)[source]#

Bases: VariationalAlgorithm, Eigensolver

The Variational Quantum Deflation algorithm. Implementation using primitives.

VQD is a quantum algorithm that uses a variational technique to find the k eigenvalues of the Hamiltonian \(H\) of a given system.

The algorithm computes excited state energies of generalised hamiltonians by optimizing over a modified cost function where each successive eigenvalue is calculated iteratively by introducing an overlap term with all the previously computed eigenstates that must be minimised, thus ensuring higher energy eigenstates are found.

An instance of VQD requires defining three algorithmic subcomponents: an integer k denoting the number of eigenstates to calculate, a trial state (a.k.a. ansatz) which is a QuantumCircuit, and one instance (or list of) classical optimizers. The optimizer varies the circuit parameters The trial state \(|\psi(\vec\theta)\rangle\) is varied by the optimizer, which modifies the set of ansatz parameters \(\vec\theta\) such that the expectation value of the operator on the corresponding state approaches a minimum. The algorithm does this by iteratively refining each excited state to be orthogonal to all the previous excited states.

An optional array of parameter values, via the initial_point, may be provided as the starting point for the search of the minimum eigenvalue. This feature is particularly useful when there are reasons to believe that the solution point is close to a particular point.

The length of the initial_point list value must match the number of the parameters expected by the ansatz. If the initial_point is left at the default of None, then VQD will look to the ansatz for a preferred value, based on its given initial state. If the ansatz returns None, then a random point will be generated within the parameter bounds set, as per above. It is also possible to give a list of initial points, one for every kth eigenvalue. If the ansatz provides None as the lower bound, then VQD will default it to \(-2\pi\); similarly, if the ansatz returns None as the upper bound, the default value will be \(2\pi\).

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

estimator#

The primitive instance used to perform the expectation estimation as indicated in the VQD paper.

Type:

BaseEstimator

fidelity#

The fidelity class instance used to compute the overlap estimation as indicated in the VQD paper.

Type:

BaseStateFidelity

ansatz#

A parameterized circuit used as ansatz for the wave function.

Type:

QuantumCircuit

optimizer#

A classical optimizer or a list of optimizers, one for every k-th eigenvalue. Can either be a Qiskit optimizer or a callable that takes an array as input and returns a Qiskit or SciPy optimization result.

Type:

Optimizer | Sequence[Optimizer]

k#

the number of eigenvalues to return. Returns the lowest k eigenvalues.

Type:

int

betas#

Beta parameters in the VQD paper. Should have length k - 1, with k the number of excited states. These hyper-parameters balance the contribution of each overlap term to the cost function and have a default value computed as the mean square sum of the coefficients of the observable.

Type:

list[float]

callback#

A callback that can access the intermediate data during the optimization. Four parameter values are passed to the callback as follows during each evaluation by the optimizer: the evaluation count, the optimizer parameters for the ansatz, the estimated value, the estimation metadata, and the current step.

Type:

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

Parameters:
  • estimator (BaseEstimator) – The estimator primitive.

  • fidelity (BaseStateFidelity) – The fidelity class using primitives.

  • ansatz (QuantumCircuit) – A parameterized circuit used as ansatz for the wave function.

  • optimizer (Optimizer | Minimizer | Sequence[Optimizer | Minimizer]) – A classical optimizer or a list of optimizers, one for every k-th eigenvalue. Can either be a Qiskit optimizer or a callable that takes an array as input and returns a Qiskit or SciPy optimization result.

  • k (int) – The number of eigenvalues to return. Returns the lowest k eigenvalues.

  • betas (np.ndarray | None) – Beta parameters in the VQD paper. Should have length k - 1, with k the number of excited states. These hyperparameters balance the contribution of each overlap term to the cost function and have a default value computed as the mean square sum of the coefficients of the observable.

  • initial_point (np.ndarray | list[np.ndarray] | None) – An optional initial point (i.e. initial parameter values) or a list of initial points (one for every k-th eigenvalue) for the optimizer. If None then VQD will look to the ansatz for a preferred point and if not will simply compute a random one.

  • callback (Callable[[int, np.ndarray, float, dict[str, Any], int], None] | None) – A callback that can access the intermediate data during the optimization. Five parameter values are passed to the callback as follows during each evaluation by the optimizer: the evaluation count, the optimizer parameters for the ansatz, the estimated value, the estimation metadata, and the current step.

Attributes

initial_point#

Returns initial point.

Methods

compute_eigenvalues(operator, aux_operators=None)[source]#

Computes the minimum eigenvalue. The operator and aux_operators are supplied here. While an operator is required by algorithms, aux_operators are optional.

Parameters:
  • operator (BaseOperator) – Qubit operator of the observable.

  • aux_operators (ListOrDict[BaseOperator] | None) – Optional list of auxiliary operators to be evaluated with the eigenstate of the minimum eigenvalue main result and their expectation values returned. For instance, in chemistry, these can be dipole operators and total particle count operators, so we can get values for these at the ground state.

Returns:

An eigensolver result.

Return type:

VQDResult

classmethod supports_aux_operators()[source]#

Whether computing the expectation value of auxiliary operators is supported.

If the eigensolver computes the eigenvalues of the main operator, then it can compute the expectation value of the aux_operators for that state. Otherwise they will be ignored.

Returns:

True if aux_operator expectations can be evaluated, False otherwise.

Return type:

bool