VariationalQuantum-Lab: VQE + QAOA lab - exact-graded energies, 3-optimizer race, measured plateaus!
123
Variational Quantum Algorithms Lab โ by Darion Kellar
Educational variational quantum algorithms lab in ONE pure-Python file: a from-scratch statevector simulator (<= 8 qubits, no numpy), a hardware-efficient RY + CNOT ansatz, exact parameter-shift gradients, and three from-scratch optimizers โ gradient descent, Nelder-Mead, random-restart โ raced on a 4-qubit transverse-field Ising chain and graded against the EXACT ground energy from full diagonalization of the same Hamiltonian (Jacobi eigensolver, also from scratch). QAOA runs on a 4-node MaxCut graph (brute-force optimum 4) at p=1 and p=2. Barren plateaus are measured, not named: gradient variance falls 83x from 2 to 8 qubits for a global cost (fitted slope -0.316 log10/qubit, a x0.484 factor per qubit), and far more gently for the local TFIM cost (slope -0.142) โ cost locality as a measured fact.
Pure Python standard library. Zero dependencies. Zero network. Honest scope: this is an exact CLASSICAL simulation of tiny systems at 2^n cost โ that cost is the lesson. No quantum advantage is claimed, no hardware is touched, the noise section is a LABELLED toy depolarizing model, and every real-world claim (advantage, production optimization, drug/materials discovery, certified chemistry) is a permanent HOLD gate (14 total).
docker pull credkellar/variationalquantum-lab:latest
docker run --rm credkellar/variationalquantum-lab:latest
The default command runs the full demo plus the built-in self-checks (CHECKS 54/54).
Run a specific command instead:
docker run --rm credkellar/variationalquantum-lab:latest python3 main.py checks # CHECKS 54/54
docker run --rm credkellar/variationalquantum-lab:latest python3 main.py vqe # VQE vs exact, both Hamiltonians
docker run --rm credkellar/variationalquantum-lab:latest python3 main.py race # the 3-optimizer race table
docker run --rm credkellar/variationalquantum-lab:latest python3 main.py qaoa # MaxCut ratios p=1 / p=2
docker run --rm credkellar/variationalquantum-lab:latest python3 main.py plateau # measured gradient variances + fits
docker run --rm credkellar/variationalquantum-lab:latest python3 main.py classify # kNN trainability report
docker run --rm credkellar/variationalquantum-lab:latest python3 main.py holds # 14 HOLD gates
python:3.12-slimScience ยท Developer tools ยท Machine learning & AI
credkellar/variationalquantum-lab:latestdocker pull credkellar/variationalquantum-lab:latest