In Part 1, we met Max-Cut — split a graph into two teams and cut as many edges as possible.
Today we open the box.
How does a quantum computer actually attempt this? What's a "quantum circuit"? And why did the smartest version of the algorithm — ADAPT-QAOA — make me stare at my laptop for days while it generated data? 🫠
Let's build it with LEGO.
Key Takeaways
- What a quantum circuit is, in plain words.
- How QAOA builds circuits with a fixed recipe, and how ADAPT-QAOA builds them smartly, one block at a time.
- The two big pains my thesis tries to fix: choosing circuit structure and choosing starting parameters.
Table of Contents
- What Is a Quantum Circuit?
- Vanilla QAOA: The Fixed LEGO Recipe
- ADAPT-QAOA: Pick the Best Brick Every Time
- Pain #1: The Circuit Structure
- Pain #2: The Starting Knobs
- The Big Idea of My Thesis
- Conclusion
What Is a Quantum Circuit?
A quantum circuit is a recipe of operations applied to qubits, step by step.
Think of it like a cooking recipe:
- Start with ingredients (qubits, all set to a neutral state)
- Apply steps (quantum "gates") in a specific order
- Taste the result (measure)
In QAOA, each step comes in a layer, and each layer has 2 knobs, called γ (gamma) and β (beta):
- γ controls how much the circuit "listens" to the problem (the graph and its edges)
- β controls how much it "mixes" and explores different answers
More layers = more expressive circuit = potentially better answer.
But more layers also = more knobs to tune = slower and harder to optimize.
Vanilla QAOA: The Fixed LEGO Recipe
Vanilla (standard) QAOA is like a LEGO set with fixed instructions:
“Stack the same 2 bricks on top of each other, p times.”
Every layer uses the same type of "mixer" block. The only thing you choose is how many layers (p) — in my experiments, p = number of nodes.
Pros: Simple, predictable.
Cons: Not tailored to the graph. A dense graph and a sparse graph get the exact same structure.
In my thesis experiments, vanilla QAOA reached an Approximation Ratio of about 0.86 – 0.87 on 9–11 node graphs. Decent, but not amazing.
ADAPT-QAOA: Pick the Best Brick Every Time
ADAPT-QAOA says: why follow fixed instructions? Let's build the tower adaptively.
It has a pool of different bricks (operators). At every step:
- Check every brick in the pool and see which one would improve the answer the most (largest gradient)
- Add that brick to the circuit
- Re-optimize all the knobs in the circuit
- Repeat until it stops improving
Step 1: try all bricks → add the best one → re-tune everything Step 2: try all bricks → add the best one → re-tune everything Step 3: ... The result? Circuits tailored to each graph, with excellent quality: AR ≈ 0.97 in my experiments.
But there's a catch. Actually, two. 😬
Pain #1: The Circuit Structure
Look at that loop again. Every single step tests every brick and re-tunes every knob.
As the graph grows, the pool grows, the circuit grows, and the runtime explodes.
From my thesis measurements on a CPU:
| Nodes | Vanilla QAOA | ADAPT-QAOA |
|---|---|---|
| 9 | ~65 s | ~5.7 s |
| 11 | ~168 s | ~23.6 s |
| 13 | ~382 s | ~211 s |
And ADAPT-QAOA circuits got deep: about 13 – 15 layers on average for 9–11 node graphs, sometimes up to 25.
Generating my training dataset with ADAPT-QAOA took from several hours to multiple days, running in parallel on my laptop and my desktop (two RTX 3060 machines, because the ADAPT implementation is single-threaded). My room was basically a sauna for weeks.
“Just one more batch of graphs…” — me, at 2 AM
Pain #2: The Starting Knobs
Even if you know the right structure, you still have to choose where to start the knobs (γ, β) before optimizing.
Start in a bad spot, and you may land in a barren plateau: a region where the landscape is so flat that the optimizer has no idea which direction is "better".
Imagine being dropped in the middle of a desert at night and told to find the lowest valley. Everything around you looks perfectly flat. Which way do you walk?
Poor initialization = slow convergence, or getting stuck with a mediocre answer.
The Big Idea of My Thesis
Most previous work treats these two pains separately:
- one method to pick the circuit structure
- another method to guess the starting knobs
My question was:
“What if one model learned both at the same time, just by looking at the graph?”
Here's the plan:
- Let ADAPT-QAOA do the slow, expensive work once, offline, on lots of graphs → collect high-quality circuits.
- Turn each graph into a vector fingerprint (Part 3).
- Write each circuit — bricks and knob values — as a sequence of tokens, like a sentence (Part 4).
- Train a GPT-style language model to "write" the circuit for a new graph in one go.
If it works, we get ADAPT-like circuits in a fraction of a second, instead of minutes.
Conclusion
| Vanilla QAOA | ADAPT-QAOA | |
|---|---|---|
| Structure | Fixed recipe | Built step by step per graph |
| Quality (AR) | ~0.86 – 0.87 | ~0.97 |
| Depth | = number of nodes | ~13 – 15 layers (up to 25) |
| Speed | Slow | Faster than vanilla, still grows fast |
- A quantum circuit = a recipe of layers, each with knobs γ and β.
- ADAPT-QAOA builds better, graph-specific circuits — but it's expensive and circuits get deep.
- Two pains: which bricks (structure) and where to start the knobs (initialization).
- My thesis: learn both with one generative model.
🚀 Coming up next: Part 3 — language models can't read graphs. So how do we turn a graph into numbers a model understands? Meet NetLSD, FEATHER and GNN.
Reference
All the code is live here on my GitHub:
mrzaizai2k/Adapt-LLM
Feel free to clone it, star it ⭐, or ask me anything.
- ADAPT.jl — the ADAPT-QAOA implementation I used
- PennyLane: Intro to QAOA — great hands-on tutorial
👉 Hit follow so you don't miss Part 3.
Ever had an algorithm that was great but way too slow? Tell me your story in the comments 😄
Project Demo
Want the quick version of the whole project? Here's my demo video:
