|q⟩ Bad Qubits

intermediate · Programming · Variational Quantum Eigensolver (VQE)

Hybrid Quantum-Classical Computing

Quantum computers today are noisy and shallow: circuits cannot be too deep before errors accumulate. The Variational Quantum Eigensolver (VQE) was designed precisely for this constraint — it keeps the quantum part short and offloads the heavy lifting to a classical optimizer. The result is a loop in which a quantum device and a classical computer take turns, each doing what it does best.

Why a hybrid approach?

A fault-tolerant quantum computer could run phase estimation to find molecular ground-state energies in polynomial time. But that algorithm requires many ancilla qubits and deep circuits — well beyond what current hardware can sustain. The hybrid idea, due to Peruzzo et al. (2014), is to observe that for any trial quantum state ψ|\psi\rangle the variational principle guarantees

ψHψE0,\langle \psi | H | \psi \rangle \geq E_0,

where HH is the Hamiltonian and E0E_0 is its lowest eigenvalue (the ground-state energy). Equality holds only when ψ|\psi\rangle is the ground state. Therefore, if we can make ψ|\psi\rangle depend on tunable angles and then minimize the expectation value, we drive the quantum state toward the ground state without ever running a deep algorithm.

The variational loop

The VQE workflow has four steps that repeat until convergence:

  1. Prepare a parameterized quantum state ψ(θ)|\psi(\boldsymbol{\theta})\rangle by running an ansatz circuit whose gate angles are the vector θ\boldsymbol{\theta}.
  2. Measure the expectation value E(θ)=ψ(θ)Hψ(θ)E(\boldsymbol{\theta}) = \langle \psi(\boldsymbol{\theta}) | H | \psi(\boldsymbol{\theta}) \rangle by sampling from the quantum device and computing a weighted sum of Pauli-string measurements.
  3. Send E(θ)E(\boldsymbol{\theta}) to a classical optimizer (gradient descent, COBYLA, SPSA, etc.).
  4. Update θ\boldsymbol{\theta} according to the optimizer's prescription, then go back to step 1.

The loop terminates when E(θ)E(\boldsymbol{\theta}) stops decreasing (within a tolerance) or when a maximum number of iterations is reached. The final value approximates E0E_0.

   ┌──────────────────────────────────────────────────────────┐
   │                VARIATIONAL LOOP                          │
   │                                                          │
   │  θ  ──►  [Quantum device: prepare |ψ(θ)⟩, measure E]   │
   │              │                                           │
   │              │  E(θ)                                     │
   │              ▼                                           │
   │         [Classical optimizer: update θ]                  │
   │              │                                           │
   │              │  new θ                                     │
   │              └──────────────────────────────────────────►│
   └──────────────────────────────────────────────────────────┘

The ansatz: hardware-efficient vs. chemically motivated

The choice of ansatz determines what states the optimizer can reach. Two common families are:

For a one-dimensional problem with a single rotation angle θ\theta, the ansatz circuit and energy landscape look like this: the quantum device sweeps out the curve E(θ)E(\theta) as θ\theta varies from 00 to 2π2\pi, and the optimizer hunts for the bottom of that curve.

Measuring the Hamiltonian

A qubit Hamiltonian is decomposed into a sum of Pauli strings:

H=kckPk,Pk{I,X,Y,Z}n.H = \sum_k c_k \, P_k, \qquad P_k \in \{I, X, Y, Z\}^{\otimes n}.

For a two-qubit molecule like H2\mathrm{H_2} in a minimal basis, a typical decomposition has four to eight terms. Each term is measured in the matching Pauli basis (changing to the XX or YY basis requires a single-qubit rotation before measurement), and the results are combined classically to give E(θ)E(\boldsymbol{\theta}). This decomposition is exact — no approximation is introduced by the measurement strategy itself.

Convergence and barren plateaus

Classical optimizers rely on gradients. For quantum circuits the parameter-shift rule provides an exact gradient:

Eθk=E ⁣(θk+π2)E ⁣(θkπ2)2.\frac{\partial E}{\partial \theta_k} = \frac{E\!\left(\theta_k + \frac{\pi}{2}\right) - E\!\left(\theta_k - \frac{\pi}{2}\right)}{2}.

Each partial derivative requires two additional circuit evaluations. With pp parameters, a full gradient costs 2p2p circuits per step.

A well-known challenge for deep or wide ansatze is barren plateaus: the gradient magnitude decreases exponentially with the number of qubits, making optimization effectively impossible. Designing ansatze that avoid barren plateaus is an active research area.

The role of noise

On real hardware, each gate introduces a small error. Shallow ansatze — few layers, few two-qubit gates — accumulate less noise, which is why the hybrid approach remains attractive even as hardware improves. Error mitigation techniques (zero-noise extrapolation, probabilistic error cancellation) can sharpen the estimate of E(θ)E(\boldsymbol{\theta}) without requiring full error correction.

In the lessons that follow you will implement an ansatz circuit, decompose a simple Hamiltonian into Pauli strings, evaluate the expectation value by simulation, and plug everything into an optimizer to watch the variational loop converge.

Sign in on the full site to ask questions and join the discussion.