Variational Quantum Algorithms

Today's quantum computers are noisy and small: run a deep circuit and the errors pile up faster than the answer. So how do you get anything useful out of a machine that can only stay coherent for a handful of gates? The winning near-term trick is to not do all the work on the quantum computer. A variational quantum algorithm (VQA) lets a noisy quantum chip and an ordinary classical optimiser tag-team a problem: the quantum device runs a short, tunable circuit and reports one number, and a classical computer — sitting in a loop with it — keeps nudging the circuit's dials to make that number smaller. The quantum part stays shallow (and so noise-tolerant); the hard search is offloaded to reliable classical silicon.

The hybrid loop

Every VQA is the same four-beat loop between a quantum and a classical machine. At its heart is a parameterised circuit — an ansatz U(\boldsymbol\theta) whose gates carry tunable angles \boldsymbol\theta = (\theta_1, \theta_2, \dots) (typically a stack of rotation gates and entanglers). The loop runs:

  1. Prepare. The quantum device builds a trial state |\psi(\boldsymbol\theta)\rangle = U(\boldsymbol\theta)\,|0\cdots0\rangle.
  2. Measure. It estimates a cost — the expectation of a problem-specific Hamiltonian H — by repeated measurement: E(\boldsymbol\theta) = \langle\psi(\boldsymbol\theta)|\,H\,|\psi(\boldsymbol\theta)\rangle.
  3. Optimise. A classical optimiser reads E(\boldsymbol\theta) and proposes new angles that should lower it.
  4. Repeat until the cost stops dropping — the angles have converged on a minimum.

The quantum computer only ever runs one shallow circuit at a time, which is exactly why VQAs fit noisy, near-term hardware: keep the circuit short enough that the answer survives the noise, and let the classical loop do the heavy lifting.

Watch the loop turn

Step through one full cycle. The quantum device (left) prepares |\psi(\boldsymbol\theta)\rangle; its measured energy flows to the classical optimiser (right), which sends back a better set of angles. Round and round it goes, walking E(\boldsymbol\theta) downhill.

VQE: finding a ground-state energy

The flagship VQA is the Variational Quantum Eigensolver (VQE). Its job: find the lowest energy — the ground-state energy E_{\text{ground}} — of a Hamiltonian H. That is the central question of quantum chemistry: the ground-state energy of a molecule's Hamiltonian tells you its stable structure, its bond energies, its reaction rates. VQE leans on one clean fact, the variational principle: no trial state can have an expected energy below the true ground energy,

E(\boldsymbol\theta) = \langle\psi(\boldsymbol\theta)|\,H\,|\psi(\boldsymbol\theta)\rangle \;\ge\; E_{\text{ground}}.

So the cost is bounded below by the very number we want. Push E(\boldsymbol\theta) as low as the ansatz allows and you squeeze up against E_{\text{ground}} from above — a proper minimisation with a known floor.

Worked example 1: why the cost can never dip below the ground energy

Where does that bound come from? Expand the trial state in the eigenbasis of H. If H|E_i\rangle = E_i|E_i\rangle with the levels ordered E_{\text{ground}} = E_0 \le E_1 \le E_2 \le \cdots, then any normalised state is |\psi\rangle = \sum_i c_i |E_i\rangle with \sum_i |c_i|^2 = 1, and its energy is a weighted average of the levels:

\langle\psi|H|\psi\rangle = \sum_i |c_i|^2 E_i \;\ge\; \sum_i |c_i|^2 E_0 = E_0 \sum_i |c_i|^2 = E_0.

Every level E_i is at least E_0, so their probability-weighted average is too — with equality only when all the weight sits on the ground state (|c_0|^2 = 1). That is the whole strategy in one line: driving E(\boldsymbol\theta) to its minimum drags the trial state toward the true ground state, and the minimum value it reaches is the estimate of E_{\text{ground}}.

Worked example 2: one turn of a single-qubit VQE

Make it concrete on one qubit with H = Z (energies +1 for |0\rangle and -1 for |1\rangle, so E_{\text{ground}} = -1). Use the one-parameter ansatz U(\theta) = R_y(\theta), giving the trial state

