Variational Quantum Deflation (VQD) — General Implementation
What You'll Learn:
- How VQD scales to larger systems (4 qubits, arbitrary Hamiltonian)
- How the deflation process systematically removes found states from the search space
- Why β must increase as more states are found (cumulative penalty landscape)
- How to implement measurement-based energy computation for a spin-chain Hamiltonian
Level: Advanced | Time: 30 minutes | Qubits: 4 | Framework: Qiskit
Prerequisites
- H2 Excited States — VQD on 2 qubits (molecular Hamiltonian)
- H2 Ground State — VQE fundamentals
The Idea
The H2 VQD tutorial shows the core algorithm on 2 qubits with a molecular Hamiltonian. This circuit generalizes VQD to arbitrary Hamiltonians and demonstrates it on the 4-qubit Transverse Field Ising Model (TFIM) — a fundamental model in condensed matter physics.
VQD works by "deflating" the Hilbert space: after finding each eigenstate, it adds a penalty that makes that region of the space expensive to visit. The optimizer is forced to explore new regions, discovering higher-energy states.
CODEState 0 (VQE): L₀ = ⟨H⟩ State 1 (VQD): L₁ = ⟨H⟩ + β₀|⟨ψ₁|ψ₀⟩|² State 2 (VQD): L₂ = ⟨H⟩ + β₀|⟨ψ₂|ψ₀⟩|² + β₁|⟨ψ₂|ψ₁⟩|²
Each additional state adds one more penalty term. The penalty "walls" accumulate, creating an increasingly constrained landscape.
How It Works
The Transverse Field Ising Model
H = -Σᵢ ZᵢZᵢ₊₁ - h Σᵢ Xᵢ (h = 0.5)
| Term | Physical meaning |
|---|---|
| -ZᵢZᵢ₊₁ | Nearest-neighbor spin alignment (ferromagnetic coupling) |
| -hXᵢ | Transverse field (quantum fluctuations, spin flipping) |
At h = 0.5 (below critical point h = 1.0), the system is in the ordered phase: spins prefer to align, and the ground state is near |0000⟩ or |1111⟩. The spectrum has clear gaps.
Measurement Strategy
The TFIM has two types of Pauli terms:
-
ZZ terms (3 for 4 qubits): Measured in the computational basis. One circuit gives all ZZ expectations simultaneously.
-
X terms (4 for 4 qubits): Each requires a Hadamard rotation before measurement. We can measure all X terms from individual single-qubit rotations on the same circuit.
Total: 5 measurement circuits per energy evaluation.
Hardware-Efficient Ansatz
CODE┌────────┐ ┌────────┐┌────────┐ ┌────────┐┌────────┐ q_0: ┤ RY(θ₀) ├──■───────┤ RY(θ₄) ├┤ RZ(θ₅) ├──■───────┤ RY(θ₁₂)├┤ RZ(θ₁₃)├ ├────────┤┌─┴─┐ ├────────┤├────────┤┌─┴─┐ ├────────┤├────────┤ q_1: ┤ RY(θ₁) ├┤ X ├──■──┤ RY(θ₆) ├┤ RZ(θ₇) ├┤ X ├──■──┤ RY(θ₁₄)├┤ RZ(θ₁₅)├ ├────────┤└───┘┌─┴─┐├────────┤├────────┤└───┘┌─┴─┐├────────┤├────────┤ q_2: ┤ RY(θ₂) ├─────┤ X ├┤ RY(θ₈) ├┤ RZ(θ₉) ├─────┤ X ├┤ RY(θ₁₆)├┤ RZ(θ₁₇)├ ├────────┤ └───┘├────────┤├────────┤ └───┘├────────┤├────────┤ q_3: ┤ RY(θ₃) ├──────────┤ RY(θ₁₀)├┤ RZ(θ₁₁)├──────────┤ RY(θ₁₈)├┤ RZ(θ₁₉)├ └────────┘ └────────┘└────────┘ └────────┘└────────┘
20 parameters per state × 3 states = 60 total (but optimized sequentially, 20 at a time).
β Selection for Multiple States
Each penalty β must exceed the corresponding energy gap. For the TFIM at h = 0.5:
| Gap | Approximate value | Recommended β |
|---|---|---|
| E₁ - E₀ | ~1.0 | β ≥ 2.0 |
| E₂ - E₁ | ~0.5-1.0 | β ≥ 2.0 |
Using a uniform β = 3.0 provides safety margin for all gaps.
The Math
Deflation Guarantee
VQD converges to the k-th eigenstate if:
- βᵢ > Eᵢ₊₁ - Eᵢ for all i < k (penalties exceed gaps)
- The ansatz can represent the k-th eigenstate
- The optimizer finds the global minimum
When all conditions hold, the cost function landscape has its global minimum exactly at the k-th eigenstate:
CODEL_k(ψ_k) = E_k + Σᵢ βᵢ × 0 = E_k L_k(ψ_j, j<k) = E_j + βⱼ × 1 > E_j + (E_{j+1} - E_j) = E_{j+1} ≥ E_k
So the ground states of lower cost functions are more expensive than the target state.
Error Propagation
VQD's main weakness: errors compound. If state k has error εₖ, then state k+1 sees a distorted penalty landscape. The overlap |⟨ψ_{k+1}|ψ̃_k⟩|² (where ψ̃_k is the approximate state k) differs from |⟨ψ_{k+1}|ψ_k⟩|² by O(εₖ). This shifts the optimal state k+1 by O(εₖ/gap).
Expected Output
For TFIM (4 qubits, h = 0.5):
| State | VQD | Exact | Error |
|---|---|---|---|
| E₀ | ~-4.5 | -4.50 | < 0.2 |
| E₁ | ~-3.5 | -3.50 | < 0.3 |
| E₂ | ~-2.5 | varies | < 0.4 |
Error increases with state index (VQD error propagation).
Running the Circuit
PYTHONfrom circuit import run_circuit, verify_vqd, compute_exact_eigenvalues # Exact reference exact = compute_exact_eigenvalues(n_states=3) print(f"Exact: {[f'{e:.4f}' for e in exact]}") # VQD: find 3 eigenstates sequentially result = run_circuit(n_states=3, beta=3.0, max_iterations=50, seed=42) for state in result['states']: print(f"State {state['index']}: E = {state['energy']:.4f}") # Verification 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.3(below the first gap ~1.0). The second state should collapse back to the ground state. -
Find 5 states: Run
run_circuit(n_states=5). Do the higher states maintain correct ordering? Does the error grow linearly or faster? -
Critical point: Set
TRANSVERSE_FIELD=1.0(quantum phase transition). The gap closes — VQD should struggle. How large does β need to be? -
Compare with SSVQE: Run SSVQE for the same system. Which method gets better excited states? (Hint: SSVQE finds them simultaneously, so no error propagation.)
-
Increase shots: Run with 256, 1024, 4096, 16384 shots. Does the energy variance decrease as 1/√shots?
What's Next
- SSVQE — Simultaneous optimization (no error propagation)
- Multistate VQE — Contracted Hamiltonian (few parameters)
- H2 Excited States — 2-qubit molecular VQD
Applications
| Domain | Use case |
|---|---|
| Condensed matter | Spin chain excitation spectra |
| Quantum chemistry | Full molecular energy manifold |
| Quantum dynamics | Propagator construction from eigenstates |
| Spectroscopy | Transition energy predictions |
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
- 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