VQE for H2 Excited States — Variational Quantum Deflation (VQD)
Known limitation (October 2026): This demo's Hamiltonian adds a Y₀Y₁ term to the standard two-qubit H2 Hamiltonian, so it is a model rather than H2: its ground state (-1.1954 Ha) lies 0.058 Ha below H2's exact STO-3G energy (-1.1373 Ha), which no correct H2 Hamiltonian in this basis can do. The VQD method, the overlap penalty and the choice of β on this page still work as shown, applied to this two-qubit model. A corrected version is planned.
What You'll Learn:
- How to find excited states of molecules on a quantum computer, not just the ground state
- How the VQD algorithm uses overlap penalties to enforce orthogonality between solutions
- Why the β (penalty coefficient) must exceed the energy gap — and what happens when it doesn't
- How to compute state overlaps via statevector simulation (and how swap tests work on hardware)
Level: Advanced | Time: 30 minutes | Qubits: 2 | Framework: Qiskit
Prerequisites
- VQE for H2 Ground State — standard VQE algorithm, Pauli measurement
- Bell State — entanglement with CX gates
- Hadamard Test — expectation value estimation
The Idea
Standard VQE is like searching for the lowest point in a valley — the ground state. But chemistry doesn't stop at ground states. Photosynthesis, vision, fluorescence, and most spectroscopy depend on excited states — the higher-energy configurations a molecule can occupy.
VQD (Variational Quantum Deflation) extends VQE with a clever trick: after finding the ground state, it searches for the next state while penalizing overlap with the ground state. Think of it like a ball rolling downhill, but with invisible walls placed at every valley it has already found. The ball is forced to settle into the next valley — the first excited state.
For H2, the ground state is the bonding orbital (electrons shared between the two protons, a superposition of |01⟩ and |10⟩). In the correct H2 Hamiltonian the first excited state sits about 0.61 Ha above it. In this demo's model Hamiltonian (see the note above), the first excited level is a 2-fold degenerate pair (|00⟩ and |11⟩) about 0.85 Ha above. Energy gaps set where a molecule can absorb light, although not every gap is an allowed transition (H2's lowest excited state is a spin triplet), and a minimal basis like STO-3G gives only rough excitation energies.
How It Works
Step 1: Find the Ground State (Standard VQE)
This is identical to the H2 VQE tutorial. The optimizer minimizes:
L₀(θ) = ⟨ψ(θ)|H|ψ(θ)⟩
The variational principle guarantees that every trial state's energy is at or above the true ground state energy, so lowering the energy moves toward it. It does not guarantee that the optimizer gets there: the ansatz must be able to represent the state, and the optimizer can stall. (H2's exact ground state energy in this basis is E₀ ≈ -1.137 Ha; this demo's model Hamiltonian has E₀ = -1.1954 Ha.)
Step 2: Find the First Excited State (VQD)
Now we run a second optimization with a modified cost function:
CODEL₁(θ) = ⟨ψ(θ)|H|ψ(θ)⟩ + β|⟨ψ(θ)|ψ₀⟩|² ↑ overlap penalty
The penalty term β|⟨ψ|ψ₀⟩|² adds a large energy cost whenever the new state overlaps with the ground state. This forces the optimizer to find a state that is both low-energy and orthogonal to |ψ₀⟩ — which is exactly the first excited state.
CODEWithout penalty With penalty (VQD) Energy ┌──────────────┐ ┌──────────────┐ ↑ │ │ │ │ │ E₁ ───── │ ψ₁ ───── │ │ ψ₁ ← found │ │ │ │ │ │ │ │ │ │ ╱╱╱╱╱╱╱╱╱╱ │ ← penalty wall │ E₀ ───── │ ψ₀ ← both │ │ ψ₀ (known) │ │ │ collapse │ │ │ └───────────── └──────────────┘ └──────────────┘
Step 3: Choosing β
The penalty coefficient β must be larger than the energy gap (E₁ - E₀). If β is too small, the optimizer finds it cheaper to accept the overlap penalty than to move to the excited state — it collapses back to the ground state.
| β value | Behavior |
|---|---|
| β < gap | Collapses to ground state (penalty too weak) |
| β ≈ 1.5× gap | Works but sensitive to noise |
| β ≈ 2-3× gap | Robust default (we use β = 3.0; this demo's model gap is ≈ 0.85 Ha) |
| β ≫ gap | Optimization unstable — steep penalty landscape |
The Ansatz
We use a 2-layer UCCSD-inspired ansatz with RY, RZ, and CX gates:
CODELayer 1: ┌──────────┐┌──────────┐ q_0: ┤ RY(θ₀) ├┤ RZ(θ₁) ├──■── ├──────────┤├──────────┤┌─┴─┐ q_1: ┤ RY(θ₂) ├┤ RZ(θ₃) ├┤ X ├ └──────────┘└──────────┘└───┘ Layer 2: ┌──────────┐┌──────────┐ q_0: ┤ RY(θ₄) ├┤ RZ(θ₅) ├──■── ├──────────┤├──────────┤┌─┴─┐ q_1: ┤ RY(θ₆) ├┤ RZ(θ₇) ├┤ X ├ └──────────┘└──────────┘└───┘
The RZ gates are not needed for this Hamiltonian: its matrix is real, so every eigenstate can be written with real amplitudes, and an RY plus CX ansatz reaches them (with the RZ gates removed, an exact-statevector VQD run finds both target energies; see exercise 3). Phase gates matter for Hamiltonians with complex matrix elements, for example with a magnetic field.
The Math
VQD Cost Function
For the k-th excited state:
L_k(θ) = ⟨ψ(θ)|H|ψ(θ)⟩ + Σᵢ₌₀ᵏ⁻¹ βᵢ |⟨ψ(θ)|ψᵢ⟩|²
The overlap |⟨ψ(θ)|ψᵢ⟩|² is computed using the statevector inner product in simulation:
overlap = |⟨ψ₁|ψ₂⟩|² = |Σⱼ α*ⱼ βⱼ|²
On real hardware, you would use a swap test — an ancilla-controlled circuit that maps the overlap to a measurement probability:
CODE┌───┐ ┌───┐ ancilla: |0⟩ ──┤ H ├──■────────┤ H ├── Measure └───┘ │ └───┘ ┌─┴──┐ |ψ₁⟩: ────────────┤SWAP├───────────── |ψ₂⟩: ────────────┤ ├───────────── └────┘ P(ancilla = 0) = (1 + |⟨ψ₁|ψ₂⟩|²) / 2
H2 Hamiltonian
This demo's 2-qubit model Hamiltonian (the standard H2 terms plus an extra Y₀Y₁ term) is:
H = -1.0523·I + 0.3979·Z₀ - 0.3979·Z₁ - 0.0112·Z₀Z₁ + 0.1809·X₀X₁ + 0.1809·Y₀Y₁
Exact eigenvalues of this model (electronic only):
- E₀ = -1.9153 Ha (bonding: superposition of |01⟩ and |10⟩)
- E₁ = E₂ = -1.0635 Ha (degenerate pair: |00⟩ and |11⟩ components)
- E₃ = -0.1669 Ha (antibonding: orthogonal superposition of |01⟩ and |10⟩)
Adding nuclear repulsion (V_nn = 0.7199 Ha):
- Ground state total: -1.1954 Ha
- First excited total: -0.3436 Ha
- Gap: 0.8518 Ha ≈ 23.2 eV
These are the model's values, not H2's. The ground state total lies 0.058 Ha below H2's exact STO-3G energy (-1.1373 Ha), which shows that the Y₀Y₁ term does not belong: in this two-qubit (parity-mapped, reduced) form, H2's Hamiltonian has only the first five terms, as in the H2 ground-state circuit. Without the Y₀Y₁ term the exact totals are -1.1373 Ha (ground state) and -0.5245 Ha (first excited state, a non-degenerate spin triplet), a gap of 0.6128 Ha (about 16.7 eV).
Expected Output
| Metric | Value |
|---|---|
| Ground state energy (exact, model Hamiltonian) | -1.1954 Ha (H2 in STO-3G: -1.1373 Ha) |
| First excited state energy (exact, model Hamiltonian) | -0.3436 Ha (H2: -0.5245 Ha) |
| Energy gap (exact, model Hamiltonian) | 0.8518 Ha (H2: 0.6128 Ha) |
| VQD ground state (optimized) | -1.22 to -1.13 Ha in 10 runs |
| VQD excited state (optimized) | -0.35 to -0.25 Ha in 10 runs |
| Final overlap |⟨ψ₀|ψ₁⟩|² | < 0.05 (near-orthogonal; at most 0.011 in 10 runs) |
Runs of optimize_vqd(max_iterations=100, shots=2048, seed=42) are not exactly repeatable: seed fixes only the starting angles, and the simulator's shots are not seeded. The reported ground energy is the lowest of many noisy 2048-shot estimates, so it can land below the exact value (4 of 10 runs did).
Running the Circuit
PYTHONfrom circuit import run_circuit, optimize_vqd, verify_vqd # Quick single evaluation result = run_circuit() print(f"Energy: {result['energy']:.4f} Ha") # Full VQD: ground + excited state opt = optimize_vqd(max_iterations=100, shots=2048, seed=42) print(f"Ground: {opt['ground_state']['energy']:.4f} Ha") print(f"Excited: {opt['excited_state']['energy']:.4f} Ha") print(f"Gap: {opt['gap']['computed']:.4f} Ha") print(f"Overlap: {opt['overlap']:.4f}") # Verification suite v = verify_vqd() for check in v["checks"]: status = "PASS" if check["passed"] else "FAIL" print(f"[{status}] {check['name']}: {check['detail']}")
Try It Yourself
-
Break β: Set
beta=0.5(below this model's 0.85 Ha gap) and runoptimize_vqd(). The excited state should collapse back to the ground state: the overlap penalty is too weak. -
Find the second excited state: After finding |ψ₀⟩ and |ψ₁⟩, run a third optimization with penalties against both. Use
excited_state_cost()withlower_state_thetas=[ground_theta, excited_theta]andbetas=[3.0, 3.0]. -
RY-only ansatz: Remove the RZ gates from the ansatz (set RZ angles to 0). Can it still find the excited state? Why or why not?
-
Swap test overlap: Replace the statevector overlap in
compute_overlap()with a swap test circuit. How many shots do you need for the overlap estimate to be accurate within ±0.05? -
Bond stretching: Change the Hamiltonian coefficients to R = 2.0 A (stretched bond). The gap shrinks — does β = 3.0 still work, or is it now too large?
What's Next
- LiH Excited States — Scale VQD to 4 qubits with lithium hydride
- Multistate VQE — Find multiple states simultaneously (no sequential penalty)
- SSVQE — Subspace-Search VQE: alternative to VQD using orthogonal initial states
- VQD Algorithm — Generalized VQD for arbitrary k-th excited state
Comparison with Other Excited State Methods
| Method | Approach | Pros | Cons |
|---|---|---|---|
| VQD | Sequential + penalty | Simple, proven | Needs good β; sequential overhead |
| SSVQE | Orthogonal initial states | All states in one optimization | Needs k orthogonal input states and k energy evaluations per step |
| MCVQE | Multi-configurational | Multi-reference capable | Complex optimization landscape |
| qEOM | Post-VQE linear response | Cheap for small excitations | Accuracy limited by the excitation operators included (usually singles and doubles) and by the ground state's quality |
Applications
| Domain | Use case |
|---|---|
| Photochemistry | Excited state reaction pathways, photodissociation |
| Spectroscopy | UV-Vis absorption spectra prediction |
| Materials science | Band gap calculations for semiconductors |
| Drug design | Fluorophore and chromophore optimization |
| Solar cells | Exciton dynamics in organic photovoltaics |
References
- Higgott, O., Wang, D., Brierley, S. (2019). "Variational Quantum Computation of Excited States." Quantum 3, 156. DOI: 10.22331/q-2019-07-01-156
- 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. (2016). "The theory of variational hybrid quantum-classical algorithms." New Journal of Physics 18, 023023. DOI: 10.1088/1367-2630/18/2/023023
- Nakanishi, K.M., Mitarai, K., Fujii, K. (2019). "Subspace-search variational quantum eigensolver for excited states." Physical Review Research 1, 033062. DOI: 10.1103/PhysRevResearch.1.033062