How Does VQE Use Classical Optimizers for Quantum Circuits?
Hybrid variational quantum algorithms like the Variational Quantum Eigensolver combine quantum processors with classical computers to solve complex optimization problems. In this feedback loop, a quantum computer prepares a trial quantum state using a parameterized circuit and measures its energy, while a classical optimizer adjusts the circuit's rotation angles to minimize that energy. This division of labor allows current noisy quantum hardware to tackle problems in quantum chemistry and materials science by keeping quantum circuits shallow.
The Hybrid Quantum-Classical Feedback Loop
The core of the Variational Quantum Eigensolver (VQE) is an iterative loop between a quantum processing unit (QPU) and a classical central processing unit (CPU). The goal is to find the ground state energy of a given Hamiltonian \(H\), which represents the total energy of a quantum system.
According to the variational principle, the expectation value of the Hamiltonian for any trial wavefunction \(|\psi(\vec{\theta})\rangle\) is always greater than or equal to the true ground state energy \(E_0\):
\[E(\vec{\theta}) = \langle \psi(\vec{\theta}) | H | \psi(\vec{\theta}) \rangle \ge E_0\]
Here, \(\vec{\theta} = (\theta_1, \theta_2, \dots, \theta_m)\) is a vector of classical parameters, typically representing the rotation angles of quantum gates in a parameterized quantum circuit (also called an ansatz).
Step-by-Step Execution
The optimization process unfolds in four repeating steps:
- Initialization: The classical computer selects an initial set of angles \(\vec{\theta}^{(0)}\) and sends them to the quantum processor.
- State Preparation: The quantum processor applies a sequence of parameterized gates \(U(\vec{\theta})\) to an initial register of qubits \(|0\rangle^{\otimes n}\), creating the trial state \(|\psi(\vec{\theta})\rangle = U(\vec{\theta})|0\rangle^{\otimes n}\).
- Measurement: The quantum state is measured in the bases required by the Hamiltonian \(H\). Because a single measurement collapses the quantum state, the circuit is executed and measured many times (shots) to estimate the expectation value \(E(\vec{\theta})\).
- Classical Optimization: The estimated energy \(E(\vec{\theta})\) is returned to the classical optimizer, which computes a new set of angles \(\vec{\theta}^{(k+1)}\) aimed at lowering the energy.
This cycle repeats until the energy converges to a minimum or a maximum number of iterations is reached.
How Classical Optimizers Update the Angles
Classical optimizers generally fall into two categories: gradient-based and gradient-free methods.
Gradient-Based Optimizers
Gradient-based methods, such as Adam or BFGS, update the parameters by moving in the direction of steepest descent:
\[\vec{\theta}^{(k+1)} = \vec{\theta}^{(k)} - \eta \nabla_{\vec{\theta}} E(\vec{\theta}^{(k)})\]
where \(\eta\) is the learning rate. On quantum hardware, gradients cannot be computed using classical backpropagation. Instead, they are typically obtained using the parameter-shift rule. For a gate parameterized by \(\theta_i\), the partial derivative is calculated by running the circuit twice with shifted angles:
\[\frac{\partial E(\vec{\theta})}{\partial \theta_i} = \frac{E(\vec{\theta} + \frac{\pi}{2}\hat{e}_i) - E(\vec{\theta} - \frac{\pi}{2}\hat{e}_i)}{2}\]
Gradient-Free Optimizers
Gradient-free optimizers, such as COBYLA, Nelder-Mead, or SPSA (Simultaneous Perturbation Stochastic Approximation), do not require exact derivatives. SPSA is especially popular on noisy quantum devices because it approximates the gradient using only two circuit evaluations per iteration, regardless of the number of parameters \(m\), by perturbing all angles simultaneously in random directions.
Challenges in Classical Optimization
Updating quantum circuit angles classically introduces unique challenges. Shot noise from finite measurements and hardware decoherence create a noisy cost landscape, which can trap optimizers in local minima. Additionally, for deep or poorly designed ansatzes, the gradient can vanish exponentially with the number of qubits—a phenomenon known as a barren plateau—making it difficult for the classical optimizer to find a direction of improvement.