|q⟩ Bad Qubits

advanced · Programming · Capstone Projects

Project: QAOA at Scale

The Quantum Approximate Optimization Algorithm (QAOA) attacks combinatorial problems by interleaving a problem-specific cost Hamiltonian with a generic mixing Hamiltonian, tuning the angles to push amplitude toward high-quality solutions. This capstone builds a full QAOA layer for MaxCut and asks you to assemble the cost gadget, mixer, and measurement correctly — the same template that "scales up" to deeper circuits and larger graphs.

MaxCut and the cost Hamiltonian

Given a graph G=(V,E)G = (V, E), MaxCut partitions the vertices into two sets to maximize the number of edges crossing the partition. Encoding each vertex as a qubit, the cut value of a bitstring zz is

C(z)=(i,j)E1zizj2,zk{+1,1}.C(z) = \sum_{(i,j)\in E} \frac{1 - z_i z_j}{2}, \qquad z_k \in \{+1, -1\}.

Promoting zkZkz_k \to Z_k gives the cost Hamiltonian HC=(i,j)E12(IZiZj)H_C = \sum_{(i,j)\in E} \tfrac{1}{2}(I - Z_iZ_j), whose largest eigenvalue is the maximum cut.

One QAOA layer

A depth-pp QAOA applies pp alternating layers to the uniform superposition +n|+\rangle^{\otimes n}:

γ,β=k=1peiβkHMeiγkHC  Hn0n,|\boldsymbol{\gamma}, \boldsymbol{\beta}\rangle = \prod_{k=1}^{p} e^{-i\beta_k H_M}\, e^{-i\gamma_k H_C}\; H^{\otimes n}|0\rangle^{\otimes n},

with mixer HM=qXqH_M = \sum_q X_q. For p=1p = 1 there is a single pair (γ,β)(\gamma, \beta). Each cost term eiγZiZje^{-i\gamma Z_iZ_j} compiles to the gadget

CX(i,j); RZ(2γ,j); CX(i,j),\texttt{CX}(i,j);\ \texttt{RZ}(2\gamma, j);\ \texttt{CX}(i,j),

and each mixer term is RX(2β,q)\texttt{RX}(2\beta, q).

The triangle instance

For the triangle K3K_3 every pair of vertices is connected. The best cut isolates one vertex, cutting 22 of the 33 edges — the bitstrings 100,010,001100, 010, 001 and their complements 011,101,110011, 101, 110 are all optimal. A well-tuned single layer concentrates measurement probability on exactly these six strings and away from the two uncut configurations 000000 and 111111.

Try it

Build the p=1p = 1 QAOA circuit for the triangle with γ=π/4\gamma = \pi/4, β=π/8\beta = \pi/8, and measure. The grader checks the output distribution; you should see the two non-cut strings 000000 and 111111 suppressed relative to the six optimal cuts.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.