QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
HomeLearnCatalogRanksPlaygroundDocs
07 · QAOA on a small graph0%

You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.

Learn/QC 302Cutting and Quantum ML·Lesson 7 of 7

QAOA on a small graph

Cost and mixer layers for MaxCut, read off the cut from the histogram, and understand the depth p.

Advanced12 min read4 sections · 2 questions+45
By the end you will be able to
  1. 01Write the MaxCut cost Hamiltonian for a triangle.
  2. 02Identify cost (rzz) and mixer (rx) layers in a circuit.
  3. 03Interpret the histogram as candidate cuts.
C=(i,j)∈E∑​21​(1−Zi​Zj​),∣γ,β⟩=ℓ=1∏p​e−iβℓ​∑i​Xi​e−iγℓ​C∣+⟩⊗n
Each edge contributes 1 when its endpoints are on different sides of the cut. The cost layer is one rzz(2γ) per edge, the mixer one rx(2β) per qubit; p layers alternate.
Hands-on

MaxCut on a triangle, p = 1

Simulate: the six strings with one vertex alone (001, 010, 100 and their complements) carry most of the weight; each cuts two of the three edges, which is the maximum. 000 and 111 cut nothing and are suppressed.

OpenQASM 3
OPENQASM 3.0;
include "stdgates.inc";
gate rzz(theta) a, b { cx a, b; rz(theta) b; cx a, b; }
qubit[3] q;
bit[3] c;
h q[0];
h q[1];
h q[2];
rzz(2.5) q[0], q[1];
rzz(2.5) q[1], q[2];
rzz(2.5) q[0], q[2];
rx(0.6) q[0];
rx(0.6) q[1];
rx(0.6) q[2];
c = measure q;
Sign in to run (nothing is saved)
Open in the IDE Open in the Playground

QAOA does not output the answer; it outputs a distribution that favours good answers. You sample, evaluate the cut of each string classically, and keep the best. Increasing p improves the distribution but doubles the two-qubit gate count each time, so on hardware p stays at 1–3.

Knowledge check

2 questions · one try each counts

Question 1

In QAOA for MaxCut, the cost layer is built from…

Sign in to answer and climb the ranks; you will come back to this lesson.

Question 2

Why is a triangle's MaxCut at most 2?

Sign in to answer and climb the ranks; you will come back to this lesson.

Key takeaway

QAOA alternates a cost layer of rzz gates with a mixer of rx gates and samples good cuts with high probability. Depth p trades quality against two-qubit gate count.

Finished reading?

Knowledge check: 2 questions waiting above. Questions are optional. Mark it complete, or press Next: moving on marks it complete too.

Further reading
  • Docs: Hamiltonians and expectation values
More in Cutting and Quantum ML
  • Circuit cutting
  • Classical ML vs. Quantum ML: The Hybrid Loop
  • Variational circuits
Observables, Hamiltonians & Real Applications
In this lesson0%
  1. Introduction
  2. Try it: MaxCut on a triangle, p = 1
  3. Knowledge check
  4. Key takeaway
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in