VQE and QAOA Playground
Train a quantum circuit yourself. Tune the angles of QAOA on small MaxCut graphs, watch the cost landscape, then run VQE on spin chains and compare with the exact answer.
Reviewed December 2026. New to this? Choose the hexagon, press Optimise at p = 1, then p = 3.
Expected cut ⟨C⟩
2.9991
Best possible cut
4 of 4 edges
Approximation ratio
0.7498
Chance of an optimal cut
53.5%
Random guessing gives
2.00 (ratio 0.5000)
Parameters
2
Most likely cut: 1010 cuts 4 edges
Layer 1 landscape (p = 1 values)
Eight most likely outcomes (qubit 0 on the left). Highlighted: optimal cuts.
A five-minute path
- QAOA tab: choose the hexagon and drag γ and β. Watch the circle on the landscape move.
- Press Optimise and note the approximation ratio. Raise p to 2 and 3 and press it again.
- Choose the triangle and see why no layer count can cut all three edges.
- VQE tab: set 2 qubits and 0 layers, then add layers and compare with the dashed exact line.
- Press “New random start” a few times on the 4-qubit Heisenberg chain and see different endpoints.
- Layers vs accuracy tab: run the comparison and read the table.
What the playground does and does not do
- It simulates exactly, up to 6 qubits for QAOA and 4 for VQE.
- It has no hardware noise. The sampling box shows shot noise for QAOA only.
- The VQE models are an Ising and a Heisenberg chain, not molecules.
- It does not claim that either algorithm beats classical methods.
Reference tables
Produced by the same functions as the lab.
| Graph | Edges | Max cut | p = 1 | p = 2 | p = 3 |
|---|---|---|---|---|---|
| Triangle (3 nodes) | 3 | 2 | 2.000 (1.000) | 2.000 (1.000) | 2.000 (1.000) |
| Square (4-cycle) | 4 | 4 | 3.000 (0.750) | 4.000 (1.000) | 4.000 (1.000) |
| Complete graph K4 | 6 | 4 | 3.698 (0.924) | 4.000 (1.000) | 4.000 (1.000) |
| Pentagon (5-cycle) | 5 | 4 | 3.750 (0.937) | 4.000 (1.000) | 4.000 (1.000) |
| House (5 nodes, 6 edges) | 6 | 5 | 4.110 (0.822) | 4.496 (0.899) | 4.709 (0.942) |
| Hexagon (6-cycle) | 6 | 6 | 4.500 (0.750) | 5.000 (0.833) | 6.000 (1.000) |
| Triangular prism (6 nodes) | 9 | 7 | 5.939 (0.848) | 6.603 (0.943) | 6.875 (0.982) |
| Qubits | 0 layers | 1 layer | 2 layers | 3 layers | 4 layers |
|---|---|---|---|---|---|
| 2 | 2 | 4 | 6 | 8 | 10 |
| 3 | 3 | 6 | 9 | 12 | 15 |
| 4 | 4 | 8 | 12 | 16 | 20 |
| Qubits | Amplitudes | Memory |
|---|---|---|
| 10 | 2^10 | 16 KiB |
| 20 | 2^20 | 16 MiB |
| 30 | 2^30 | 16 GiB |
| 40 | 2^40 | 16 TiB |
| 50 | 2^50 | 16 PiB |
Eight guides
What are variational quantum algorithms?
7 min read
The hybrid loop that tunes a short quantum circuit with a classical optimiser, and why it was designed for noisy machines.
QAOA explained, layer by layer
8 min read
How the cost phase and the mixer combine, what γ and β do, and what the p parameter controls.
MaxCut with QAOA: graphs and approximation ratios
8 min read
What MaxCut asks, how the approximation ratio is defined, and the exact numbers for seven small graphs.
VQE explained: the variational principle
8 min read
Why any state’s energy is an upper bound on the ground energy, and how VQE exploits that.
Choosing an ansatz: expressibility versus trainability
8 min read
The hardware-efficient ansatz used in the lab, how its parameters grow, and why more is not always better.
Gradients and the parameter-shift rule
7 min read
How a quantum circuit’s exact gradient is obtained from two extra runs, and what that costs.
Optimisers, local minima and shot noise
8 min read
Why the same algorithm can give different answers, and what real measurement noise adds.
Do variational algorithms beat classical computers?
8 min read
An honest look at what is known, using the lab’s own memory numbers as a baseline.
Predict, then check
Pick any graph and set γ = 0. What is the expected cut?
Half the number of edges, because the state is still the uniform superposition. For the triangle that is 1.5.
What is the largest cut of the square (4-cycle)?
4 edges: colour the nodes alternately.
What is the largest cut of the triangle?
2 of 3 edges, because an odd cycle cannot be coloured with two colours without a clash.
For the hexagon, what is the best approximation ratio found with p = 1, 2 and 3?
0.750, 0.833, 1.000.
How many parameters does a 4-qubit VQE circuit with 3 layers have?
16. The exact ground energy of the 4-qubit Heisenberg chain is -6.4641.
Related on QuantumAtlas
Frequently asked questions
What does this playground do?
It runs two variational algorithms on small problems: QAOA for the MaxCut problem on seven graphs, and VQE for the ground-state energy of two spin chains. All results are exact statevector simulations.
Is this running on a real quantum computer?
No. It simulates up to six qubits in your browser, with no hardware noise.
What is MaxCut?
Colour the nodes of a graph with two colours so that as many edges as possible join nodes of different colours.
What does the approximation ratio mean?
The expected cut found by QAOA divided by the true maximum cut, which the lab finds by checking every colouring.
Why does the energy never go below the exact value?
Because of the variational principle: no state has lower average energy than the ground state.
Why do different random starts give different answers?
The cost landscape has several valleys and the optimiser stops in the one it starts near.
Why is there no molecule in the lab?
A molecular Hamiltonian needs coefficients from a chemistry package for a specific geometry and basis. This lab does not type such numbers from memory.
Does this show a quantum advantage?
No. Every problem here is trivial for a classical computer, and the lab makes no advantage claim.
What is the parameter-shift rule?
A way to get the exact gradient of a circuit’s cost from two extra runs per parameter. See the gradients guide.
How should I cite results from this page?
Cite the original papers listed under the sources, not the lab output.
Sources and further reading
- E. Farhi, J. Goldstone and S. Gutmann, “A Quantum Approximate Optimization Algorithm” (2014). The paper that introduced QAOA.
- A. Peruzzo et al., “A variational eigenvalue solver on a photonic quantum processor” (2014). The first experimental VQE.
- A. Kandala et al., “Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets” (2017). Introduced the hardware-efficient ansatz style used in this lab.
- J. McClean et al., “Barren plateaus in quantum neural network training landscapes” (2018). Shows why training can fail for deep random circuits.
- J. Preskill, “Quantum computing in the NISQ era and beyond” (2018). Context for why short, hybrid circuits matter.
- K. Mitarai et al. (2018) and M. Schuld et al. (2019) on analytic gradients of quantum circuits. Sources usually cited for the parameter-shift rule.
References were written from memory of the original works. Check the originals for exact citations.