DEV Community

Cover image for 🧱 QAOA vs ADAPT-QAOA: Building Quantum Circuits Like LEGO
Mai Chi Bao
Mai Chi Bao

Posted on

🧱 QAOA vs ADAPT-QAOA: Building Quantum Circuits Like LEGO

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?

A quantum circuit is a recipe of operations applied to qubits, step by step.

Think of it like a cooking recipe:

  1. Start with ingredients (qubits, all set to a neutral state)
  2. Apply steps (quantum "gates") in a specific order
  3. 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:

  1. Check every brick in the pool and see which one would improve the answer the most (largest gradient)
  2. Add that brick to the circuit
  3. Re-optimize all the knobs in the circuit
  4. 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: ...
Enter fullscreen mode Exit fullscreen mode

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:

  1. Let ADAPT-QAOA do the slow, expensive work once, offline, on lots of graphs β†’ collect high-quality circuits.
  2. Turn each graph into a vector fingerprint (Part 3).
  3. Write each circuit β€” bricks and knob values β€” as a sequence of tokens, like a sentence (Part 4).
  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.


πŸ‘‰ 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:

Top comments (0)