|q⟩ Bad Qubits

advanced · Programming · Advanced VQE & Ansatz Design

Symmetry-Preserving Ansätze

A fixed or hardware-efficient ansatz wanders freely over the whole Hilbert space. But the physical states we care about almost always live in a much smaller subspace defined by a symmetry — a conserved quantity such as the number of electrons or the total spin. A symmetry-preserving ansatz restricts its trial states to that subspace from the start. This buys two things at once: a smaller, more trainable search space (helping against barren plateaus) and trial states that are physically valid by construction.

Symmetries as conserved quantum numbers

A symmetry is generated by an operator SS that commutes with the Hamiltonian, [H,S]=0[H, S] = 0. The eigenvalue of SS — the quantum number — is conserved by the true dynamics, so the ground state lives in a single eigensector. For electronic structure the most important example is particle number: under the Jordan–Wigner mapping the number operator counts the number of qubits in state 1|1\rangle (the Hamming weight). A molecule with NN electrons has its ground state in the weight-NN subspace.

If your ansatz can produce states of the wrong weight, the optimizer wastes its expressibility exploring unphysical regions — and may even converge to a lower-energy state that simply has the wrong number of electrons.

Particle-number-preserving gates

The fix is to build the circuit entirely from gates that commute with the number operator, i.e. that never change the Hamming weight. Single-qubit XX or RYR_Y gates do not qualify — they flip 01|0\rangle\leftrightarrow|1\rangle and change the count. The fundamental weight-preserving two-qubit gate is the Givens rotation (also called the AA gate or RBS gate), which mixes only the two single-excitation basis states:

G(θ):01cosθ201sinθ210,10sinθ201+cosθ210,G(\theta):\quad \begin{aligned} |01\rangle &\mapsto \cos\tfrac{\theta}{2}\,|01\rangle - \sin\tfrac{\theta}{2}\,|10\rangle,\\ |10\rangle &\mapsto \sin\tfrac{\theta}{2}\,|01\rangle + \cos\tfrac{\theta}{2}\,|10\rangle, \end{aligned}

while acting as the identity on 00|00\rangle and 11|11\rangle. Crucially, every basis state it touches has Hamming weight 1, so weight is conserved exactly. This single rotation is the chemistry analogue of a single orbital excitation.

Decomposing the Givens rotation

Native hardware rarely has a Givens gate directly, so we synthesize it. A controlled-RYR_Y between two CNOTs realizes G(θ)G(\theta), and the controlled-RYR_Y itself decomposes into native single- and two-qubit gates:

CRY(θ)=[RY(θ/2)]CX[RY(θ/2)]CX,\mathrm{CRY}(\theta) = \bigl[R_Y(\theta/2)\bigr]\,\mathrm{CX}\,\bigl[R_Y(-\theta/2)\bigr]\,\mathrm{CX},

so the whole Givens block needs only RYR_Y and CNOT gates — exactly what every superconducting or trapped-ion device provides.

Try it

Start from the single-excitation state 01|01\rangle and apply a Givens rotation with θ=π/3\theta = \pi/3. The grader checks the full state vector. A correct circuit produces

cosπ601sinπ6100.866010.510,\cos\tfrac{\pi}{6}\,|01\rangle - \sin\tfrac{\pi}{6}\,|10\rangle \approx 0.866\,|01\rangle - 0.5\,|10\rangle,

with zero amplitude on 00|00\rangle and 11|11\rangle — the unmistakable signature that particle number has been preserved.

Run your code to see the quantum state.

After running, confirm in the Amplitudes view that the 00|00\rangle and 11|11\rangle bars are exactly zero. The trial state never left the one-electron subspace.

Sign in on the full site to ask questions and join the discussion.