Curriculum / Real-World Quantum Python / Capstone: Production VQE Pipeline
Capstone: Production VQE Pipeline
Build a production-quality VQE pipeline with circuit optimization, noise mitigation, caching, and benchmarking.
Capstone: Production VQE Pipeline
Integrate the core concepts from this track into a production-quality Variational Quantum Eigensolver (VQE) pipeline. This capstone combines: circuit construction, state vector simulation, optimization, error mitigation, and benchmarking.
What You Will Build
A complete VQE system for the 2-qubit Ising transverse field Hamiltonian: H = Z₀ + Z₁ − X₀X₁ (ground state energy = −√5 ≈ −2.2361)
The pipeline has four checkpoints:
Checkpoint 1: Ansatz Design Build and characterize a hardware-efficient ansatz (HEA): H⊗H → RY(θ₀)⊗RY(θ₁) → CX(0,1) → RY(θ₂)⊗RY(θ₃). Count total gates and identify any redundant pairs.
Checkpoint 2: Energy Estimation Implement energy evaluation using the provided QS2 (2-qubit state vector) class. The Hamiltonian H = Z₀ + Z₁ − X₀X₁ decomposes into three Pauli terms: apply the ansatz, then measure ⟨Z₀⟩, ⟨Z₁⟩, and ⟨X₀X₁⟩ using expectation value methods.
The parameter-shift gradient is provided: two circuit evaluations per parameter give the exact gradient. Your implementation of energy_ising feeds directly into the gradient computation.
Checkpoint 3: VQE Optimization Run gradient descent VQE. The optimizer calls your energy function repeatedly, adjusting parameters to minimize ⟨H⟩. Target: reach within 1 mHa (0.001 Ha) of the ground state −√5 ≈ −2.2361.
Checkpoint 4: Production Report Format a complete pipeline summary showing the initial energy, final optimized energy, error relative to the true ground state, and circuit statistics. This is the deliverable format for a real quantum chemistry workflow.
Scaffold and Implementation Guide
The Circuit class (gate tracking) and QS2 class (2-qubit state vector with expectation value methods) are provided. You implement:
- 1.
build_hea_ansatz(params): add H, RY, CX, RY gates using the Circuit API - 2.
count_redundant_pairs(gates): count adjacent identical self-inverse gates (H/X/Z on same qubit) - 3.
energy_ising(params): create QS2, apply circuit, return ⟨Z₀⟩ + ⟨Z₁⟩ − ⟨X₀X₁⟩ - 4.The gradient and optimizer are provided: your energy function is called automatically
- 5.Checkpoint 4 print statements: format the summary report
This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.
How this lesson works
A multi-step project that combines several concepts into one larger build, checked checkpoint by checkpoint as you go.
Part of: Real-World Quantum Python
Write production-quality quantum Python, circuit optimization, hybrid algorithms, cloud backends, noise modeling, and software engineering patterns.
This lesson is part of Pro
Unlock Real-World Quantum Python and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.