Variational Quantum Eigensolvers
VQE uses a quantum computer to prepare trial molecular wavefunctions and a classical computer to tune circuit angles until the measured energy reaches its lowest possible point.
Why Does This Exist?
In quantum chemistry and material science, determining the chemical reactivity, binding affinity, and thermal stability of molecules requires finding the ground state energy (the lowest eigenvalue) of the molecular electronic Hamiltonian . On classical supercomputers, the dimension of the electronic Hilbert space scales exponentially as with the number of spin orbitals and electrons . For molecules larger than 50 electrons—such as the active iron-molybdenum cofactor in nitrogenase that fixes atmospheric nitrogen—exact classical diagonalization is computationally impossible.
The theoretical ideal quantum algorithm, Quantum Phase Estimation (QPE), provably extracts exact eigenvalues with polynomial quantum speedup. However, QPE requires deep quantum circuits with millions of fault-tolerant logic gates, far beyond modern Noisy Intermediate-Scale Quantum (NISQ) hardware.
Introduced by Alberto Peruzzo, Jarrod McClean, Peter O'Brien, and Alán Aspuru-Guzik in 2014, the Variational Quantum Eigensolver (VQE) circumvents hardware limitations by splitting the workload. Instead of executing long coherent circuits, VQE runs shallow, parameterized quantum circuits on a QPU to prepare trial molecular states, measures expectation values, and offloads the energy minimization loop to a classical optimizer.
Think of It Like This
A sound technician dialing out microphone feedback hum
Imagine a concert sound technician trying to eliminate a ringing acoustic feedback frequency created between an auditorium's stage microphone and loudspeakers.
Finding the exact resonance mode analytically by solving acoustic 3D wave differential equations across every wall, chair, and curtain reflection is mathematically intractable.
Instead, the technician twiddles the parametric equalizer frequency dials on the mixing console (variational parameters ). With each slight knob adjustment, they listen to the overall sound pressure meter on the board (energy measurement ). Guided by the readout, they nudge the knobs in the direction that lowers the volume until the screeching feedback vanishes completely into a quiet hum (the lowest ground state energy ).
How It Actually Works
Rayleigh-Ritz Variational Principle and Pauli Decomposition
VQE is grounded in the Rayleigh-Ritz variational principle from quantum mechanics. For any valid quantum state and Hermitian Hamiltonian operator , the expectation value of energy is guaranteed to be greater than or equal to the true minimum ground state energy :
Equality holds if and only if is the exact ground state eigenstate. This converts an intractable matrix diagonalization problem into a continuous optimization problem: minimize by adjusting gate parameters .
1. Second Quantization and Jordan-Wigner Transformation
A molecular Hamiltonian in second quantization is expressed using fermionic creation () and annihilation () operators:
Using the Jordan-Wigner transformation (or Bravyi-Kitaev transformation), fermionic operators are mapped onto tensor products of Pauli spin operators (), decomposing into a linear sum of Pauli strings:
2. Measuring Energy on the QPU
By linearity of expectation values, the total system energy is the weighted sum of individual Pauli expectations:
To measure a Pauli string like :
- The QPU prepares trial state .
- Basis rotation gates are applied (e.g., a Hadamard gate rotates the basis into the computational basis).
- The qubits are measured in the computational basis for trials.
- The classical processor aggregates the sample averages, sums , and executes an optimization step .
Worked Example
Consider a 1-qubit Hamiltonian representing a magnetic spin system:
Step 1: Compute Exact Analytical Ground Energy The Hamiltonian matrix is:
Its eigenvalues satisfy .
The exact ground state energy is .
Step 2: Define Trial Wavefunction (Ansatz) Use a single-parameter rotation ansatz initialized from ground state :
Step 3: Evaluate Pauli Expectation Values
- For :
- For :
Step 4: Formulate Energy Objective
Step 5: Minimize Energy Analytically Find the critical angle by setting the derivative to zero:
The minimum occurs in the third quadrant where both sine and cosine are negative:
Compute trigonometric values at :
Substitute back into the energy equation:
The variational expectation value matches the theoretical lowest eigenvalue to 4 decimal places.
Code
Below is a pure Python script simulating the VQE hybrid optimization loop on this Hamiltonian:
import numpy as np
def ry(theta: float) -> np.ndarray: half = theta / 2.0 return np.array([ [np.cos(half), -np.sin(half)], [np.sin(half), np.cos(half)] ], dtype=np.complex128)
# Pauli Matricespauli_z = np.array([[1.0, 0.0], [0.0, -1.0]], dtype=np.complex128)pauli_x = np.array([[0.0, 1.0], [1.0, 0.0]], dtype=np.complex128)
# Hamiltonian Coefficients: H = 0.5*Z + 1.2*Xc_z, c_x = 0.5, 1.2
def measure_expectation(state: np.ndarray, observable: np.ndarray) -> float: """Computes <psi|Observable|psi>.""" return float(np.real(np.conj(state).T @ observable @ state))
def vqe_energy(theta: float) -> float: """Prepares trial state on QPU and evaluates energy.""" state = ry(theta) @ np.array([1.0, 0.0], dtype=np.complex128) exp_z = measure_expectation(state, pauli_z) exp_x = measure_expectation(state, pauli_x) return c_z * exp_z + c_x * exp_x
# Classical Gradient Descent Looptheta = 0.0 # Initial parameterlearning_rate = 0.1shift = np.pi / 2.0
for step in range(50): # Parameter-shift gradient: dE/dtheta = 0.5 * (E(theta + pi/2) - E(theta - pi/2)) grad = 0.5 * (vqe_energy(theta + shift) - vqe_energy(theta - shift)) theta -= learning_rate * grad
final_energy = vqe_energy(theta)exact_ground = -np.sqrt(c_z**2 + c_x**2)
print(f"Optimal angle theta: {theta:.4f} rad")# -> Optimal angle theta: -1.9656 rad (equivalent to 4.3176 rad mod 2pi)print(f"VQE Ground Energy: {final_energy:.4f}")# -> VQE Ground Energy: -1.3000print(f"Exact Ground Energy: {exact_ground:.4f}")# -> Exact Ground Energy: -1.3000Watch Out For
Pauli term grouping overhead and shot budget explosion
When scaling VQE to multi-atom molecules (such as caffeine or lithium hydride), mapping the fermionic Hamiltonian via Jordan-Wigner yields individual Pauli strings. For a modest 20-qubit system, this produces over 10,000 distinct Pauli terms.
If every term is measured with to achieve chemical accuracy (), each single energy evaluation requires over circuit executions, causing runtimes on real cloud QPUs to stretch into weeks for a single convergence run.
Fix: Group commuting Pauli operators into simultaneous measurement cliques using Qubit-Wise Commutativity (QWC) or Full Commutativity (FC) algorithms. Operators in the same commutative clique can be measured simultaneously in a single basis rotation circuit, collapsing tens of thousands of separate terms into a few dozen bundled circuit runs.
The Quick Version
- Variational Quantum Eigensolvers solve molecular ground state energies using the Rayleigh-Ritz theorem: .
- Second-quantized electronic Hamiltonians are decomposed into weighted sums of Pauli spin strings using the Jordan-Wigner transformation.
- The QPU prepares trial wavefunctions and measures Pauli expectation values; the classical CPU sums terms and runs gradient updates.
- Commutativity grouping algorithms are essential to condense Pauli terms into manageable measurement shot budgets.