Variational Quantum Eigensolvers

Caleb Clothier
9 min readMay 7, 2021

--

Introduction

The Variational Quantum Eigensolver (VQE) is a hybrid classical-quantum algorithm that, in its most basic form, can find the ground state energy of various quantum systems. Some notable applications lie in the field of quantum chemistry, where the resources required to classically simulate molecular wavefunctions increase exponentially with the size of the molecule. Although true quantum speedups in computational chemistry are still far off and dependant on the development of large fault-tolerant quantum computers, VQEs can already be used to determine the ground state energy of smaller molecules to a high degree of accuracy.

VQE Overview

Before delving into the specifics of VQE, we first recall some quantum mechanics that will be of use. The state of a quantum system is represented by a complex-valued wavefunction, and the energy is associated with the Hamiltonian operator H, a matrix with eigenvalues representing the possible energies of the system. The system’s ground state is the eigenstate of the Hamiltonian with the smallest eigenvalue, and the expected value of the energy in this state equals the ground state energy. Casting this into equation form:

Importantly, the expected value of the energy in all other states is greater than or equal to the ground state energy:

VQE leverages this inequality by parametrizing the quantum state used to evaluate the energy expectation, and variationally updating these parameters on a classical computer to find a tight upper bound to the ground state. More precisely, the VQE algorithm is as follows:

  1. A parametrized quantum circuit prepares a trial ground state using some initial parameter values
  2. A quantum measurement circuit estimates the energy expectation in this trial state
  3. The classical optimization algorithm updates the parameters to (ideally) decrease the energy expectation of the next trial state
  4. This algorithm is iterated until the energy expectation converges to some value, which is taken to be an approximation of the ground state energy.
Image source: http://openqemist.1qbit.com/docs/_images/VQE_overview.png

However, for even the simplest of quantum systems, there is typically an enormous number of quantum states that the VQE could prepare and consider as trial states. Moreover, the number of parameters required to prepare arbitrary quantum states increases problematically with the system size, presenting a challenge to the classical optimizer. In order to reduce the number of parameters and hence the size of the algorithmic search space, an ansatz (German for guess) is often made regarding the form of the ground state wavefunction, with this ansatz determining the exact configuration of the parametrized quantum circuit. The choice of optimal ansatz varies across VQE applications and is informed by the Hamiltonian of the system being studied. We will return to this in the next section, where we will explore the VQE algorithm applied to finding molecular ground states.

Lastly, there are several choices for the classical optimizer, which is responsible for determining the parameter updates, and thus for generating the new trial states. A simple option would be gradient descent, identifying the energy expectation as the cost function to be minimized, but a tendency to get stuck in local minima and a relatively high number of required quantum circuit evaluations make this optimizer a poor choice for VQE. Popular optimizers for noise-free models (i.e., statevector simulations on classical computers) include the Nelder-Mead method, Sequential Least Squares Programming (SLSQP), Constrained Optimization by Linear Optimization (COBYLA), with COBYLA being more efficient at the expense of fewer (just one) energy expectation evaluations per iteration. VQE on physical quantum computers or on simulators incorporating noise models often involves more nuanced optimization schemes. This project only used noise-free simulator models, however, and there will be no further discussion of the topic.

VQEs in Molecular Science

VQEs are particularly useful in molecular science because of their ability to determine the ground and excited states of molecules, which can, in turn, reveal other interesting properties — for example, the ground state distance between atoms in the molecule (the “interatomic separation”). It should not be immediately clear, though, how the wavefunction of a molecule can be mapped onto the qubit states of a quantum computer, and this process indeed is theoretically involved.

Hamiltonian Mapping

It seems natural to begin with the general Hamiltonian for a quantum molecular system:

where indices i and j denote electrons, index I denotes nuclei, Z is the atomic number of nuclei I, r is the position of electron i,j and R is the position of each nucleus, which is fixed in space in accordance with the Born-Oppenheimer approximation. Though the Hamiltonian in this form is more intuitive, the second quantization Hamiltonian (shown below), in which electrons are treated as excitations in an electron field, will ultimately prove more useful in our effort to encode the problem onto a quantum computer:

Here the a-dagger operators in each term “excite” an electron to orbitals p and (p, q), respectively, and the a operators in each term “deexcite” an electron from orbitals q and (r, s), respectively. The h terms are coefficients known as the one- and two-electron integrals and can be calculated relatively efficiently in terms of a small set of orbital basis states on a classical computer. We restrict ourselves to single- and double-electron excitations to obtain a workable approximation of the more complicated true physical system.

Illustration of Jordan-Wigner mapping from fermionic Hamiltonian to spin Hamiltonian

Next, there are three common mappings that can be used to produce a Hamiltonian for distinguishable fermions (i.e., qubits) from a Hamiltonian for indistinguishable fermions (i.e., electrons) shown above: the Jordan-Wigner mapping, the parity mapping, and the Bravyi-Kitaev mapping. No matter the choice of mapping, a Hamiltonian of the form shown below will be produced:

That is, the Hamiltonian will be a linear combination of products of Pauli matrices (with index i denoting the qubit being act upon), which can be executed on a quantum computer –or at least a simulated one, since inter-qubit connectivity may be limited on real quantum hardware. Given a trial state, the energy expectation may be evaluated by measuring this superposition of Pauli operators, as specified in the equation below:

Parametrized Wavefunction Ansatz

Among the most common wavefunction ansatz is the Unitary Coupled-Cluster Single and Double excitation (UCCSD) ansatz, used in the foundational VQE paper by Perruzo et al. It is constructed by applying an exponentiated single- and double-electron excitation operator to an initial state, commonly chosen to be the Hartree Fock mean-field wavefunction (an unentangled state that decently approximates the ground state):

