VQE is most useful when treated as a controlled experiment rather than a single notebook run. This workflow shows how to implement a Variational Quantum Eigensolver in Qiskit or PennyLane, compare ansatzes and optimizers, and benchmark results across ideal simulators, noisy simulations, and available quantum hardware. It also provides a repeatable run plan, a result schema, and checkpoints for deciding whether a change improved the algorithm or merely changed the experimental conditions.
Overview
The Variational Quantum Eigensolver estimates the lowest eigenvalue of a problem Hamiltonian. In a typical quantum chemistry experiment, the Hamiltonian is written as a weighted sum of measurable Pauli operators:
H = Σᵢ cᵢ Pᵢ
A parameterized circuit, or ansatz, prepares a state |ψ(θ)⟩. The quantum program measures the expectation value of each Pauli term, while a classical optimizer updates θ to minimize the energy:
E(θ) = ⟨ψ(θ)|H|ψ(θ)⟩
The algorithm is hybrid: circuit execution and measurement happen on a quantum simulator or device, while parameter selection happens classically. That division makes VQE a useful case study for hybrid quantum-classical computing, but it also creates several sources of variation. Results depend on the Hamiltonian mapping, initial parameters, ansatz depth, optimizer, shot count, transpilation, noise model, and stopping rule.
A fair VQE benchmark therefore changes one factor at a time. Start with a small, reproducible Hamiltonian and an ideal statevector or exact expectation-value calculation. Then introduce finite shots, noise, and hardware execution as separate stages. Do not compare a deep ansatz with a shallow ansatz while also changing the optimizer and backend; the resulting difference will be difficult to attribute.
For a conceptual introduction and a complete hybrid workflow, see the VQE tutorial on hybrid quantum-classical optimization. The paper reproduction workflow is also useful when translating published VQE experiments into runnable code.
What to track
1. Define the problem and reference value
Record the Hamiltonian, coefficient precision, qubit count, mapping method if applicable, and the reference energy used for comparison. For small problems, an exact diagonalization result can provide a reference. Label it clearly as a reference calculation, not as a result produced by VQE.
Before optimization, verify basic implementation details: each Pauli term is represented correctly, identity terms are included, qubit ordering is consistent, and the circuit measures the operators required by the Hamiltonian. A sign or ordering error can look like optimizer failure.
2. Compare ansatzes by resource and expressivity
Useful baseline choices include a hardware-efficient ansatz, a problem-informed ansatz, and a deliberately shallow circuit. Track:
- Number of trainable parameters.
- Circuit depth before and after transpilation.
- Total gate count and two-qubit gate count.
- Connectivity assumptions and inserted routing operations.
- Initial-state preparation and symmetry constraints.
A lower final energy does not automatically make an ansatz better. If it uses substantially more two-qubit gates or evaluations, it may be less practical on noisy hardware. Inspect the transpiled circuit with a circuit visualizer and record backend-specific resource counts. The transpilation guide explains why the same logical ansatz can have different physical costs on different backends.
3. Compare optimizers under the same budget
Common VQE choices include gradient-based methods, parameter-shift-compatible methods, and derivative-free methods. The right comparison is not simply “which optimizer reached the lowest value?” Use a fixed evaluation budget or a clearly defined stopping rule, and record:
- Initial parameter seed and parameter initialization method.
- Maximum iterations and maximum circuit evaluations.
- Final energy, best observed energy, and energy error.
- Final energy variance or another convergence diagnostic.
- Wall-clock runtime and quantum execution time when available.
- Whether gradients, finite differences, or function values were used.
Run multiple seeds when the experiment is affordable. A single successful run can hide sensitivity to initialization. Keep optimizer settings in the log rather than relying on notebook state.
4. Use a result log that supports reruns
A compact CSV schema can make quarterly comparisons much easier:
date,framework,framework_version,problem,qubits,ansatz,parameters,optimizer,seed,backend,shots,noise_model,iterations,circuit_evals,depth,two_qubit_gates,final_energy,reference_energy,energy_error,variance,runtime_seconds,status,notes
For each row, save the code revision, environment specification, backend configuration, and Hamiltonian definition. Qiskit and PennyLane APIs evolve, so recording versions is part of the experiment—not administrative overhead. Keep ideal, noisy, and hardware runs in separate categories even when they use the same logical circuit.
Cadence and checkpoints
Use a staged run plan rather than sending every experiment directly to hardware.
- Implementation check: run a tiny Hamiltonian with exact or high-precision expectations. Confirm energy evaluation and measurement grouping.
- Ideal baseline: compare ansatzes and optimizers on an ideal simulator with a fixed seed and generous evaluation budget.
- Shot-based check: introduce a fixed shot count and repeat selected configurations. Measure the effect of sampling noise.
- Noisy simulation: apply a documented noise model or backend-derived configuration. Treat its parameters as experimental inputs, not universal device properties.
- Hardware run: select a small number of finalists. Record queue time separately from execution time where possible, and preserve the transpiled circuit and backend metadata.
At every checkpoint, ask whether the comparison remains controlled. If the simulator uses exact expectation values while hardware uses finite shots, report those as different execution modes. If a framework automatically selects measurement strategies or transforms circuits, record that behavior and avoid presenting raw circuit counts as directly comparable without qualification.
For measurement interpretation, review the guide to counts, probabilities, and shot noise. For framework selection and portability considerations, use the quantum SDK comparison as a companion reference.
How to interpret changes
Separate four outcomes that are often conflated:
- Optimization improvement: the same circuit and execution model reaches a lower energy or converges more reliably.
- Ansatz improvement: the circuit reaches a comparable or better energy with fewer parameters or lower physical cost.
- Sampling improvement: repeated estimates become more stable as shot allocation or measurement handling changes.
- Hardware improvement: a device run retains more of the ideal result after accounting for depth, routing, calibration context, and statistical uncertainty.
Use energy error against the reference as the primary quality measure, but pair it with variance and resource metrics. A low final energy reached after unstable oscillations may not be a robust result. Conversely, a slightly higher energy with much lower two-qubit cost may be the better engineering choice.
When a hardware result changes, first check the mundane explanations: transpiled depth, routing, shots, initialization, measurement mitigation, backend selection, and time-dependent device conditions. Do not attribute every difference to the optimizer. If you use error mitigation, report both mitigated and unmitigated values and describe the method sufficiently for another reader to reproduce the comparison.
When to revisit
Revisit the benchmark monthly or quarterly if VQE is part of an active development effort. A lighter monthly check can rerun the fixed ideal and noisy baselines, verify that the environment still produces expected values, and detect API or dependency changes. A quarterly review can repeat the full selected matrix across ansatzes, optimizers, and execution modes.
Update the experiment sooner when a Qiskit, PennyLane, simulator, transpiler, noise-model, or hardware release changes the execution path; when a new backend becomes relevant; when measurement or error-mitigation techniques are added; or when a new ansatz changes the resource trade-off. Mark each update with a date and preserve archived rows rather than overwriting them.
For the next run, create a short run plan: choose one problem, two or three ansatzes, two optimizers, fixed seeds, a defined evaluation budget, and separate ideal, shot-based, noisy, and hardware stages. Export the CSV after every completed configuration, inspect the transpiled circuits, and write one sentence explaining each meaningful change. This turns a VQE implementation into a benchmark that can be reproduced, compared, and improved as software and hardware change.