A variational quantum eigensolver (VQE) experiment is easier to improve when its decisions are separated into measurable parts: the ansatz controls the search space, the optimizer controls parameter updates, and the measurement plan controls estimation cost and noise sensitivity. This workflow shows how to choose those components, estimate a run before submitting it, diagnose stalled convergence, and record results in a way that makes later experiments comparable.
Overview
VQE estimates the lowest eigenvalue of a problem Hamiltonian by combining a parameterized quantum circuit with a classical optimization loop. The circuit prepares a state such as |ψ(θ)⟩, the quantum processor estimates the expectation value of the Hamiltonian, and a classical optimizer changes the parameters θ to reduce that energy.
For a Hamiltonian written as a weighted sum of Pauli operators, H = Σᵢ cᵢPᵢ, the measured objective is:
E(θ) = ⟨ψ(θ)|H|ψ(θ)⟩ = Σᵢ cᵢ⟨Pᵢ⟩
The theoretical minimum is bounded by the ground-state energy, but a practical result is also shaped by circuit depth, parameter count, shot noise, optimizer behavior, compilation, and hardware noise. A useful VQE workflow therefore starts with a resource estimate rather than immediately increasing the circuit size.
The three decisions that dominate a VQE run
- Ansatz: Which states can the circuit represent, and what depth and parameter count does that require?
- Optimizer: How will the classical loop use noisy objective values to update parameters?
- Measurement strategy: How many Hamiltonian terms must be measured, and which compatible terms can share a circuit setting?
Keep these decisions independent during early experiments. If an ansatz, optimizer, and measurement budget all change at once, it becomes difficult to identify why the energy improved or failed to converge.
Pre-run checklist
- Define the Hamiltonian, qubit mapping, and target energy or accuracy.
- Count Hamiltonian terms and identify commuting measurement groups.
- Choose an ansatz appropriate to the problem and hardware constraints.
- Set parameter initialization and record whether parameters are symmetry-preserving.
- Choose an optimizer with a clear stopping rule and iteration limit.
- Estimate shots, circuit executions, depth, and expected classical iterations.
- Run a noiseless or statevector baseline when practical.
- Validate the circuit and objective with unit tests before using hardware.
How to estimate
Estimate VQE cost in layers. The first layer is the number of optimization iterations. The second is the number of measurement settings per iteration. The third is the shot count used for each setting. A simple execution estimate is:
Total shots ≈ iterations × measurement settings × shots per setting
If the implementation evaluates separate parameter-shift circuits for a gradient, include those executions as well. For an objective-only optimizer, the estimate may be close to one objective evaluation per iteration, although line searches, restarts, or adaptive routines can add evaluations. For a gradient-based method, use:
Total circuit evaluations ≈ iterations × (objective evaluations + gradient evaluations)
The precise count depends on the framework primitive and optimizer implementation, so treat this as a planning model rather than a billing guarantee. Confirm the actual job and circuit count in the selected SDK or platform after a small dry run.
Ansatz and optimizer comparison
| Choice | Useful when | Main advantage | Main risk or cost |
|---|---|---|---|
| Hardware-efficient ansatz | Testing a device-aware prototype | Uses native-friendly layers and flexible rotations | May explore states that do not respect problem symmetries; depth can grow quickly |
| Problem-inspired ansatz | Quantum chemistry or structured Hamiltonians | Builds in domain structure and may reduce the search space | Requires a suitable model and can be harder to adapt |
| Unitary coupled-cluster-style ansatz | Electronic-structure workflows with a chemistry-driven reference | Connects parameters to excitation structure | Compilation and parameter count can become demanding |
| Layered shallow ansatz | Baseline comparisons and noisy hardware tests | Simple to scale and benchmark | May lack expressibility for the target state |
| Gradient-based optimizer | Objectives with usable, stable gradients | Can use directional information efficiently | Gradient estimation adds circuit evaluations and may be noise-sensitive |
| Gradient-free optimizer | Low-dimensional or noisy objectives | Does not require explicit gradients | May need many objective evaluations and can be sensitive to scaling |
| Shot-aware or stochastic optimizer | Finite-shot measurements and changing objective variance | Can account for noisy function values | Requires careful tuning and consistent logging |
There is no universally best VQE ansatz or optimizer. Start with the smallest ansatz that can represent the expected solution, then add layers only when a controlled baseline shows that expressibility is the limiting factor. Similarly, begin with an optimizer that matches the objective’s measurement noise instead of selecting one solely because it performs well on an ideal simulator.
Measurement grouping
Each Pauli term in the Hamiltonian contributes to the energy estimate. Terms that can be measured in the same basis may be grouped into one circuit setting, reducing repeated state preparation. A typical workflow is:
- Represent each Hamiltonian term as a Pauli string.
- Identify terms compatible with the same measurement basis or commuting group.
- Assign a shot allocation to each group.
- Estimate each group’s expectation value and combine it using the Hamiltonian coefficients.
Grouping reduces the number of settings, but it does not automatically reduce statistical error. A group containing large coefficients or high-variance terms may deserve more shots. For a first comparison, use a fixed allocation so that changes in energy can be attributed to the ansatz or optimizer. Once the baseline is stable, compare uniform allocation with coefficient- or variance-aware allocation.
Keep measurement conventions consistent. Qubit ordering, bit-string interpretation, basis rotations, and identity terms can create apparent energy changes that are really implementation differences. Measurement behavior also varies across SDK primitives, so test a small known circuit before running the full Hamiltonian.
Inputs and assumptions
Record the following inputs before estimating a VQE run:
- Problem size: Number of qubits, Hamiltonian terms, coefficients, and symmetry constraints.
- Ansatz: Circuit family, number of layers, parameter count, entangling pattern, and initial state.
- Compilation: Target gate set, connectivity assumptions, transpiled depth, and two-qubit gate count.
- Optimizer: Name, initial step or trust-region settings, gradient method if applicable, maximum iterations, and stopping tolerance.
- Measurements: Number of groups, shots per group, allocation method, and whether measurements are sampled or exact.
- Noise: Simulator noise model or hardware backend, readout treatment, error mitigation, and calibration context.
- Validation: Reference energy, symmetry checks, conservation checks, and independent objective evaluation.
Distinguish three different sources of uncertainty. Optimization error means the classical loop has not found the best parameters it could reach. Ansatz error means the circuit family cannot represent a sufficiently good state. Sampling and hardware error means the measured objective differs from the ideal expectation value. These require different remedies, so do not respond to every energy plateau by adding ansatz layers.
Diagnostics for stalled convergence
- If the energy is nearly constant from the first iteration, inspect parameter initialization, gradients, and whether the circuit contains inactive parameters.
- If the energy moves erratically, increase shots for a diagnostic run, check objective scaling, and compare repeated evaluations at the same parameters.
- If the simulator converges but hardware does not, compare transpiled depth, measurement error, and noise sensitivity before changing the optimizer.
- If different seeds reach very different energies, test whether the ansatz has multiple basins or whether the optimizer is reacting to shot noise.
- If the energy appears lower than a trusted physical bound, check sign conventions, qubit ordering, Hamiltonian construction, and measurement aggregation.
Use a convergence plot with iteration on the horizontal axis and energy on the vertical axis. Add a second plot for objective variance or repeated-evaluation spread. A single final energy is not enough to explain a VQE result.
Worked examples
Example 1: estimating a baseline run
Assume a small Hamiltonian has 18 Pauli terms, which are grouped into 7 measurement settings. You plan 100 iterations and 2,000 shots per setting. The basic shot estimate is:
100 × 7 × 2,000 = 1,400,000 shots
This estimate excludes extra evaluations from line searches, gradient circuits, retries, and framework overhead. If the optimizer needs a parameter-shift gradient with one additional circuit evaluation per parameter and the ansatz has 12 parameters, the circuit-evaluation budget can be substantially larger than the objective-only estimate. Before committing to the full run, execute five iterations and inspect the actual number of submitted circuits and returned samples.
Example 2: choosing between a deeper ansatz and more shots
Suppose a shallow ansatz reaches a stable energy but remains above the reference value, while repeated measurements at the same parameters have low spread. This pattern suggests that sampling noise is not the primary limitation. Test one additional ansatz layer in simulation or with a small hardware budget, then compare depth, parameter count, and energy improvement.
Conversely, if repeated measurements at fixed parameters vary enough to obscure the optimizer’s direction, adding layers may make the problem harder. First increase shots for selected iterations, use a noise-aware or gradient-free baseline, or improve measurement allocation. The decision should be based on whether the limiting signal is representation capacity or objective precision.
Run-record template
| Field | Value to record |
|---|---|
| Problem and mapping | Hamiltonian label, qubits, mapping, symmetry constraints |
| Ansatz | Family, layers, parameters, initial state, seed |
| Optimizer | Method, settings, maximum iterations, stopping rule |
| Measurement | Groups, shots per group, allocation, estimator configuration |
| Backend | Simulator or hardware target, compilation settings, noise model |
| Outcome | Final energy, best energy, iteration count, circuit evaluations |
| Resources | Total shots, transpiled depth, two-qubit gates, elapsed runtime if available |
| Diagnostics | Repeated-evaluation spread, symmetry result, failure notes |
For implementation reliability, pair this record with circuit tests and a resource estimate. See unit testing across Qiskit, Cirq, and PennyLane, quantum circuit resource estimation, and the quantum program debugging workflow.
When to recalculate
Recalculate the VQE estimate whenever an input that affects circuit count, measurement cost, or noise changes. That includes adding Hamiltonian terms, changing the qubit mapping, increasing ansatz layers, switching optimizers, enabling gradient evaluations, changing shot allocation, or targeting a different backend.
Refresh the estimate after a major SDK release or backend change as well. Estimator primitives, transpilation behavior, supported optimizers, measurement grouping, batching, and job accounting can change the practical number of circuits even when the algorithm is unchanged. Treat documented API behavior and a small dry run as the source of truth for the environment you are using.
Before each new experiment, take these actions:
- Copy the previous run record and mark every changed input.
- Recompute settings, shots, iterations, and gradient overhead.
- Run a short validation job with fixed parameters.
- Compare ideal, noisy-simulator, and hardware results when available.
- Save the convergence plot and final resource counts with the energy.
- Only then scale the run to its full budget.
This repeatable process turns VQE from a trial-and-error circuit exercise into a measurable experiment. The best next change is usually the one that tests a specific diagnosis: improve the ansatz when representation is limiting, improve measurements when variance is limiting, and change the optimizer only after confirming that the objective and implementation are behaving as expected.