|\psi(\theta)\rangle = R_y(\theta)\,|0\rangle = \cos\tfrac{\theta}{2}\,|0\rangle + \sin\tfrac{\theta}{2}\,|1\rangle.

Measure. The cost is the expected value of Z — the probability of |0\rangle minus that of |1\rangle:

E(\theta) = \langle\psi(\theta)|Z|\psi(\theta)\rangle = \cos^2\tfrac{\theta}{2} - \sin^2\tfrac{\theta}{2} = \cos\theta.

One iteration. Suppose the loop currently holds \theta = 0: the device prepares |0\rangle and measures E = \cos 0 = +1 — the worst possible energy. The classical optimiser sees that the slope \tfrac{dE}{d\theta} = -\sin\theta points downhill as \theta grows, so it nudges \theta upward and hands it back. Iterate, and \theta climbs toward \pi, where E = \cos\pi = -1 = E_{\text{ground}} and the state has become |1\rangle — exactly the ground state the variational bound promised.

QAOA: approximating hard optimisation

The other flagship VQA targets combinatorial optimisation — problems like Max-Cut (split a graph's vertices into two groups so as many edges as possible cross the divide), scheduling, or routing, where the number of candidate answers explodes. The Quantum Approximate Optimisation Algorithm (QAOA) encodes the objective as a cost Hamiltonian H_C whose ground state is the best solution, then builds its ansatz from alternating layers:

|\psi(\boldsymbol\gamma, \boldsymbol\beta)\rangle = \underbrace{e^{-i\beta_p H_M} e^{-i\gamma_p H_C}}_{\text{layer } p} \cdots\; e^{-i\beta_1 H_M}\, e^{-i\gamma_1 H_C}\;|+\cdots+\rangle.

Each layer alternates a cost unitary e^{-i\gamma H_C} (which imprints the problem) with a mixer unitary e^{-i\beta H_M} (which shuffles amplitude between candidate bit-strings). The same hybrid loop then tunes the angles \boldsymbol\gamma, \boldsymbol\beta to minimise \langle H_C\rangle, and measuring the final state yields a good (not always optimal) solution — the "Approximate" in the name.

Watching the cost fall

As the loop turns, the measured cost traces a descent curve, settling toward the E_{\text{ground}} floor. Drag the slider to change how strongly each step lowers the cost — the trainability of the ansatz. Turn it near zero and the curve flattens into a stalled plateau that never reaches the floor: a preview of the trouble below.

The barren plateau problem

VQAs have a signature failure mode. For many qubits or a deep, generic ansatz, the cost landscape becomes almost perfectly flat almost everywhere: the gradient \nabla_{\boldsymbol\theta} E vanishes exponentially in the number of qubits. This is the barren plateau. With no discernible slope, the classical optimiser has nothing to follow — it wanders a featureless expanse, and the number of measurements needed just to see a downhill direction blows up. Barren plateaus are one of the main reasons a VQA that looks good on 4 qubits can stall completely at 40.

The mental picture is two specialists sharing one job. The quantum computer is a brilliant but exhausted athlete: it can do something no classical machine can — prepare and sample an enormous entangled state — but only for a few seconds before noise wears it down. So it does one short, explosive move (run the shallow circuit, report a number) and tags out. The classical optimiser is the tireless strategist in the corner: it can't prepare the quantum state itself, but it can bookkeep, remember, and calculate the next set of angles all day long. Neither could win alone. Letting a noisy quantum computer and a classical optimiser tag-team the problem is what turns imperfect near-term hardware into something that can still compute a molecule's energy.

It is tempting to read "runs on today's hardware" as "beats today's supercomputers." It does not — not yet, and not provably. VQAs are heuristics: unlike Shor's algorithm, they come with no general speedup guarantee. They can get stuck in barren plateaus where gradients vanish, they are still buffeted by hardware noise, and their success is painfully sensitive to the ansatz — the wrong circuit shape can't represent the answer no matter how you tune it, while an expressive one is exactly the kind that plateaus. VQAs are the most promising near-term idea we have, but "promising" is the operative word: treat a VQA result as a well-motivated approximation to be checked, not a proof of quantum advantage.