Skip to content
Tech Interview Prep home
Technical interview guide

Variational Algorithms & NISQ Computing

How hybrid classical-quantum loops like VQE and QAOA are designed to extract value from today's noisy, error-uncorrected hardware.

Read
54 min
Practice MCQs
25
Interview QA
25
Edition
v2
Editorial status
Reviewed

Scope: IBM Quantum current variational, VQE, Estimator, mitigation, runtime, and transpiler guidance; foundational VQE, QAOA, and barren-plateau literature reviewed 2026-09-04.

Overview

Curated: · Written: · Reviewed:

Variational Quantum Algorithms (VQE, QAOA): Concept Guide

Review status: rewritten from reviewer feedback; framing check previously failed, now addressed. Quality score pending re-review.

The hybrid loop, and why the split exists

A variational quantum algorithm is a hybrid loop: a parameterized circuit prepares a candidate state, a quantum execution estimates a problem-specific cost, and a classical optimizer proposes new parameters. The ansatz defines reachability and inductive bias; the observable decomposition defines measurement cost; the optimizer sees noisy, finite-shot estimates rather than an exact landscape. Convergence of optimizer settings is not proof of a globally optimal or even physically meaningful solution.

Interviewers open here, and the weak answer describes only the quantum half. The split exists because current devices have short coherence times and no error correction: a deep circuit decoheres before it finishes, so the only circuits that fit are shallow ones, and a shallow fixed circuit can't solve anything interesting. Parameterizing a shallow circuit and letting a classical computer search over the parameters is the workaround — the quantum device does the one thing classical simulation struggles with (evolving a state and sampling it), and the classical optimizer handles everything else. If you can say that in one breath, you've answered the follow-up "why not just simulate it?" for small instances: you can, and you should, for debugging — the loop only earns its cost at sizes where classical simulation of the statevector becomes exponential.

What interviewers probe next: what exactly passes between the two sides (parameters in, expectation-value estimates plus standard errors out), and what the optimizer actually sees (a stochastic cost landscape, not a function). A weak answer treats the cost as deterministic and the loop as guaranteed to converge.

The variational principle, and what generalizes

VQE uses the variational principle: for any normalized state, the expectation value of a Hamiltonian is at least its ground-state energy, so minimizing that expectation over the parameters of an ansatz upper-bounds the true ground-state energy. The bound is only as good as the ansatz — if the ground state is outside the reachable family, you converge to the best in-family state and the bound stays loose.

The generalization interviewers look for: the "cost function" need not be an energy at all. Any quantity you can estimate from measurements — an approximation ratio on sampled bitstrings, a penalty-weighted objective, a machine-learning loss — can drive the same loop. The variational principle is what makes the energy case special (you get a certified upper bound); for everything else, the loop is just stochastic optimization with a quantum device inside the objective. Candidates who can state that distinction avoid the common trap of claiming VQE's guarantee applies to QAOA.

What NISQ names, and each constraint's design consequence

NISQ — noisy intermediate-scale quantum — is not a compliment; it's a constraint list, and each item forces a design decision:

  • Decoherence limits circuit depth, which is why the ansatz must be shallow and why depth, not qubit count, is often the binding limit.
  • Gate and readout error mean every expectation estimate is biased, which is why error mitigation exists and why it inflates variance (below).
  • Limited connectivity means transpilation inserts SWAPs, so a circuit that is 50 gates in the abstract can be 200 on hardware — depth and error exposure are properties of the compiled circuit, not the source.
  • No fault tolerance means no error correction overhead budget, which is the whole reason for the variational approach rather than a deeper algorithm.
  • Shot-based measurement means every number is a statistical estimate with a standard error you pay for in samples, which is the arithmetic in the measurement-cost section below.

A weak answer lists the constraints; a strong answer maps each to a consequence in the circuit design. Expect the follow-up: "which of these dominates your runtime?" — and the honest answer is that shot budget and queue latency usually dominate, not gate count.

VQE end to end

VQE uses the variational principle to upper-bound a Hamiltonian's ground-state energy when the prepared state and measured Hamiltonian are represented consistently. The pipeline: take the problem Hamiltonian (from chemistry or materials, typically via a second-quantized to qubit mapping such as Jordan-Wigner or Bravyi-Kitaev), decompose it into a weighted sum of Pauli strings; prepare a trial state with a parameterized ansatz (often a Hartree-Fock reference plus particle-conserving excitations, or a hardware-efficient circuit); measure each Pauli term (or commuting group) and sum the weighted estimates into an energy; hand the estimate to the classical optimizer; repeat. Applications are ground-state problems — molecular energies, reaction barriers, lattice models of materials.

The interview probe here is consistency: the state must be prepared in the same encoding the Hamiltonian assumes, and a frequent weak answer is a sign error or qubit-ordering mismatch between the two, which silently produces a plausible-looking but wrong energy. Verification on small instances against exact diagonalization is the standard defense.

QAOA end to end

QAOA alternates problem and mixer evolutions: p layers, each applying the problem cost Hamiltonian for angle gamma and a mixer (typically a transverse-field term) for angle beta, then samples the resulting bitstring distribution. It connects to adiabatic evolution — at large p it approximates the adiabatic path, and at small p it's a variational cut of it — and its natural home is combinatorial optimization: MaxCut, portfolio problems, anything expressible as a QUBO.

Feasibility depends on encoding and mixer design: a constrained problem mapped to a QUBO with penalty terms can return infeasible bitstrings, and a mixer that doesn't preserve the constraint subspace will happily explore them. Interviewers probe whether you know p is the depth knob trading circuit cost against solution quality, and whether you know the approximation ratio must be measured against what a classical heuristic achieves in the same seconds — not against random assignments. Both VQE and QAOA can be useful experimental frameworks, but neither supplies quantum advantage merely by running on a QPU.

Measurement cost: the arithmetic that decides feasibility

Measurement cost is the constraint that decides whether a VQE run is possible, and it is arithmetic rather than intuition. A Hamiltonian expressed as a weighted sum of Pauli terms is estimated to a standard error of epsilon with a shot count on the order of the squared sum of the coefficient magnitudes divided by epsilon squared. A modest 12-qubit molecular Hamiltonian with several hundred terms and a coefficient sum near 20 hartree, evaluated to chemical accuracy of 1.6 millihartree, therefore needs on the order of 1.6 times 10 to the eighth shots for a single energy evaluation. Grouping commuting terms into a few dozen simultaneously measurable sets and using shot allocation weighted by coefficient magnitude buys one to two orders of magnitude, leaving roughly 10 to the sixth or 10 to the seventh shots per evaluation — and an optimizer needs hundreds of evaluations. At ten thousand shots per second that is hours to days of QPU time for one molecule, before any hardware queue, and it is the reason a VQE result should be reported in shots and wall time rather than in iterations. Parameter-shift gradients multiply the bill by two circuit evaluations per parameter, so a 200-parameter ansatz costs 400 energy estimates per gradient step; gradient-free optimizers such as SPSA trade that for two evaluations per step at the cost of a noisier trajectory, which is a real choice with a stated consequence rather than a preference.

This is the section interviewers use to separate people who have read about VQE from people who have run it. The follow-up is almost always "so how would you cut that budget?" — and the defensible answers are measurement grouping, coefficient-weighted shot allocation, and a shallower ansatz, each with its stated cost.

Barren plateaus and trainability

Barren plateaus turn the same cost into an impossibility rather than an expense, and they are a property of the ansatz and the observable rather than of the optimizer. For deep hardware-efficient circuits that approximate random unitaries, the variance of a cost gradient falls exponentially in qubit count: at 20 qubits a variance near 10 to the minus 6 means a typical gradient component is around 10 to the minus 3, and distinguishing it from zero at that magnitude takes on the order of 10 to the sixth shots per component — with a hundred components and hundreds of steps, the run is not merely slow but unbudgetable. Changing the optimizer does not help, because the landscape is flat rather than badly navigated. What does help is structure: shallow problem-informed ansaetze, local rather than global cost observables, layerwise or warm-started initialization, and symmetry-preserving circuits that restrict the explored subspace. The diagnostic is cheap and should run before the optimization does — sample the gradient variance at random parameter settings for increasing qubit counts and check whether it decays exponentially.

A related trap sits at the end of the run: mitigation applied to the reported energy reduces bias while inflating variance, sometimes by one to two orders of magnitude in shot cost, so a mitigated energy that beats a classical baseline by less than its own error bar is not a result. The weak answer blames the optimizer; the strong answer measures the gradient distribution across sizes and seeds before committing to a circuit family.

Evaluation: baselines, verification, and honest claims

The classical baseline is the part of a variational result that most often goes missing, and it is the part that decides whether the work means anything. For electronic structure, the comparison is coupled cluster with perturbative triples or density matrix renormalization group on the same active space, not Hartree-Fock; for combinatorial optimization, it is a tuned classical heuristic or an exact solver given the same wall-clock budget, not a random assignment. QAOA on a graph problem is the clearest case: a shallow circuit's approximation ratio has to be measured against what a well-implemented classical heuristic achieves on the same instances in the same seconds, and against the trivial bound the problem already guarantees, because an algorithm that produces cuts a random assignment would also produce has demonstrated nothing about quantum computation.

Two further checks keep a variational result honest. Verify the solution independently — energies against an exact diagonalization on small instances, combinatorial answers against the objective function directly — since an optimizer reporting a low cost is reporting its own estimate. And record whether the encoding preserved feasibility: the fraction of feasible samples belongs beside the approximation ratio.

Freeze the benchmark instances, the classical baseline, the accuracy target and the stopping rule before looking at any outcome, and report every restart including the ones that did not converge. The production invariant is end-to-end variational evidence: a claimed improvement must survive independent solution verification, held-out instances, complete quantum and classical resource accounting, uncertainty propagation, and a competitive baseline — without treating optimizer output, mitigation, or simulator success as quantum advantage.

What interviewers probe, and what a weak answer sounds like

  • "Walk me through one VQE iteration." Weak: describes the circuit only. Strong: parameters in, grouped Pauli measurements, weighted sum plus standard error out, optimizer update, and names the shot budget per iteration.
  • "Why does the variational principle give you a bound, and when is it loose?" Weak: "because quantum mechanics." Strong: expectation ≥ ground energy for any state; loose when the ansatz can't reach the ground state.
  • "Your QAOA beat the baseline — convince me." Weak: reports the ratio. Strong: matched wall-clock, tuned baseline, feasibility fraction, error bars, frozen stopping rule, all restarts reported.
  • "When would you not use a variational algorithm?" Weak: never addressed. Strong: when a classical method solves it exactly in less time, when the ansatz is untrainable at that size, or when the shot budget arithmetic doesn't close.
  • "What changes at scale?" Weak: "more qubits." Strong: transpilation depth grows with connectivity limits, gradient variance decays exponentially for unstructured ansaetze, and shot cost scales with the coefficient sum — each with the mitigation it implies.