Case Study 2: Designing an Ansatz Under a Gate Budget

"Every ansatz decision is a trade between what you can represent and what you can afford to run. Making it with numbers takes twenty minutes."

Executive Summary

You have eight qubits, a hardware error budget of roughly 100 two-qubit gates, and a problem whose solution is entangled across the whole register. Which ansatz?

There are four knobs — depth, entanglement pattern, rotation set, and qubit count — and the naive answers are all wrong in instructive ways. This case study measures each knob, discovers that one of them is free, finds that the most expressive option is not the best one, and ends with a decision you could defend to a reviewer.

The method matters more than the answer, because you will make this decision again for every problem and every device.

Skills applied: ansatz construction (§8.8); entanglement patterns (§8.7); logical versus ISA cost (§8.8); the ry/ryrz result (§8.8); reachable entanglement (Ch. 4 checkpoint).

Reproducibility. FakeSherbrooke, seed_transpiler=42, optimization level 3.

The Constraint

Chapter 1 §1.5 gave the budget: a few hundred two-qubit gates before a clean run becomes a coin flip. Chapter 4 §4.9 refined it: on a good layout, GHZ fidelity decays at roughly 0.978 per qubit, and each entangling gate costs error.

Take 100 two-qubit gates as the working ceiling. Everything below is measured against it.

Knob 1: Depth

The obvious knob, and the one with the clearest cost.

For linear entanglement on $n$ qubits, depth $d$ costs $(n-1) \times d$ two-qubit gates.

   n   depth | params  logical  ISA   ratio    2q
   ---------------------------------------------
   2       1 |      8        5   16     3.2     1
   4       2 |     24       11   35     3.2     6
   6       2 |     36       13   42     3.2    10
   8       3 |     64       19   61     3.2    21
  10       3 |     80       21   66     3.1    27

Two things to read.

The ISA-to-logical depth ratio is a remarkably stable 3.1–3.2×. That is not a coincidence: it is Chapter 3 §3.8's arithmetic — every single-qubit gate becomes three rz and two sx — applied uniformly. It means you can estimate ISA depth from logical depth by multiplying by three, which is a genuinely useful rule of thumb.

Two-qubit gates grow linearly in both $n$ and $d$. At $n = 8$, our 100-gate budget buys $100 / 7 \approx 14$ layers of depth, which is far more than the barren-plateau literature suggests is useful. Depth is not the binding constraint here — which is worth discovering before spending effort optimizing it.

Knob 2: Entanglement Pattern

  pattern           n=4 cx   n=6 cx   n=8 cx   n=8 depth
  ------------------------------------------------------
  full                   6       15       28          17
  linear                 3        5        7          11
  circular               4        6        8          12
  pairwise               3        5        7           6
  reverse_linear         3        5        7          11

full is quadratic and it shows. At $n = 8$ it is 28 CNOTs per layer against 7 for linear — four times the cost, and the gap widens as $n$ grows. With a 100-gate budget, full buys three layers and linear buys fourteen.

pairwise matches linear's count at nearly half the depth — 6 against 11 at $n = 8$ — because its two sub-layers act on disjoint qubit pairs and execute in parallel. Depth costs decoherence, so this is a real gain for free.

But there is a catch the table does not show. These are logical counts, assuming any pair can interact. On real hardware, a pattern that requires non-adjacent pairs forces the router to insert SWAPs at three CNOTs each (Ch. 4 §4.6). linear and pairwise map onto a 1-D chain of physical qubits with no routing at all; full requires routing for most of its pairs, so its real cost is worse than 4× — which is why the ISA numbers are the ones to trust.

Knob 3: Rotations — and the Surprise

The naive reasoning: ryrz has twice the parameters, so it must cost roughly twice as much.

  rotation   params   ISA depth   2q   pulses
  -------------------------------------------
  ry             12          41    6       40
  ryrz           24          41    6       38

Identical ISA depth. Identical two-qubit count. Slightly fewer real pulses.

The explanation is Chapter 3's Case Study 2: an arbitrary single-qubit gate costs exactly three rz and two sx on this hardware, regardless of complexity. ry(θ) and ry(θ)·rz(φ) both merge into one arbitrary single-qubit unitary. The second rotation is free.

So the choice is not about circuit cost at all:

ry ryrz
Hardware cost 2 pulses per qubit per layer identical
Parameters $n(d{+}1)$ $2n(d{+}1)$
Reachable states real amplitudes complex amplitudes
Optimizer evaluations fewer ~2×
Barren-plateau exposure lower higher

It is entirely an optimization decision. Chapter 5's Case Study 1 established that optimizer iterations are the dominant cost of a VQE — hundreds of energy evaluations, each costing thousands of shots. Doubling the parameter count roughly doubles that, and buys access to states a real-amplitude ground state does not need.

⚠️ Common Pitfall — "More gates means more error" is a good heuristic that fails here.

The intuition is correct in general and wrong in this specific case, because of a property of the hardware's basis set. Had the team reasoned from the heuristic they would have chosen ry for the right conclusion and the wrong reason — and then made the opposite error the first time they met a device whose basis made single-qubit gates expensive.

