TopicIntermediateEstablished concept

Variational Quantum Circuits

Variational Quantum Circuits

A variational quantum algorithm optimises the parameters of a quantum circuit $U(\theta)$ in a classical loop to minimise a cost function estimated from measurements, such as the energy of a Hamiltonian.

Variational quantum algorithms (VQA) are the most widely used framework in the NISQ eraNISQ Era: NISQ (Noisy Intermediate-Scale Quantum) is a term coined by Preskill (2018) for current devices: tens to hundreds of noisy qubits without full error correction.. Their components are: a parameterised circuit, or ansatz, $U(\theta)$ that prepares the state $|\psi(\theta)\rangle=U(\theta)|0\rangle$; a cost function $C(\theta)$ computed from expectation values, the simplest being $$C(\theta)=\langle\psi(\theta)|H|\psi(\theta)\rangle;$$ and a classical optimiser that proposes new parameters based on the cost values or their gradients. The loop repeats until convergence. The circuit is relatively short, and a large share of the work moves to the classical computer, which is what makes the framework suited to noisy devices.

The first notable application is the variational quantum eigensolverVariational Quantum Eigensolver: VQE is a hybrid quantum–classical algorithm that approximates the lowest energy of a Hamiltonian by minimising ⟨ψ(θ)Hψ(θ)⟩ over a parameterised circuit; it is heuristic,… (VQE), which Peruzzo and colleagues (2014) ran on a photonic processor to estimate the ground-state energy of a molecule. VQE rests on the variational principle: for every normalised state, $\langle\psi|H|\psi\rangle\ge E_0$, where $E_0$ is the smallest eigenvalue; so minimising the cost gives an upper bound on the ground-state energy, whose accuracy is limited by the circuit's ability to represent the ground state.

To estimate $\langle H\rangle$ on a device, the Hamiltonian is written as a weighted sum of Pauli strings $H=\sum_kc_kP_k$, and each compatible group of strings is measured in its appropriate basis. The statistical error of the estimate is of order $1/\sqrt{N}$ for $N$ shots, so high accuracy requires many shots.

The same framework includes QAOA for combinatorial optimisation problems, and variational classifiers in quantum machine learning, where the cost is a loss function on training data. Cerezo and colleagues (2021) summarised the field, including its challenges: choosing the circuit, barren plateausBarren Plateaus: Barren plateaus are a phenomenon in which the variance of the cost-function gradient vanishes exponentially with the number of qubits in deep random parameterised circui…, noise, measurement cost, and the lack of general guarantees of an advantage over classical methods.

In the lab, the VQE experiment builds a small transverse-field Ising modelIsing Model: The Ising model describes binary spins z_i=±1 with energy E(z)=Σ J_ijz_iz_j+Σ h_iz_i; its quantum version is a Hamiltonian diagonal in Z, and X terms are added in the tr… and optimises a circuit of rotation and entangling layers, and the resulting energy can be compared with the exact value computed by diagonalisation, a comparison available only because the system is very small.

It is important to note that the quality of a VQE result is set by three separate factors: the ansatz's ability to represent the ground state, the optimiser's success in reaching the best parameters within that ansatz, and the accuracy of estimating the expectation values from shots. Failure in any of them gives an energy above $E_0$, and the energy alone cannot tell which factor is the cause.

q0q1q2RY(x0)RY(θ)RZ(θ)RY(x1)RY(θ)RZ(θ)RY(x2)RY(θ)RZ(θ)⟨Z⟩
Variational circuit: RY(x) encoding, then trainable RY·RZ layers with CNOT, then measuring ⟨Z⟩

Mathematical formulation

$$\theta^{*}=\arg\min_\theta\ \langle\psi(\theta)|H|\psi(\theta)\rangle\ \ge E_0$$

Worked example

One qubit, $|\psi(\theta)\rangle=R_Y(\theta)|0\rangle$ and $H=Z$.

$R_Y(\theta)|0\rangle=\cos\tfrac{\theta}{2}|0\rangle+\sin\tfrac{\theta}{2}|1\rangle$, so $C(\theta)=\cos^2\tfrac{\theta}{2}-\sin^2\tfrac{\theta}{2}=\cos\theta$.

The smallest value is $-1$ at $\theta=\pi$, which is indeed the smallest eigenvalue of $Z$ (the state $|1\rangle$). The variational principle holds: $\cos\theta\ge-1$ for every $\theta$.

The gradient by the parameter-shift rule: $\tfrac12[\cos(\theta+\tfrac{\pi}{2})-\cos(\theta-\tfrac{\pi}{2})]=-\sin\theta$, which is the analytic derivative itself.

Try it yourself: Variational Quantum Circuit

Loading the simulator…

The full experiment page

Test your understanding

The quiz needs JavaScript.

Related topics

References

  1. M. Cerezo et al. (2021). Variational quantum algorithms. Nature Reviews Physics 3:625–644 doi:10.1038/s42254-021-00348-9
  2. Alberto Peruzzo et al. (2014). A variational eigenvalue solver on a photonic quantum processor. Nature Communications 5:4213 doi:10.1038/ncomms5213
  3. IBM Quantum (2025). Variational Algorithm Design (course). IBM Quantum Learning quantum.cloud.ibm.com