Quiz: Circuit Optimization

Answers with explanations at the end.


1. In one sentence, why does this chapter follow Chapter 27 rather than precede it?

2. What does optimization level 0 do, and what does it not do?

3. How do you verify that a transpiled circuit is equivalent to the original, and what goes wrong if you skip the layout?

4. Why can you not run that verification on a 127-qubit backend, and what should you do instead?

5. On a Grover-like circuit, level 2 produced a 16% deeper circuit with 6% fewer two-qubit gates. Is this a bug? Explain.

6. Which physical quantity does depth govern, and which does two-qubit count govern?

7. Eight seeds of level 1 versus level 2 gave a fidelity difference of $+0.0028 \pm 0.0065$. What should be reported?

8. Which level transition is a significant win, and by how much?

9. The best-optimized circuit retained 12.9% of its noiseless signal. What does that imply about the role of optimization?

10. An earlier draft concluded levels 2 and 3 were identical. What was the error, and what did widening the test show?

11. Name two passes level 3 has that level 2 does not, and say what each does.

12. On the wasteful test circuit, which single pass reduced depth from 8 to 1? Why that one?

13. RemoveIdentityEquivalent did nothing on that circuit. Is the pass broken? Explain.

14. Pass order changed the output from u1 to rz. Did it change the unitary? What does this imply about pass-manager design?

15. H H transpiles to depth 0. When is this a disaster, and what is the fix?

16. Chapter 25's id noise slot was wrapped in barriers and deleted anyway. Explain precisely what a barrier does and does not prevent.

17. Does approximation_degree=0.99 produce a circuit with 99% fidelity? Give the measured value.

18. What happens between approximation_degree 0.95 and 0.9, and why does it make the parameter dangerous rather than merely imprecise?

19. Give three things the transpiler cannot do that a human can.

20. Why does the transpiler not optimize $T$ count, and when does that matter?


Answers

1. Because every optimization is a claim that two circuits are equivalent, and without a way to check the claim an optimizer is a machine for introducing bugs quickly.

2. It makes the circuit runnable — basis translation, layout, routing — and it does not optimize. Its optimization stage contains zero passes.

3. process_fidelity(Operator.from_circuit(transpiled), Operator(padded_logical)), which should be exactly 1.0. Operator.from_circuit applies the initial layout and the routing permutation; without it you get Chapter 26 Case Study 2's 0.001406 — a plausible number produced by comparing two circuits on mismatched wires.

4. Because the unitary would be $2^{127} \times 2^{127}$ — about $1.7 \times 10^{38}$ amplitudes per row. Verify on a small backend with similar coupling structure, then apply the same settings to the large one. The setting transfers; the verification does not.

5. No. Depth and two-qubit count are both standard optimization objectives, and the transpiler resolves them differently at different levels — level 2's TwoQubitPeepholeOptimization and CommutativeCancellation find gate reductions that cost serialization. Two objectives disagreeing, not a regression.

6. Depth governs decoherence — the circuit must finish inside $T_1$ and $T_2$. Two-qubit count governs gate error — Chapter 12 measured a median ecr error around $8\times10^{-3}$ with a 288× spread. Both are real; here they point in opposite directions.

7. "No measurable change", or the number with its error bar. The mean is higher and the error bar is twice the difference. A gate-count improvement is not a performance claim — "level 2 reduced two-qubit gates by 9%" is true and corresponds to nothing measurable in the output.

8. Level 0 to level 1, which roughly doubles the surviving signal (6.5% → 12.9% of noiseless) for milliseconds of transpiler time. Everything above level 1 is refinement.

9. That optimization is a constant-factor improvement to an exponentially decaying quantity. Worth doing; not a strategy. Chapter 25 §25.9 explains why — the device is on the wrong side of the error-correction threshold, and no amount of gate-count tuning moves a threshold.

10. The conclusion came from two small circuits (QFT(5), Grover-ish(5)) that happen to agree — and circuits where two configurations agree are, by definition, the ones that cannot tell them apart. Widening to 5 circuits × 8 seeds: they differ in 14/40 trials, and level 3 wins 12 of the 14. Vary the circuit as well as the seed.

11. MinimumPoint (instead of level 2's FixedPoint) — keeps iterating and returns the best circuit seen rather than stopping at the first fixed point. VF2PostLayout (with ApplyLayout) — re-examines the layout after routing using measured error rates.

12. CommutativeCancellation. It knows an RZ commutes through a CX's control, which is where the non-obvious cancellations live — the other three passes only see adjacent inverse pairs or single-qubit runs.

13. No. None of those gates is individually close enough to the identity for its threshold; the three RZs sum to zero only collectively. A pass that does nothing on your circuit is not a broken pass — different passes see different structure.

14. No — same depth, same unitary, different basis (fid 1.000000 both ways). On larger circuits ordering changes gate counts too, which is why the preset pass managers wrap their optimization stage in a convergence loop rather than running each pass once.

15. It is a disaster when those Hadamards were holding a qubit in the X basis for a duration — the unitary is the identity but the timing was the point. The fix is a barrier, which prevents cancellation across it.

16. A barrier stops gates commuting across it. It does not stop a single removable gate between two barriers from being removed — the barriers survived ({'barrier': 2, 'measure': 1}) and the id did not. "Wrap it in barriers" is the standard advice and it fails here. Chapter 25's fix — optimization_level=0 plus an assertion on the gate count — remains the only reliable one.

17. No — it produced 0.925328. The parameter is a knob on the synthesis routine's internal tolerance, not a specification of output fidelity, and the relationship between them depends on the circuit.

18. The two-qubit gates go from 8 to zero, leaving a depth-3 circuit of single-qubit rotations with 46% overlap with the requested operation. It is dangerous because a dial that degrades smoothly is manageable and one with a trapdoor is not — and the resulting circuit looks better on every hardware-facing metric: shallower, faster, higher fidelity against the noise model. It simply computes something else.

19. Any three of: choose a decomposition (Chapter 19's plain MCXGate with spare qubits beat a hand-specified v-chain — leaving the transpiler room is itself a hand optimization); know that your ancillas are free, which is a qubits-for-depth trade only you can make; exploit problem structure — Chapter 22's AQFT cutoff is a numerical argument about phase precision, not a circuit identity, and no peephole optimizer will find it; restructure the algorithm at all.

20. Because its objectives are depth and two-qubit count — the pre-fault-tolerant metrics. $T$ count matters after error correction: Chapter 25 §25.10 showed the surface code supports Clifford gates natively and $T$ gates only through magic state distillation, which is why Chapter 15's resource estimates were $T$-dominated. Optimizing one does not optimize the other.