QUAVIS.CC
Variational Quantum Eigensolver (VQE): Principles & Applications
#VQE #Algorithms #QuantumChemistry #DeepDive

Variational Quantum Eigensolver (VQE): Principles & Applications

Understanding the Variational Quantum Eigensolver (VQE)

The Variational Quantum Eigensolver (VQE) is a hybrid quantum-classical algorithm designed to calculate the ground state energy of a molecular Hamiltonian or quantum system on noisy intermediate-scale quantum (NISQ) devices.

How VQE Works

VQE relies on the variational principle, which states that the expectation value of a Hamiltonian $H$ for any trial state $|\psi(\theta)\rangle$ is an upper bound to the true ground state energy $E_0$:

$$\langle \psi(\theta) | H | \psi(\theta) \rangle \ge E_0$$

The Hybrid Execution Loop

  1. Quantum Execution: Prepare the parameterized ansatz state $|\psi(\theta)\rangle$ on the QPU and measure Pauli terms of the Hamiltonian.
  2. Classical Optimization: Send measured expectation values to a classical optimizer (e.g. COBYLA, Adam, or SPSA) to update circuit parameters $\theta$.
  3. Convergence: Repeat until energy reaches a minimum.
import pennylane as qml
from pennylane import numpy as np

dev = qml.device('default.qubit', wires=2)
H = qml.Hamiltonian([1.0, 0.5], [qml.PauliZ(0), qml.PauliX(0) @ qml.PauliX(1)])

@qml.qnode(dev)
def circuit(params):
    qml.RY(params[0], wires=0)
    qml.CNOT(wires=[0, 1])
    return qml.expval(H)

params = np.array([0.1], requires_grad=True)
opt = qml.GradientDescentOptimizer(stepsize=0.4)
for step in range(20):
    params, energy = opt.step_and_cost(circuit, params)
print(f'Optimized Ground State Energy: {energy:.6f}')