UCCSD Ansatz
Known limitation (October 2026): This demo's "double excitation" block (CNOTs around one RZ) is diagonal, so it only adds a phase and never moves electrons, and its "single excitation" blocks (CNOT, RY, CNOT) do not conserve electron number: applying the singles 0→2 and 1→2 at θ = π/2 to the Hartree-Fock state |1100⟩ puts 25% probability on |0000⟩ (no electrons). So it is not yet a true UCCSD circuit. The Hartree-Fock preparation and the coupled-cluster and Jordan-Wigner background on this page still apply. A corrected version is planned.
What You'll Learn: How the gold-standard quantum chemistry ansatz encodes electron correlation into a parameterised quantum circuit, using coupled-cluster theory translated through the Jordan-Wigner transformation.
- Map fermionic excitation operators to qubit gates via Jordan-Wigner
- Build a simplified variational circuit with single- and double-excitation blocks, and see where it falls short of true UCCSD
- Understand why UCCSD is the default ansatz for VQE-based molecular simulation
Level: Advanced | Time: 60 minutes | Qubits: 4 | Framework: Cirq
Prerequisites
- Familiarity with single-qubit gates (RY, RZ) and CNOT
- Understanding of the Variational Quantum Eigensolver (VQE) loop
- Basic quantum chemistry concepts: orbitals, electrons, Hartree-Fock
- Comfort with second-quantised notation (creation/annihilation operators)
Recommended prior circuits: Hardware-Efficient Ansatz | VQE H2 Ground State
The Idea
Classical computational chemistry has a workhorse method called Coupled Cluster (CC). It works by "exciting" electrons from occupied orbitals into virtual (unoccupied) orbitals, building up correlations that the simple Hartree-Fock picture misses. The standard CCSD (singles and doubles) truncation captures the vast majority of correlation energy for most molecules.
The problem is that classical CC uses a non-unitary exponential operator, which is fine for a classical computer but impossible to implement directly on a quantum processor (all quantum operations must be unitary). The fix is simple in principle: replace the cluster operator T with the anti-Hermitian combination T - T†. Exponentiating an anti-Hermitian operator always gives a unitary. This is the Unitary Coupled Cluster (UCC) ansatz.
On a classical computer, UCC is exponentially expensive because the Baker- Campbell-Hausdorff expansion does not truncate. On a quantum computer, a Trotterized version of the unitary can be built from gates without evaluating that expansion, which is the potential advantage VQE aims for. (A 4-qubit case like this one is still trivial to simulate classically.)
UCCSD is often called the "gold standard" ansatz because it is physically motivated (it respects the structure of electronic excitations), systematically improvable (add triples for UCCSDT), and provides a good balance between accuracy and circuit depth for small molecules.
How It Works
The Circuit
The UCCSD circuit has three layers:
CODESection 1: Hartree-Fock preparation q_0: ──X── (occupied) q_1: ──X── (occupied) q_2: ───── (virtual) q_3: ───── (virtual) Section 2: Single excitations (one block per occupied→virtual pair) q_i: ──●──RY(θ)──●── │ │ q_a: ──X──────────X── Section 3: Double excitations (compact 4-qubit blocks) q_0: ──●─────────────────●── │ │ q_1: ──X──●───────────●──X── │ │ q_2: ─────X──RZ(θ/4)──X────── │ │ q_3: ─────●───────────●──────
Step 1: Hartree-Fock Reference
PYTHONfor i in range(n_electrons): circuit.append(cirq.X(qubits[i]))
X gates flip the first n_electrons qubits from |0> to |1>, encoding the
occupation pattern |1100> — two electrons in the lowest-energy orbitals. This
is the mean-field starting point that UCCSD will improve upon.
Step 2: Single Excitations
Each occupied-virtual pair (i, a) gets a block of two CNOTs bracketing an RY gate. The angle theta_ia controls how much amplitude is "moved" from orbital i to orbital a. In this simplified demo the block implements exp(-i theta/2 Y_i X_a), which is only half of a true Givens rotation (that also needs the X_i Y_a term, plus a Jordan-Wigner Z string for non-adjacent orbitals), so it does not conserve electron number: at large angles you will see bitstrings with 0 or 4 electrons (exercise 5 shows this). For 2 occupied and 2 virtual orbitals there are 2 x 2 = 4 single excitation parameters.
Step 3: Double Excitations
Double excitations promote two electrons simultaneously, capturing the pair correlation that single excitations miss. In this simplified demo, though, the compact block (a CNOT staircase around one RZ rotation, scaled by 1/4) only applies a phase: CNOTs plus RZ are diagonal, and the block equals exp(-i theta/8 Z_p Z_q Z_r), so it never moves electrons and adds no pair correlation on its own. A true double excitation, exp(theta (a†_a a†_b a_j a_i - h.c.)), needs X and Y rotations, for example the 8 Pauli exponentials from the Jordan-Wigner mapping.
The Math
The Cluster Operator
The UCC ansatz state is:
|psi(theta)> = exp(T - T†) |HF>
The cluster operator T is truncated at singles and doubles:
CODET_1 = sum_{i in occ, a in virt} theta_ia a†_a a_i T_2 = sum_{i<j in occ, a<b in virt} theta_ijab a†_a a†_b a_j a_i
where a† and a are fermionic creation and annihilation operators.
Jordan-Wigner Transformation
To implement fermionic operators on qubits, the Jordan-Wigner mapping encodes occupation numbers directly:
CODEa†_p = (1/2)(X_p - iY_p) Z_{p-1} Z_{p-2} ... Z_0 a_p = (1/2)(X_p + iY_p) Z_{p-1} Z_{p-2} ... Z_0
The Z-string ensures the correct fermionic anti-commutation relations. A single excitation a†_a a_i - h.c. becomes a sum of Pauli tensor products acting on qubits i through a.
Trotterization
The full unitary exp(T - T†) cannot be implemented as a single gate. Instead we use a first-order Trotter-Suzuki decomposition:
exp(T_1 + T_2 - T_1† - T_2†) ≈ prod_k exp(theta_k G_k)
where each G_k is a single- or double-excitation generator mapped to Pauli strings. Each Pauli exponential exp(i theta P_1 P_2 ... P_n) is compiled into a CNOT ladder + single-qubit rotation + reverse CNOT ladder.
Parameter Scaling
| System | Qubits | Singles | Doubles | Total Params |
|---|---|---|---|---|
| H2 (minimal basis) | 4 | 2 | 1 | 3 |
| LiH (STO-3G) | 12 | 16 | 76 | 92 |
| H2O (STO-3G) | 14 | 20 | 120 | 140 |
Counts are for spin-conserving excitations from the Hartree-Fock state (all electrons, no frozen core). This circuit's simplified counting pairs every occupied spin-orbital with every virtual one regardless of spin, which gives 4 + 1 = 5 parameters for H2, 32 + 168 = 200 for LiH and 40 + 270 = 310 for H2O.
The parameter count grows as O(n_occ * n_virt) for singles and O(n_occ^2 * n_virt^2) for doubles.
Expected Output
With 4 qubits, 2 electrons, and random initial parameters (seed=42):
| Property | Value |
|---|---|
| Single excitations | 4 |
| Double excitations | 1 |
| Total parameters | 5 |
| Circuit depth | 15 moments |
Measurement outcomes will be distributed across computational basis states. With zero parameters (theta=0) the circuit produces only the Hartree-Fock state |1100> with 100% probability, confirming that the ansatz correctly reduces to the reference when no excitations are applied.
Note: Unlike the hardware-efficient ansatz, true UCCSD outcomes have physical meaning — the bitstrings represent electronic configurations in the orbital basis. In this demo the single-excitation blocks do not conserve electron number, so some outcomes (0 or 4 electrons) are not valid 2-electron configurations; at the demo's small random angles their total probability is only about 0.06%.
Running the Circuit
PYTHONfrom circuit import create_uccsd_ansatz, run_circuit, verify_uccsd # Basic execution with random parameters result = run_circuit(n_qubits=4, n_electrons=2, shots=1024) print(f"Parameters: {result['n_params']}") print(f"Depth: {result['depth']}") print(f"Top outcomes: {result['top_outcomes']}") # Build a custom ansatz with specific amplitudes params = [0.0] * 5 # All zeros = Hartree-Fock state circuit = create_uccsd_ansatz(n_qubits=4, n_electrons=2, params=params) print(circuit) # Verification suite verification = verify_uccsd() print(f"All checks passed: {verification['passed']}") for check in verification['checks']: print(f" {check['name']}: {check['detail']}")
Try It Yourself
-
Zero-parameter limit: Set all parameters to 0.0 and verify that you recover the Hartree-Fock state |1100> with 100% probability. This confirms the ansatz correctly encodes the reference.
-
Single excitation only: Set all double-excitation parameters to zero and vary one single-excitation amplitude from 0 to pi. Watch how population transfers from an occupied to a virtual orbital.
-
Compare with HEA: Build a hardware-efficient ansatz of the same depth and compare the measurement distributions. Which produces more physically meaningful states?
-
Scale to 6 qubits: Try
create_uccsd_ansatz(n_qubits=6, n_electrons=2). How does the parameter count change? How does the circuit depth grow? -
Symmetry check: For H2, the UCCSD state should preserve total spin (S^2) and particle number. Measure the expectation values of the number operator N = sum of (1 - Z_i)/2 across multiple parameter settings. In this demo N is not conserved, because of the simplified single-excitation blocks (see the note at the top): at large angles ⟨N⟩ moves away from 2.
What's Next
- VQE H2 Ground State — Use this UCCSD ansatz inside a full VQE loop to find the ground-state energy of H2
- Hardware-Efficient Ansatz — Compare UCCSD with a physics-agnostic ansatz and understand the tradeoffs
- Barren Plateaus — Investigate whether UCCSD suffers from vanishing gradients as the system size grows
- VQD Algorithm — Extend beyond the ground state to find excited-state energies using UCCSD
Applications
| Application | How UCCSD Is Used |
|---|---|
| Molecular ground states | VQE + UCCSD finds the lowest energy of small molecules (H2, LiH, H2O) on near-term hardware |
| Bond dissociation curves | Vary internuclear distance and compute energy at each point to map reaction pathways |
| Excited states | Combined with VQD or SSVQE to access excited electronic states beyond the ground state |
| Benchmarking quantum hardware | UCCSD circuits of known accuracy serve as benchmarks for assessing hardware fidelity |
| Drug discovery | Accurate molecular energies feed into computational pipelines for molecular property prediction |
References
- Peruzzo, A. et al. (2014). "A variational eigenvalue solver on a photonic quantum processor." Nature Communications 5, 4213. DOI: 10.1038/ncomms5213
- Romero, J. et al. (2019). "Strategies for quantum computing molecular energies using the unitary coupled cluster ansatz." Quantum Science and Technology 4(1), 014008. DOI: 10.1088/2058-9565/aad3e4
- Whitfield, J.D., Biamonte, J., Aspuru-Guzik, A. (2011). "Simulation of electronic structure Hamiltonians using quantum computers." Molecular Physics 109(5), 735-750. DOI: 10.1080/00268976.2011.552441
- Anand, A. et al. (2022). "A quantum computing view on unitary coupled cluster theory." Chemical Society Reviews 51, 1659-1684. DOI: 10.1039/D1CS00932J
- Nielsen, M.A. & Chuang, I.L. Quantum Computation and Quantum Information, Chapter 9 (Quantum simulation).
- Helgaker, T., Jorgensen, P., Olsen, J. Molecular Electronic-Structure Theory, Chapter 11 (Coupled-cluster theory).