VQE for LiH Molecule Ground State
What You'll Learn:
- How to scale VQE from 2 qubits (H2) to 4 qubits (LiH)
- How hardware-efficient ansatze use layered RY-RZ-CX structures
- How Pauli string measurements work for multi-qubit Hamiltonians
- Why larger molecules are harder: barren plateaus, parameter space, and noise
Level: Intermediate | Time: 30 minutes | Qubits: 4 | Framework: Qiskit
Prerequisites
- H2 Ground State — VQE fundamentals on 2 qubits
- Bell State — CX entanglement basics
The Idea
Hydrogen (H2) was a warm-up: 2 qubits, 4 parameters, a tiny Hamiltonian you could diagonalize by hand. Now we scale up. Lithium hydride (LiH) has 4 electrons (3 from lithium, 1 from hydrogen). In the minimal STO-3G basis that is 12 qubits (6 spatial orbitals); getting down to 4 qubits takes further reductions, such as freezing the lithium 1s core and dropping orbitals. The real 12-qubit (Jordan-Wigner) Hamiltonian has 631 Pauli terms; this tutorial uses a 9-term model Hamiltonian instead (see below), and the ansatz needs 16 parameters across 2 layers.
This is where VQE starts to earn its keep. At 4 qubits, classical diagonalization is still easy (16x16 matrix). But the same approach applied to larger molecules (caffeine: 102 electrons) would require matrices far too large for any classical computer. VQE's hybrid quantum-classical loop scales more gracefully.
The catch: more parameters mean a larger optimization landscape, more circuit depth, and increased sensitivity to noise. Welcome to the real challenges of quantum chemistry.
How It Works
The Ansatz: 2-Layer Hardware-Efficient
Each layer has: (1) RY+RZ rotations on every qubit, then (2) a linear CX chain.
CODELayer 1 Layer 2 ┌────────┐┌────────┐ ┌─────────┐┌─────────┐ q0: ┤ RY(θ₀)├┤ RZ(θ₁)├──■────────── ┤ RY(θ₈) ├┤ RZ(θ₉) ├──■── ├────────┤├────────┤┌─┴─┐ ├─────────┤├─────────┤┌─┴─┐ q1: ┤ RY(θ₂)├┤ RZ(θ₃)├┤ X ├──■── ┤ RY(θ₁₀)├┤ RZ(θ₁₁)├┤ X ├──■── ├────────┤├────────┤└───┘┌─┴─┐ ├─────────┤├─────────┤└───┘┌─┴─┐ q2: ┤ RY(θ₄)├┤ RZ(θ₅)├─────┤ X ├──■── ┤ RY(θ₁₂)├┤ RZ(θ₁₃)├─────┤ X ├──■── ├────────┤├────────┤ └───┘┌─┴─┐ ├─────────┤├─────────┤ └───┘┌─┴─┐ q3: ┤ RY(θ₆)├┤ RZ(θ₇)├──────────┤ X ├ ┤ RY(θ₁₄)├┤ RZ(θ₁₅)├──────────┤ X ├ └────────┘└────────┘ └───┘ └─────────┘└─────────┘ └───┘
- RY: Controls the polar angle on the Bloch sphere (amplitude mixing)
- RZ: Controls the azimuthal angle (phase control)
- CX chain: Creates nearest-neighbor entanglement (0→1→2→3)
- 16 parameters: 4 qubits × 2 rotations × 2 layers
The linear CX chain maps onto a line of neighbouring qubits without SWAP gates, although the gates are still translated into each device's native gate set (for example, transpiling to an ECR-based gate set takes the circuit depth from 10 to 22).
The Hamiltonian: 9 Dominant Pauli Terms
The full LiH Hamiltonian in STO-3G has 100+ Pauli terms (631 under Jordan-Wigner). Here we use an illustrative 9-term model Hamiltonian, not the 9 largest terms of the real one: the real Hamiltonian has large single-qubit Z terms (up to about 1 Ha), which this model leaves out. The model's constant term is set so its lowest eigenvalue is -7.8825 Ha, close to the FCI/STO-3G energy of LiH at 1.6 Å (-7.8823 Ha). The energies on this page show how VQE behaves on this model; they are not a LiH calculation.
| Term | Coefficient | Physical meaning |
|---|---|---|
| IIII | -7.2062 | Constant offset (set so the lowest eigenvalue is -7.8825 Ha) |
| ZZII | +0.1722 | Z-Z correlation, qubits 3-2 |
| IIZZ | +0.1209 | Z-Z correlation, qubits 1-0 |
| ZIZI | +0.1659 | Alternating Z correlation |
| IZIZ | +0.1659 | Alternating Z correlation |
| XXII | +0.0454 | Exchange (XX), qubits 3-2 |
| YYII | +0.0454 | Exchange (YY), qubits 3-2 |
| IIXX | +0.0505 | Exchange (XX), qubits 1-0 |
| IIYY | +0.0505 | Exchange (YY), qubits 1-0 |
Pauli strings are written with the highest qubit first, as in Qiskit: the leftmost character acts on qubit 3, the rightmost on qubit 0.
Measuring Multi-Qubit Pauli Strings
Each 4-character Pauli string requires its own measurement circuit. Before measuring, rotate each qubit into the appropriate basis:
- I or Z: No rotation (computational basis)
- X: Apply H (Hadamard)
- Y: Apply S†H
For example, to measure XXII, apply H on qubits 3 and 2 (the X positions, since the leftmost character is the highest qubit), leave qubits 1 and 0 unchanged, then measure all in the computational basis.
PYTHONfrom circuit import run_circuit, optimize_vqe # Quick evaluation with initial parameters result = run_circuit() print(f"Energy: {result['energy']:.4f} Ha") # Full optimization (takes longer — 16 parameters) opt = optimize_vqe(max_iterations=200, shots=2048, seed=42) print(f"Optimized: {opt['optimal_energy']:.4f} Ha")
The Math
Scaling from H2 to LiH
| Property | H2 | LiH | Growth |
|---|---|---|---|
| Electrons | 2 | 4 | 2× |
| Qubits | 2 | 4 | 2× |
| Parameters | 4 | 16 | 4× |
| Hamiltonian terms | 5 | 9 (simplified) | 1.8× |
| Matrix size | 4×4 | 16×16 | 4× |
| Measurement circuits | 2 | 8 | 4× |
The parameter count grows as O(qubits × layers), and measurement circuits grow with the number of unique Pauli bases. This is the fundamental scaling challenge of VQE.
Barren Plateaus
A barren plateau is a region of the optimization landscape where gradients become vanishingly small:
CODEVar(∂E/∂θ_i) shrinks exponentially with the number of qubits n (for random circuits deep enough to scramble the state; McClean et al. 2018)
At a fixed number of qubits, adding layers does not make the gradient vanish. For this 4-qubit ansatz and model Hamiltonian, sampling random parameters gives Var(∂E/∂θ₀) of about 0.003 to 0.004 at every depth from 2 to 64 layers, with no decay. The problem grows with qubit count, which is why it matters for larger molecules. Strategies:
- Use few layers (we use 2)
- Initialize near identity (small angles)
- Use problem-informed ansatze instead of hardware-efficient ones
Expected Output
| Metric | Value |
|---|---|
| Exact ground state (FCI/STO-3G) | -7.8825 Ha |
| VQE with optimized parameters | -7.8 to -7.9 Ha |
| Initial guess energy | ~-6.6 Ha |
| Chemical accuracy threshold | ±1.6 mHa |
With a simplified 9-term Hamiltonian, VQE may not reach chemical accuracy. The full 100+ term Hamiltonian is needed for production-quality results.
Running the Circuit
PYTHONfrom circuit import run_circuit, optimize_vqe, verify_vqe # Quick evaluation result = run_circuit() print(f"Energy: {result['energy']:.4f} Ha (error: {result['error']:.4f})") # Full optimization opt = optimize_vqe(max_iterations=200, shots=2048, seed=42) print(f"Optimized: {opt['optimal_energy']:.4f} Ha") print(f"Chemical accuracy: {opt['chemical_accuracy']}") # Verification v = verify_vqe() for check in v["checks"]: status = "PASS" if check["passed"] else "FAIL" print(f"[{status}] {check['name']}: {check['detail']}")
Try It Yourself
-
Add a 3rd layer: Change
layers=3and use 24 parameters. Does the extra depth improve the energy, or does it hit a barren plateau? -
Reduce to 1 layer: Use only 8 parameters. How much accuracy is lost? This quantifies the expressibility vs. trainability trade-off.
-
Try full connectivity: Replace the linear CX chain with all-to-all CX (0→1, 0→2, 0→3, 1→2, 1→3, 2→3). Does this improve convergence?
-
Compare optimizers: Try
method="Nelder-Mead"ormethod="Powell". Which handles the 16-dimensional landscape best? -
Plot the potential energy surface: Run VQE at Li-H bond lengths from 1.0 to 3.0 A (adjust coefficients). Does VQE reproduce the Morse potential shape?
What's Next
- H2O Ground State — 4 qubits with active space reduction for water
- BeH2 Ground State — 6 qubits, the largest in the VQE progression
- QAOA MaxCut — Variational algorithms for optimization (not chemistry)
Applications
| Domain | Use case |
|---|---|
| Benchmark | Standard test for VQE implementations beyond H2 |
| Education | Stepping stone from 2-qubit to multi-qubit chemistry |
| Algorithm R&D | Testing ansatz designs, optimizer strategies, error mitigation |
| Materials | LiH is a precursor to lithium-ion battery materials |
References
- Kandala, A. et al. (2017). "Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets." Nature 549, 242-246. DOI: 10.1038/nature23879
- Peruzzo, A. et al. (2014). "A variational eigenvalue solver on a photonic quantum processor." Nature Communications 5, 4213. DOI: 10.1038/ncomms5213
- McClean, J.R. et al. (2018). "Barren plateaus in quantum neural network training landscapes." Nature Communications 9, 4812. DOI: 10.1038/s41467-018-07090-4