where “virt” denotes unoccupied orbitals and “occ” denotes occupied orbitals, dagger-a operators excite electrons and a operators deexcite electrons to/from orbitals, and the t coefficients are the tunable parameters that are fed to the classical optimizer. The T operator is then converted via one of the three aforementioned mappings (Jordan-Wigner, parity, Bravyi-Kitaev) into an effective Hamiltonian operator on qubits, which may consequently be executed on a quantum computer.

Further reading regarding this more mathematically intense section may be found at the end of the post.

Building a VQE in Qiskit

I implemented a VQE in Python using Qiskit, an open-source SDK for working with quantum computers, to find the ground state energy and corresponding interatomic separation for several small molecules: diatomic hydrogen (H₂), lithium hydrogen (LiH), ionic helium hydride (HeH+), and hydroxide (OH-).

First, the molecule structure was specified as a string in xyz coordinates. For example, lithium hydride would be specified as “Li .0 .0 .0; H .0 .0 d” where d is the interatomic distance. For two-atom molecules, the z-coordinate of the second atom was varied to determine the ground state energy as a function of interatomic distance.

Next, a PySCF driver was initialized with this molecule specification, creating a data structure representing the molecule along with several useful calculated attributes, including the nuclear repulsion energy — a quantity later added to the VQE-determined electronic energy to obtain the total molecular energy. The PySCF molecular data structure was then provided as input to the ElectronicStructureProblem class in the Qiskit-Nature module. This class determines the Hamiltonian of the molecule in terms of second-quantization operators, calculating the one- and two-electron integral coefficients discussed previously and returning the electronic operator in the form:

Second quantization electronic operator for diatomic hydrogen

where “+” is the excitation operator, “ -“ is the deexcitation operator, “I” is the identity operator, and “N” is the number operator (deexcitation followed by excitation). This operator was then converted into a qubit electronic operator using the class qiskit_nature.converters.second_quantization.QubitConverter, with the mapping type set to the Jordan-Wigner transformation, yielding a summation of Pauli operator products:

Qubit electronic operator for diatomic hydrogen

Note that the number of qubits needed to execute the algorithm is equal to the number of second quantization operators, which is defined to be the number of molecular spin orbitals considered.

Next, the Hartree Fock initial state preparation circuit and the UCCSD variational unitary transformation circuit (with HF as its initial state) were retrieved from a library of optimized circuits in the qiskit_nature.circuits.library module, being sure to pass the Jordan-Wigner QubitConverter object created earlier as an argument to each circuit for consistency. Finally, these were all supplied to the VQE class in the module qiskit.algorithms, which simulated the UCCSD variational circuit repeatedly on a Qiskit Aer statevector backend to solve for the minimum eigenvalue of the qubit Hamiltonian, using the SLSQP classical optimizer to calculate parameter updates.

This algorithm was repeated for intermolecular separations ranging between 0.2 and 2 Angstroms (~0.1 nanometers), storing the minimum energy as determined by the VQE at each iteration.

Results

The table below summarizes the results obtained using VQE and demonstrates the close correspondence between experimentally determined ground state energies and the ground state energies determined using VQEs. The ground state interatomic distance was determined by finding the minimum on the plot of VQE ground state energy against interatomic distance.

Energy units are Hartrees and interatomic distance units are Angstroms

In the plot on the left, the theoretical curve of ground state energy against interatomic distance — determined by diagonalizing the molecule Hamiltonian directly using NumpyMinimumEigensolver (wrapped in Qiskit) — coincides almost perfectly with the VQE curve. Future research could involve incorporating noise models into the statevector simulator and testing the robustness of the method with environmental noise.

The ground state energy for H₂ was -1.137 Hartrees, at an interatomic distance of 0.75 Angstroms.
The ground state energy for LiH was -7.882 Hartrees, at an interatomic distance of 1.55 Angstroms.

All code for this project may be found on my Github at https://github.com/calebclothier/MolecularVQE.

References & Further Reading

  1. Fedorov, Dmitry A., Bo Peng, Niranjan Govind, and Yuri Alexeev. “VQE Method: A Short Survey and Recent Developments.” arXiv, March 15, 2021.
  2. Liu, Hongbin, Guang Hao Low, Damian S Steiger, Thomas Haner, Markus Reiher, and Matthias Troyer. “Prospects of Quantum Computing for Molecular Sciences.” arXiv, February 19, 2021.
  3. Peruzzo, Alberto, Jarrod McClean, Peter Shadbolt, Man-Hong Yung, Xiao-Qi Zhou, Peter J. Love, Alán Aspuru-Guzik, and Jeremy L. O’Brien. “A Variational Eigenvalue Solver on a Photonic Quantum Processor.” Nature Communications 5, no. 1 (2014). https://doi.org/10.1038/ncomms5213.
  4. Qiskit VQE Tutorial: https://qiskit.org/textbook/ch-applications/vqe-molecules.html
  5. Electronic structure further reading: https://qiskit.org/documentation/tutorials/chemistry/01_electronic_structure.html
  6. Jordan-Wigner mapping further reading: https://docs.microsoft.com/en-us/azure/quantum/user-guide/libraries/chemistry/concepts/jordan-wigner
  7. https://medium.com/qiskit/ive-simulated-a-molecule-with-a-quantum-computer-now-what-aa9e2dfd92c5

--

--

Caleb Clothier
Caleb Clothier

Written by Caleb Clothier

Senior at Yale University studying physics.

No responses yet