Measure the cost of a design decision rather than assuming it. The measurement is two lines and twenty seconds, and it is the difference between a rule you can apply and a rule you can transfer.

Knob 4: Qubit Count

Not usually free to choose — the problem sets it. But it is worth knowing where the budget runs out.

With linear entanglement at depth 3, two-qubit gates are $3(n-1)$:

$n$ 2q gates Within 100?
4 9 yes
8 21 yes
12 33 yes
20 57 yes
34 99 at the ceiling

Linear entanglement at modest depth is cheap enough that qubit count is not the binding constraint either — up to roughly thirty qubits. That is a more optimistic picture than Chapter 1's framing suggests, and it comes with an immediate caveat: the number of gates is within budget, but Chapter 4 §4.9's fidelity measurement showed a 20-qubit entangled state landing near 0.65 even with a good layout. Gate count and fidelity are different constraints, and the second is tighter.

The Decision

For eight qubits, an entangled solution, and a 100-gate budget:

Knob Choice Why
Entanglement pairwise same cost as linear, ~half the depth, maps to hardware without routing
Depth 3 21 two-qubit gates, well inside budget; deeper risks barren plateaus for no measured gain
Rotations ry free either way in circuit terms; halves the optimization problem, and a real-amplitude answer does not need rz
Qubits 8 set by the problem

Result: 32 parameters, 21 two-qubit gates, ISA depth around 60. Comfortably inside budget on every axis.

What the numbers do not tell you

Two things, and stating them is part of defending the decision.

Whether the ansatz can represent the answer. Every number here is a cost. None of them says the ansatz contains a good solution. Chapter 4's checkpoint added reachable_entanglement() for exactly this, and it should be run before committing:

reachable_entanglement(ansatz, n_samples=200)     # can it reach entangled states at all?

An ansatz that is cheap and cannot represent the answer is worthless, and cost tables cannot detect that.

Whether the optimizer can find it. Expressiveness and trainability pull in opposite directions — Chapter 32 §32.5 derives why, and Chapter 16 §16.6 measures it: over a layer sweep, a shallower ansatz starts about 5× higher in gradient variance but decays with width at the same rate, so you buy a constant factor and the wall stays where it is. The ry choice above is partly a bet on that trade, and it is a bet, not a derivation.

🔬 Honest Assessment — What ansatz design currently is.

It is not a solved problem, and the honest description is that it is empirical.

There is no theory that tells you, for a given Hamiltonian and device, which ansatz will converge. The hardware-efficient family is popular because it is cheap and hardware-friendly, not because it is known to be good — and it is known to suffer barren plateaus at scale. Chemistry-inspired ansätze (UCCSD, Chapter 36 §36.5) have better theoretical grounding and are dramatically more expensive.

So what this case study actually produces is a defensible starting point with its costs measured, not an optimal design. That is the honest deliverable, and it is worth more than a confident recommendation, because the numbers let the next person change one knob and know what it cost.

When you read a paper proposing a new ansatz, the questions are: what does it cost in two-qubit gates, does it avoid barren plateaus at the sizes tested, and was it compared against a hardware-efficient baseline of equal cost? The third is skipped surprisingly often.

Lessons

  1. Measure the knobs; do not reason about them. One of the four turned out to be free.
  2. The ISA-to-logical depth ratio is stable at about 3× on this hardware — a usable rule of thumb.
  3. full entanglement is quadratic, and worse than quadratic after routing. Use it only on small circuits or all-to-all hardware.
  4. pairwise matches linear's gate count at half the depth, for free.
  5. ryrz costs nothing extra in circuit terms. The choice is about the optimization problem, not the hardware.
  6. "More gates means more error" is a good heuristic that failed here. Transferable rules come from measurement, not intuition.
  7. Gate count and fidelity are different constraints, and fidelity binds first.
  8. Cost tables cannot tell you whether the ansatz contains the answer. Run reachable_entanglement before committing.
  9. Ansatz design is empirical. Produce a defensible starting point with measured costs, not a confident recommendation.

Questions

  1. Reproduce the four tables for your own choice of backend. Does the ISA/logical ratio still land near 3? If not, what does that tell you about that device's basis set?

  2. Redo the entanglement comparison using ISA two-qubit counts rather than logical ones. How much worse does full become once routing is included? Does the ranking change?

  3. The 100-gate budget was asserted. Derive one instead: using your backend's median two-qubit error rate, compute the gate count at which the probability of an error-free run drops below 50% (Ch. 1 Exercise 1.12).

  4. Run reachable_entanglement on the recommended ansatz (8 qubits, pairwise, depth 3, ry) and on a depth-1 version. Does depth 3 buy measurably more reachable entanglement? Is the answer what you expected?

  5. Construct a problem where full entanglement is the right choice despite its cost. What property of the target state would justify it?

  6. The ry choice assumes a real-amplitude answer. Construct a target state that ry-only cannot reach, verify that it cannot, and confirm that ryrz can.

  7. Hardest. Design an experiment to compare two ansätze fairly — one hardware-efficient and one chemistry-inspired — on the same problem and device. What must be held equal? (Consider: gate count, parameter count, shot budget, optimizer, initialization, and number of restarts.) Which of these are usually not controlled in published comparisons, and what would that do to the reported result?