Q&A-1How does the closed-loop optimization cycle work in hybrid quantum-classical algorithms like VQE or QAOA, and how do you partition tasks between the classical host and the QPU?
Answer
Core answer (first 90 seconds). In VQE and QAOA the QPU is a coprocessor that evaluates one scalar: the expectation value of a Hamiltonian at a fixed parameter vector. Everything else runs classically. One iteration is: the host binds θ_t into an already-transpiled circuit, the QPU prepares |ψ(θ_t)⟩ and returns bitstring samples, the host converts those samples into ⟨H⟩(θ_t), the optimizer proposes θ_{t+1}, and the loop repeats until the energy or the gradient stops moving. The partition follows from what each side is good at: state preparation and measurement are quantum; Hamiltonian decomposition, ansatz synthesis, shot aggregation, error mitigation, the update rule and the convergence test are classical. The binding constraint is usually loop latency, not coherence time: a single circuit executes in microseconds, but a cloud job submission costs about a second.
Where each stage runs
| Stage | Runs on | Why |
|---|---|---|
| H → Σ c_k P_k, grouped into qubit-wise commuting sets | Host | Linear algebra; no quantum resource needed |
| Ansatz synthesis, transpile, layout | Host, once | Static; recompiling per iteration burns QPU time |
| Bind θ_t into the circuit | Host | Cheap; keeps circuit structure fixed |
| Pulse generation, state prep, gates | QPU control electronics | Only place it can happen |
| Basis rotation + measurement | QPU | The measurement basis is set by P_k |
| Shots → ⟨P_k⟩ → ⟨H⟩ | Host | Classical arithmetic |
| Readout calibration, ZNE | Host, on QPU data | Post-processing |
| Gradient / update step, convergence test | Host | Optimizer |
The interface between the tiers is narrow: (circuit, parameter vector, shot count) in, (bitstring counts) out. The QPU never sees the optimizer; the host never sees the wavefunction.
Loop
host: θ_0 ──bind──▶ QPU: prepare |ψ(θ_t)⟩, rotate to basis, measure N shots
▲ │
│ ▼
└── θ_{t+1} = θ_t − η g_t ◀── host: counts → ⟨P_k⟩ → ⟨H⟩(θ_t), g_tWorked cost trace. Take a 4-qubit transverse-field Ising problem, H = −J Σ Z_i Z_{i+1} − h Σ X_i with J = h = 1: 3 ZZ terms and 4 X terms, 7 Pauli terms total. All ZZ terms are qubit-wise commuting, as are all X terms, so the 7 terms collapse into G = 2 measurement groups. Use a hardware-efficient ansatz with P = 8 parameters and N = 4096 shots.
Parameter-shift gradient: for a gate U(θ) = e^{−iθG/2} with G² = I (any Pauli generator),
∂⟨H⟩/∂θ = ½ [⟨H⟩(θ + π/2) − ⟨H⟩(θ − π/2)].
Each gradient step needs 2P = 16 shifted evaluations, each covering G = 2 groups → 32 circuit executions, 32 × 4096 = 131,072 shots. SPSA needs only 2 evaluations per step (4 circuits, 16,384 shots) regardless of P, but typically 10× more iterations.
Wall clock: submitting 32 circuits as 32 separate cloud jobs at ~1 s round trip is ~32 s per gradient step, so 100 steps is ~53 minutes, almost all of it queue latency. Inside a session-based runtime (Qiskit Runtime sessions, Braket hybrid jobs, or a co-located container) the batch is one job and per-iteration overhead drops to milliseconds; at ~3 µs per shot the QPU work is 32 × 4096 × 3 µs ≈ 0.4 s per step, so 100 steps is under a minute. (These numbers are illustrative; the shape (latency-bound outside a session, shot-bound inside one) is the point.)
Failure modes to name.
- Barren plateaus: for random ansätze the gradient variance falls exponentially in qubit count. Log ‖g_t‖; if it sits at the shot-noise floor, more shots will not help: change the ansatz or initialize near a known-good point.
- Shot noise swamping the gradient: ⟨H⟩ has standard error σ/√N. If |g_t| is below that, the optimizer random-walks. Raise shots, switch to SPSA, or shrink the parameter space.
- Measurement blow-up: measuring each of K Pauli terms separately costs K circuits per evaluation. Grouping into qubit-wise commuting sets cuts it to G; for molecular Hamiltonians G is often 10–100× smaller than K.
- Calibration drift: T1/T2 and gate errors move between iterations, so a long loop optimizes against a moving target. Pin the calibration or run inside a session.
- Optimizer mismatch: COBYLA and SPSA tolerate shot noise but converge slowly; parameter-shift with Adam or BFGS converges fast but needs 2P evaluations per step and assumes low noise.
QAOA vs VQE. In QAOA the ansatz is fixed by the problem (p alternating cost and mixer layers, 2p free angles) so the only design choices are p and the mixer. In VQE the ansatz is the main design decision, and it drives both achievable accuracy and per-step cost.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.