
Variational Quantum Eigensolver (Pillar 6 main entry point)
Source:R/quantum_vqe.R
quantum_vqe_fit.RdRuns the Peruzzo et al. 2014 VQE on the supplied Hamiltonian with
a hardware-efficient EfficientSU2 ansatz (Kandala et al. 2017) and
a classical optimiser (default COBYLA). The optimisation trajectory
is captured by a callback so the energy curve can be plotted or
audited after the fact.
Arguments
- hamiltonian
An
edaphos_quantum_hamiltonian.- ansatz_reps
Integer — number of
EfficientSU2repetition blocks. More blocks increase expressivity at the cost of more variational parameters.- optimizer
Character — one of
"COBYLA"(default),"SPSA","SLSQP","L-BFGS-B". Shot-based and hardware runs strongly prefer"SPSA"because it is robust to stochastic cost-function evaluations (Spall 1998).- max_iter
Integer — maximum classical-optimiser iterations.
- backend
Character — one of
"aer_statevector"(default, exact),"aer_shots"(shot-based simulation),"ibmq"(real IBM Quantum hardware). See Details.- shots
Integer — number of circuit shots per energy evaluation. Ignored when
backend = "aer_statevector". Defaults to4096for"aer_shots"and"ibmq"when leftNULL.- mitigation
Character — one of
"none"(default),"m3","zne". Controls hardware error mitigation; see Details.- ibmq_backend
Character — name of the target IBM Quantum backend (e.g.
"ibm_brisbane","ibm_sherbrooke") whenbackend = "ibmq". IfNULL, the least-busy operational backend available to the account is selected automatically.- seed
Optional integer — seeds NumPy / Qiskit RNGs for reproducible runs.
- initial_point
Optional numeric vector — custom starting ansatz parameters. Defaults to Qiskit's random initial point.
Value
An edaphos_quantum_vqe object with:
- energy
Ground-state energy estimate.
- exact
Numerically exact ground-state energy, for reference.
- gap
Absolute difference
|energy - exact|.- parameters
Numeric vector of optimal ansatz parameters.
- history
Numeric vector of energy values, one per optimiser iteration (via callback).
- n_iter
Integer iteration count.
- shots, mitigation
Echo of the execution configuration.
- hamiltonian,ansatz,optimizer,backend
Configuration echo.
Details
Three execution back ends are supported as of v0.9.0:
"aer_statevector"(default)Exact noiseless statevector simulation via
qiskit.primitives.StatevectorEstimator. The ansatz is not transpiled. Deterministic; limited by memory to roughly 24 qubits."aer_shots"Shot-based simulation via
qiskit_aer.primitives.EstimatorV2. Each energy evaluation is estimated fromshotscircuit executions and therefore carries a finite-sample noise of order1/sqrt(shots). The ansatz is transpiled to the standard\{id, rz, sx, x, cx, u\}basis gate set so that the Aer primitive can dispatch it."ibmq"Real hardware via
qiskit_ibm_runtime.EstimatorV2inside a RuntimeSession. Requires theqiskit-ibm-runtimePython package and anIBMQ_TOKENenvironment variable. Supports two mitigation strategies (Kim et al. 2023, see References):mitigation = "m3"— Matrix-free Measurement Mitigation (TREX + M3 readout correction), mapped to IBM runtimeresilience_level = 1;mitigation = "zne"— Zero-Noise Extrapolation over gate-folding noise scales, mapped to IBM runtimeresilience_level = 2.
References
Peruzzo, A. et al. (2014). A variational eigenvalue solver on a photonic quantum processor. Nature Communications 5, 4213.
Kandala, A. et al. (2017). Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets. Nature 549, 242–246.
Kim, Y. et al. (2023). Evidence for the utility of quantum computing before fault tolerance. Nature 618, 500–505.
Spall, J. C. (1998). Implementation of the simultaneous perturbation algorithm for stochastic optimisation. IEEE Transactions on Aerospace and Electronic Systems 34, 817–823.
Examples
if (FALSE) { # \dontrun{
ham <- quantum_hamiltonian_h2()
# 1) Exact noiseless reference (fast).
fit <- quantum_vqe_fit(ham, backend = "aer_statevector", seed = 1L)
# 2) Shot-based simulation with SPSA (honest to finite sampling).
fit_s <- quantum_vqe_fit(ham, backend = "aer_shots",
shots = 4096L, optimizer = "SPSA",
max_iter = 100L, seed = 1L)
# 3) Real IBM Quantum hardware with M3 readout mitigation.
if (quantum_ibmq_available()) {
fit_q <- quantum_vqe_fit(ham, backend = "ibmq",
shots = 4096L,
mitigation = "m3",
ibmq_backend = "ibm_brisbane",
optimizer = "SPSA",
max_iter = 50L)
}
} # }