Interactive Calculator · Algorithms and Advantage
QAOA Depth and Quality Calculator
Pick a small graph and a number of QAOA layers, then see how good the answers get, how many shots you need, and how hardware noise eats the benefit.
Max-Cut instances small enough to simulate exactly.
Each layer adds one cost round and one mixer round.
Applied to each CNOT after compiling every cost gate into two CNOTs.
Average cut
11.65 of 12
Ratio 0.971; random guess averages 7.5
Chance a shot is optimal
76.3%
A random guess succeeds 0.98% of the time
Shots for 99% confidence
4
Random guessing needs about 470
Two-qubit gates
90
15 edges × 2 CNOTs × 3 layers, before routing
With noise (rough, any CNOT fault ruins the shot)
No-fault chance
63.7%
Noisy optimal chance
48.6%
7 shots for 99%
Time for the noisy shot budget: about 0.0070 seconds at your run rate.
Quality by depth for this graph
What this is and is not
Values come from exact simulations I ran of QAOA on these graphs, with angles tuned by an optimiser. These graphs are tiny: brute force checks them instantly. The tool shows how depth trades quality against noise. It does not show a quantum advantage.Explore the trade-off at the heart of the Quantum Approximate Optimization Algorithm: more layers give better Max-Cut answers, and also mean more two-qubit gates and more noise. The values come from exact simulations of six small graphs.
What this calculator does
QAOA is a hybrid algorithm for problems such as Max-Cut, where you split the vertices of a graph into two groups to cut as many edges as possible. A circuit with p layers has 2p tunable angles. A classical optimiser tunes the angles, and the quantum device samples bit strings. The central question for anyone planning an experiment is: how large should p be?
This calculator lets you choose one of six small graphs (rings of 4, 6, 8 and 10 vertices, the cube graph and the Petersen graph) and a depth of one, two or three layers. It shows the average cut value the circuit reaches, the ratio to the best possible cut, the chance that a single shot lands on an optimal cut, and the number of shots needed to see an optimal cut with 99 percent confidence. It then converts the circuit into two-qubit gates and applies a gate error rate you choose to estimate how noise reduces the benefit.
The graph values are not formulas. I ran an exact statevector simulation of QAOA on each graph and optimised the angles with the Nelder-Mead method from six random starting points, keeping the best result. Because the optimiser can get stuck, a few values might be improved with more starts. The tool stores the results of those simulations, and everything that depends on your slider choices is computed on the page.
How to use it
Start with the Petersen graph at p = 3. The average cut is 11.65 out of a best possible 12, a ratio of 0.971, and 76.3 percent of shots are optimal cuts. A random guess finds an optimal cut only 0.98 percent of the time, so the circuit concentrates probability on good answers.
Then move the gate-error slider. With 0.5 percent error per CNOT, the 90 two-qubit gates of this circuit run without a fault only 63.7 percent of the time, and the noisy chance of an optimal shot falls to about 48.6 percent. Lower p and the circuit gets shorter, but the ideal quality falls too. Try the preset for 0.1 percent error to see how much better hardware helps. The sweet spot depends on the error rate, and finding it is the practical skill the tool is meant to teach.
Use the bar chart to compare depths for the same graph. On rings of 8 and 10 vertices, the ratio climbs from 0.75 to 0.833 to 0.875 as p goes from 1 to 3, a pattern that fits the formula (2p + 1) ÷ (2p + 2). I did not open a source to confirm that this formula is a known result, so treat it as a pattern in my numbers.
What the noise estimate assumes
The noisy numbers use a deliberately simple model. Every cost-layer gate between two vertices is compiled into two CNOT gates, so a graph with E edges and p layers has 2Ep CNOTs. The calculator assumes that if any CNOT fails, the shot is useless, so the chance of a clean run is (1 − error) raised to the number of CNOTs. The noisy chance of an optimal shot is then the ideal chance multiplied by the no-fault chance.
This is crude. Some errors do not change the answer, a few errors may even cancel, and real devices need extra swap gates when qubits are not directly connected, which would add more CNOTs than the tool counts. Readout errors are ignored. The estimate is a planning aid, and not a prediction for a particular machine.
Why these graphs are not a test of advantage
A computer checks all 1,024 assignments of the Petersen graph in a fraction of a millisecond, so brute force wins easily. Even random sampling finds an optimal cut with 99 percent confidence in about 470 draws, because 10 of the 1,024 assignments are optimal. QAOA needs about four shots at p = 3 in the ideal case, but each shot is a full circuit run on a quantum device. The tool therefore illustrates how the algorithm behaves, and it makes no claim of a speed-up. Whether QAOA helps on graphs with hundreds of vertices, where classical heuristics are strong, is an open question.
The formulas behind it
Cut ratio
ratio = average cut ÷ best cut
How close the average sampled answer is to the optimum. A uniformly random assignment averages half the edges.
Shots for confidence
n = ⌈ ln(0.01) ÷ ln(1 − P) ⌉
Shots needed to see at least one optimal string with 99 percent probability, if each shot is optimal with probability P.
Two-qubit gate count
CNOTs = 2 · E · p
Each of the E edges contributes one ZZ rotation per layer, compiled into two CNOT gates.
No-fault probability
F = (1 − ε)^(2Ep)
Chance that every CNOT succeeds, with error ε per gate. Ignores routing and readout errors.
Noisy success
P_noisy ≈ P · F
A rough estimate that treats any fault as ruining the shot.
Worked examples
Petersen graph, three layers
- From the stored simulation: average cut 11.6489 of 12, chance of an optimal shot 0.7626.
- Shots for 99% confidence: ln(0.01) ÷ ln(1 − 0.7626) = 3.2, so 4 shots.
- CNOTs: 2 × 15 × 3 = 90. With 0.5% error, F = 0.995⁹⁰ = 0.637.
- Noisy chance of an optimal shot: 0.7626 × 0.637 = 0.486, so about 7 shots for 99% confidence.
ResultNoise roughly halves the benefit of the third layer, but the circuit still beats random guessing by a wide margin.
A ring of 10 vertices, one layer
- Average cut 7.5 of 10, ratio 0.75. Chance of an optimal shot 0.0775.
- Only 2 of 1,024 assignments are optimal, so a random guess succeeds 0.195% of the time.
- CNOTs: 2 × 10 × 1 = 20. With 0.5% error, F = 0.905.
ResultOne layer already makes optimal cuts about 40 times more likely than guessing, with a short circuit.
Better hardware
- Petersen graph, p = 3, CNOT error 0.1%.
- F = 0.999⁹⁰ = 0.914. Noisy chance of an optimal shot = 0.7626 × 0.914 = 0.697.
ResultLower gate error recovers most of the ideal quality and lets a deeper circuit pay off.
Frequently asked questions
Is QAOA faster than classical methods?
Not on the tiny graphs here, where brute force is instant. Whether it offers an advantage on large, hard instances is an open research question.
Why does a bigger p not always help?
Each layer adds gates, and the gates add noise. On a perfect machine deeper is better, but on a real one the benefit can reverse beyond a certain depth.
Can I enter my own graph?
Not here. Exact simulation of arbitrary graphs would need an optimiser running in your browser, so the tool offers six graphs I simulated in advance.
Where do the numbers come from?
My own NumPy simulation with angles tuned by Nelder-Mead from six random starts. They are not measurements from hardware.
References
- Farhi, E., Goldstone, J., & Gutmann, S. (2014). A Quantum Approximate Optimization Algorithm. arXiv:1411.4028. (Cited from memory; I did not open it for this page.)
- Simulation data: my own exact statevector calculations for the six graphs, angles optimised with the Nelder-Mead method from six random starts.
Keep exploring
- Lesson: QAOA: Quantum Approximate Optimization
- Algorithm: QAOA
- Paper: A Quantum Approximate Optimization Algorithm
- Term: QAOA
- Calculator: Circuit Success Probability
- Calculator: Shot Count
These calculators use simplified, published models for education and planning. Real devices and systems differ, so treat results as estimates. They are not engineering, investment, legal, or security advice.