QAOA explained, layer by layer
How the cost phase and the mixer combine, what γ and β do, and what the p parameter controls.
8 min read · reviewed December 2026
The recipe
QAOA, the Quantum Approximate Optimization Algorithm, starts every qubit in the equal superposition of all bit strings. Then it repeats p layers. Each layer has two steps with one angle each.
|ψ⟩ = Π over layers [ Mixer(β) · Cost(γ) ] |+…+⟩
⟨C⟩ = Σₓ P(x)·C(x)
- Cost step with angle γ: give each bit string x a phase e^(−iγ·C(x)), where C(x) is the value being maximised. Better strings are rotated further.
- Mixer step with angle β: apply an RX(2β) rotation to every qubit, which turns phase differences into probability differences.
What the angles mean
With γ = 0 or β = 0 nothing useful happens: the state stays uniform and ⟨C⟩ equals half the number of edges, the value of random guessing. The lab’s test checks this for all seven graphs. Between those extremes, interference builds up probability on strings with large cut values.
What p controls
Each extra layer adds two parameters and gives the circuit more freedom. In this lab, for the 6-cycle the best expected-cut ratio found rises from 0.750 at p = 1 to 0.833 at p = 2 and 1.000 at p = 3. The table in the next guide has all seven graphs. More layers also mean a deeper circuit, which on real hardware means more noise.
Reading the landscape
For p = 1 the expected cut depends on just two numbers, so the lab draws it as a map over γ from 0 to 2π and β from 0 to π. Bright regions are good. The map repeats and has several equivalent peaks, which is why different optimiser starts can land on different but equally good parameters.
Try it
Questions
Is QAOA guaranteed to find the best cut?
No. It produces a probability distribution over cuts. With small p the best cut may have a low probability.
Why does the mixer use RX?
It is a simple rotation that mixes each bit between 0 and 1, so probability can flow between neighbouring strings.
Does a bigger p always help?
In the table of the next guide the best value found never decreased as p grew, which is expected in a noiseless simulation because a deeper circuit can imitate a shallower one. On hardware, noise can cancel the gain.
Read next
Sources and further reading
- E. Farhi, J. Goldstone and S. Gutmann, “A Quantum Approximate Optimization Algorithm” (2014)
- A. Peruzzo et al., “A variational eigenvalue solver on a photonic quantum processor” (2014)
- A. Kandala et al., “Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets” (2017)
- J. McClean et al., “Barren plateaus in quantum neural network training landscapes” (2018)
- J. Preskill, “Quantum computing in the NISQ era and beyond” (2018)
- K. Mitarai et al. (2018) and M. Schuld et al. (2019) on analytic gradients of quantum circuits
Check the original sources for exact citations.