This project implements a Variational Quantum Eigensolver (VQE) pipeline for a Hydrogen molecule (
ZNE is a powerful error mitigation technique that artificially scales the noise of a quantum circuit, tracks the degraded observables, and extrapolates backwards to the zero-noise limit.
Paper Acknowledgment This implementation and the underlying mathematics are deeply inspired by the foundational work on error mitigation:
"Error mitigation for short-depth quantum circuits" Kristan Temme, Sergey Bravyi, and Jay M. Gambetta (2017) Physical Review Letters 119, 180509
VQE is a hybrid quantum-classical algorithm used to find the lowest eigenvalue (ground state energy) of a given Hamiltonian
-
Quantum State Preparation: A parameterized quantum circuit (ansatz),
$U(\vec{\theta})$ , prepares a trial state$|\psi(\vec{\theta})\rangle$ . -
Measurement: The expectation value
$E(\vec{\theta}) = \langle\psi(\vec{\theta})|H|\psi(\vec{\theta})\rangle$ is measured. -
Classical Optimization: A classical optimizer (like the Adam optimizer used here) updates the parameters
$\vec{\theta}$ to minimize$E(\vec{\theta})$ and navigate the energy landscape.
In real quantum hardware, gates suffer from decoherence and depolarizing errors, pulling the expectation value away from the true, ideal energy. ZNE elegantly circumvents this without requiring complex hardware upgrades.
-
Noise Scaling via Unitary Folding: If we cannot subtract noise from the hardware, we intentionally add it by a scale factor
$c$ . We achieve this through Unitary Folding. For any quantum gate$G$ , we map:$$G \rightarrow GG^\dagger G$$ Logically,$GG^\dagger G = G$ , so the ideal mathematical operation remains entirely identical. Physically, however, it triples the execution time of the gate ($c=3$ ), meaning the qubit experiences exactly 3x the depolarizing noise. -
Richardson Extrapolation: By evaluating the energy at multiple elevated noise scale factors (e.g.,
$c={1,3,5}$ ), we map out the "noise curve". We then perform Richardson Extrapolation, taking a carefully weighted linear combination of these values to mathematically cancel out the first few orders of the noise parameter and project backward to the$c=0$ limit:$$E_{mitigated} = \sum_j \gamma_j E(c_j)$$ Where the Richardson Weights are defined as:$$\gamma_j = \prod_{m \neq j} \frac{c_m}{c_j - c_m}$$
-
src/vqe_baseline.py(Phase 1): Runs an ideal, noise-free VQE simulation on PennyLane'sdefault.qubitto establish the exact baseline energy (-0.889 Ha). -
src/vqe_noisy.py(Phase 2): Injects a realistic depolarizing noise model (0.1% single-qubit, 1% two-qubit error rates) into the simulation. This demonstrates how drastically noise degrades the energy readout, shifting it up to -0.686 Ha. -
src/vqe_zne.py(Phase 3): Implements Unitary Folding dynamically during the optimization loop. The Adam optimizer differentiates directly through the Richardson Extrapolation layer, minimizing the mitigated cost function and pulling the energy back down to -0.897 Ha. -
main.py: The main execution pipeline. Runs all three phases sequentially and generates comparison plots. -
data/: Contains the generated visualisations:-
extrapolation_curve.png: The classical ZNE extrapolation curve plotting energy vs noise scale factor$c$ . -
convergence_landscape.png: The VQE optimization landscape showing$E(1) < E(3) < E(5)$ . -
absolute_error.png: Absolute error charts demonstrating a massive >23x error reduction.
-
Ensure you have a Python virtual environment set up with pennylane, matplotlib, and numpy installed.
# Activate your environment
source .venv/bin/activate
# Run the complete pipeline
python3 main.py