QAOA MaxCut - Farhi, Goldstone, Gutmann (2014)
Overview
Implementation of the QAOA ansatz from the paper that introduced it (Farhi, Goldstone and Gutmann 2014): the Quantum Approximate Optimization Algorithm, one of the most influential quantum algorithms for combinatorial optimization. This circuit applies QAOA to MaxCut on three small graphs (3 to 5 qubits) in simulation. It does not test the paper's 3-regular-graph bound, and its random search for p > 1 does not always find the best angles (on the triangle, the ratio drops from 0.9985 at p = 2 to 0.9932 at p = 3).
| Property | Value |
|---|---|
| Category | Research Reproduction |
| Difficulty | Advanced |
| Framework | Cirq (Google) |
| Qubits | 3-5 |
| Depth | O(p * |E|) |
| Gates | H, ZZPowGate, RX |
| Paper | arXiv:1411.4028 (2014) |
| DOI | 10.48550/arXiv.1411.4028 |
Paper Context
Edward Farhi, Jeffrey Goldstone, and Sam Gutmann introduced QAOA in November 2014 as a quantum algorithm designed for combinatorial optimization on near-term quantum devices. Unlike algorithms requiring fault-tolerant hardware (e.g., Shor's, Grover's), QAOA was explicitly designed as a shallow-circuit variational algorithm — making it one of the earliest proposals in the now-thriving field of variational quantum algorithms (VQAs).
The paper proved that at p = 1, QAOA achieves at least 0.6924 of the maximum cut on every 3-regular graph, and that the best achievable expected cut can only stay the same or improve as p grows, reaching the exact solution as p goes to infinity. This established QAOA as more than a heuristic, interpolating between a simple quantum heuristic and an exact quantum adiabatic algorithm.
The MaxCut Problem
Given an undirected graph G = (V, E), the MaxCut problem asks for a partition of the vertex set V into two disjoint subsets S and V\S that maximizes the number of edges crossing the partition. MaxCut is:
- NP-hard (Karp, 1972) — no known polynomial-time exact algorithm
- APX-hard — no polynomial-time approximation scheme (PTAS) exists unless P = NP
- The best classical polynomial-time algorithm (Goemans-Williamson, 1995) achieves ratio ~0.878
Example: Triangle Graph (K3)
CODE0 / \ 1---2 Max cut = 2 (any 2-1 partition achieves this)
Example: Square Graph (C4)
CODE0---1 | | 3---2 Max cut = 4 (alternating partition: {0,2} vs {1,3})
The QAOA Ansatz
The algorithm prepares a parametrized quantum state by alternating two unitaries p times:
|psi(gamma, beta)> = U_B(beta_p) U_C(gamma_p) ... U_B(beta_1) U_C(gamma_1) |+>^n
Cost Unitary U_C(gamma)
Encodes the MaxCut objective function into quantum phases:
CODEC = sum_{(i,j) in E} (1 - Z_i Z_j) / 2 U_C(gamma) = exp(-i * gamma * C) = prod_{(i,j) in E} exp(-i * gamma * (1 - Z_i Z_j) / 2)
Each edge contributes a ZZ-interaction gate with angle proportional to gamma.
Mixer Unitary U_B(beta)
Drives transitions between computational basis states:
CODEB = sum_i X_i U_B(beta) = exp(-i * beta * B) = prod_i RX(2*beta)
Circuit Diagram (p=1, triangle graph)
CODE┌───┐ ┌──────────┐ ┌────────┐ q_0: ┤ H ├──┤ ZZ(g/pi) ├──ZZ(g/pi)───────────────┤ RX(2b) ├── ├───┤ └────┬─────┘ ┌──────────┐ ├────────┤ q_1: ┤ H ├───────┘────────┤ ZZ(g/pi) ├────────────┤ RX(2b) ├── ├───┤ └────┬─────┘ ├────────┤ q_2: ┤ H ├──────────ZZ(g/pi)───┘──────────────────┤ RX(2b) ├── └───┘ └────────┘ ←── Cost unitary ──→ ←── Mixer ──→
Key Results from the Paper
Approximation Ratio by Depth
For 3-regular graphs, Farhi et al. proved the p = 1 bound; the p = 2 and p = 3 values are later worst-case results by Wurtz & Love (2021), the p = 3 one conditional on a conjecture:
| p (depth) | Approximation Ratio | Significance |
|---|---|---|
| 1 | >= 0.6924 | Provable worst-case bound (Theorem 1) |
| 2 | >= 0.7559 | Worst-case bound (Wurtz & Love 2021) |
| 3 | >= 0.7924 | Worst-case bound, conditional on a conjecture (Wurtz & Love 2021) |
| inf | 1.0 | Recovers exact solution (quantum adiabatic limit) |
Theoretical Bounds
- Farhi et al. p=1 bound: For every 3-regular graph, QAOA at p = 1 with optimal angles achieves an expected cut of at least 0.6924 times the maximum cut.
- Monotonicity: The expected cut value is non-decreasing in p — adding layers never hurts.
- Goemans-Williamson comparison: The classical SDP-based GW algorithm achieves ~0.878, establishing that moderate-depth QAOA is needed to compete classically.
- Guerreschi & Matsuura (2019): Estimated, from simulations on random 3-regular graphs, that QAOA needs several hundred qubits before its time-to-solution could beat a state-of-the-art classical exact solver (AKMAXSAT) on Max-Cut.
Prerequisites
Before studying this advanced research reproduction, ensure familiarity with:
- QAOA fundamentals: See QAOA MaxCut (intermediate) for the introductory version
- Variational circuits: Understanding of parametrized quantum circuits and hybrid classical-quantum optimization loops
- Graph theory basics: Vertices, edges, partitions, NP-hardness
Running the Circuit
Basic Usage
PYTHONfrom circuit import run_circuit # Test on triangle graph with QAOA depths 1, 2, 3 result = run_circuit( graph_type='triangle', # or 'square', 'butterfly' p_values=[1, 2, 3], n_iter=30 ) for p, data in result['p_analysis'].items(): print(f"p={p}: ratio = {data['approximation_ratio']:.3f}")
Verification
PYTHONfrom circuit import verify_reproduction verification = verify_reproduction() for check in verification['checks']: status = "PASS" if check['passed'] else "FAIL" print(f"[{status}] {check['name']}: {check['actual']}")
QubitHub CLI
qubithub execute has no --params option, so the graph type and depths cannot be overridden from the CLI. To change graph_type or p_values, call run_circuit() locally as shown above.
Available Test Graphs
| Graph | Qubits | Edges | Max Cut | Regularity | Notes |
|---|---|---|---|---|---|
| Triangle (K3) | 3 | 3 | 2 | 2-regular | Trivial: p=1 achieves ratio ~1.0 |
| Square (C4) | 4 | 4 | 4 | 2-regular | Bipartite: exact cut exists |
| Butterfly | 5 | 6 | 4 | Irregular | Non-trivial test of QAOA |
Implementation Notes
Cost Hamiltonian Encoding
The MaxCut cost function in the Pauli-Z basis:
C = sum_{(i,j) in E} (1 - Z_i Z_j) / 2
Each edge contributes a ZZ-interaction. The constant term (1/2 per edge) shifts the energy but does not affect the optimization landscape.
Parameter Optimization Strategy
| Depth | Method | Search Space | Justification |
|---|---|---|---|
| p = 1 | Grid search | gamma in [0, pi], beta in [0, pi/2] | 2D landscape is tractable; symmetry reduces range |
| p > 1 | Random search | Same per-parameter bounds | Higher-dimensional; random search as baseline |
The parameter symmetries gamma -> gamma + 2*pi and beta -> beta + pi reduce the search space. For production use, gradient-based optimizers (COBYLA, L-BFGS-B) or parameter-transfer strategies (Zhou et al., 2020) are recommended for p > 1.
Cirq-Specific Details
- ZZPowGate: Cirq's
ZZPowGate(exponent=t)equalsexp(-i * pi * t * Z Z / 2)up to a global phase. We sett = -gamma / pi, which givesexp(+i * gamma * Z Z / 2): the per-edge factor ofU_C(gamma) = exp(-i * gamma * (1 - Z Z) / 2), up to a global phase. - RX gate:
cirq.rx(theta)implementsexp(-i * theta/2 * X). Settingtheta = 2*betagives the desiredexp(-i * beta * X).
Verification Checks
The verify_reproduction() function runs four automated checks:
| Check | Criterion | Source |
|---|---|---|
| Triangle p=1 exact | Ratio > 0.95 on K3 | Trivially solvable at p=1 |
| Monotonic improvement | <C>(p=2) >= <C>(p=1) on square | Farhi et al. Theorem |
| Above Farhi bound | Butterfly p=1 ratio >= 0.6424 | Farhi p = 1 value minus 0.05, used as a loose threshold (the theorem covers 3-regular graphs; the butterfly is not 3-regular) |
| Ratio in range | Butterfly p=1 ratio between 0 and 1.01 | Sanity check (measured ratio: 0.98) |
Historical Significance
This 2014 paper is a cornerstone of near-term quantum computing:
- Introduced QAOA as a general-purpose quantum optimization framework, applicable to any combinatorial problem encodable as an Ising Hamiltonian
- Proved approximation bounds — the first provable performance guarantee for a variational quantum algorithm
- Established the depth-quality tradeoff — more layers monotonically improve the approximation ratio, interpolating to the exact quantum adiabatic solution
- Spawned a research subfield: QAOA variants include the Quantum Alternating Operator Ansatz (Hadfield et al., 2019), QAOA+ (Chalupnik et al., 2022), ADAPT-QAOA (Zhu et al., 2022), Recursive QAOA (Bravyi et al., 2020), and warm-start QAOA (Egger et al., 2021)
- Inspired practical benchmarks — QAOA MaxCut is now a standard benchmark for quantum hardware and compilers
References
Primary Paper
BIBTEX@article{farhi2014quantum, title = {A Quantum Approximate Optimization Algorithm}, author = {Farhi, Edward and Goldstone, Jeffrey and Gutmann, Sam}, journal = {arXiv preprint arXiv:1411.4028}, year = {2014}, url = {https://arxiv.org/abs/1411.4028}, doi = {10.48550/arXiv.1411.4028} }
Key Follow-Up Papers
| Paper | Year | Contribution | DOI / arXiv |
|---|---|---|---|
| Guerreschi & Matsuura | 2019 | Practical crossover estimates vs. an exact classical solver (AKMAXSAT) | 10.1038/s41598-019-43176-9 |
| Zhou et al. | 2020 | Parameter transfer and optimal QAOA | arXiv:1812.01041 |
| Wurtz & Love | 2021 | Worst-case bounds for p = 2 and 3 on 3-regular graphs | arXiv:2010.11209 |
| Basso et al. | 2022 | Performance on random regular graphs | arXiv:2110.14206 |
| Goemans & Williamson | 1995 | Classical SDP approximation (0.878) | 10.1145/227683.227684 |