Checking that a quantum program does what it should is hard once it runs on more than about 50 qubits, because a classical computer can no longer write down the $2^n$ numbers that describe its state. One escape is known. For shallow circuits, meaning circuits with only a few layers of gates, each output qubit depends on only a small neighborhood of inputs. Scalable Equivalence Checking and Verification of Shallow Quantum Circuits uses this locality to check equivalence in time linear in qubit count. Its cost, however, grows exponentially with depth. Real programs chain many shallow subroutines, such as oracles, transforms, and the repeated layers of variational circuits, and together these quickly pass any depth such a checker can handle. We propose to cut a deep program into shallow segments. The checker verifies each segment against a small, local contract that describes the quantum state at the segment boundary. A language model proposes those contracts while reading only one segment and its neighbors' contracts.
In plain terms, the idea borrows the classical software tactic of verifying functions one at a time using pre- and postconditions. The quantum version applies it to states described by local constraints. The checker stays exponential only in the depth of the largest segment, not the whole program. The language model never has to hold an unrolled circuit of thousands of gates in its context. It only has to guess the boundary descriptions, and a sound checker then accepts or rejects each guess.
Core Claim
Two failures from classical program analysis carry over to the quantum setting. The first is the analysis of units in isolation. In classical code, On the Effectiveness of Function-Level Vulnerability Detectors for Inter-Procedural Vulnerabilities shows that detectors which look at one function lose an average of 18.7% F1 because triggers and sanitizers live in callers. Graph Is the Verifier finds that 71.7% of vulnerable functions need evidence from outside the function. A quantum subroutine checked alone fails in the same way: whether it is correct depends on the input state its caller supplies. The second failure is dumping everything into a long context. QuantumSemEval shows that language models judging whole circuits fall back on surface patterns, and only 5 of 15 models beat chance on equivalent pairs. RepoDebug shows that model accuracy degrades as the input grows.
Our claim is that local-projector contracts fix both failures at once. They supply the missing caller context as an explicit precondition. They also give the language model a task that fits in a small context: propose a boundary description. Because a checker verifies every proposal soundly, the model is never trusted to decide equivalence itself.
The Mechanism
We reduce equivalence of circuits $U$ and $V$ acting on $|0\rangle^{\otimes n}$ to showing that $W = V^\dagger U$ returns $|0\rangle^{\otimes n}$ to itself, following the weak-equivalence setting of Yu et al. We split $W$ into shallow segments $W_K \cdots W_1$.
A contract $\mathcal{Q}^k$ is a set of projectors, each acting on a few qubits. A state satisfies the contract if every projector sends it to zero. The first contract $\mathcal{Q}^0$ contains the projectors $|1\rangle\langle 1|$ on each qubit, and exactly one state satisfies it: $|0\rangle^{\otimes n}$. The last contract $\mathcal{Q}^K$ is the same set. Intermediate contracts need not pin down a unique state. They only need to be true of every state that satisfies the previous contract.
To pass from $\mathcal{Q}^{k-1}$ to $\mathcal{Q}^k$, we take each projector $R \in \mathcal{Q}^k$ and pull it back through the segment, forming $P = W_k^\dagger R W_k$. Because $W_k$ is shallow, $P$ acts on only a small patch of qubits. We then check the local condition
$$ \ker\Big(\sum_{i \in N(R)} Q_i\Big) \subseteq \ker(P), $$
where $Q_i$ ranges over the projectors in $\mathcal{Q}^{k-1}$ whose support lies in a neighborhood $N(R)$ of the patch where $P$ acts. The condition is equivalent to $P \le c\sum_i Q_i$ for some constant $c$. This makes the check sound. Any state that every $Q_i$ sends to zero has zero expected value of $P$, so it satisfies $R$ after the segment.
The check is linear algebra on a region whose size is set by one segment's light cone and the chosen neighborhood radius. Its cost is therefore exponential in the per-segment depth, not the total depth. The check is incomplete: some true contracts need non-local reasoning to justify. Enlarging $N(R)$ trades cost for completeness. Strong equivalence follows the same pattern using the doubled-qubit Choi construction from Yu et al.
Research Program
We will build three components. The first is a segmenter. It splits a program at procedure boundaries where the source code has them, as in Qiskit or OpenQASM, and otherwise at layer boundaries sized to a depth budget.
The second is a contract source with three tiers. The first tier propagates exactly: for Clifford gates, and wherever pushing $\mathcal{Q}^{k-1}$ forward keeps projector supports within budget, the contract is simply the pushed-forward set, which needs no guessing. The second tier searches templates. It tries a fixed library of product-state, computational-basis, and Pauli-stabilizer constraints. The third tier is a language model, called only when the first two fail. It sees the segment's source, $\mathcal{Q}^{k-1}$, and the next downstream contract if one exists. It never sees the rest of the program.
When a check fails, the checker returns the failing projector $R$ and its patch as feedback. This borrows the verifier-in-the-loop design of Graph Is the Verifier. It also borrows the on-demand, neighbor-only retrieval of DyCoder, which navigates a partial dependency graph instead of indexing a whole repository. Both prior systems work on classical code. Here the "dependency" the model retrieves is the neighboring contract, not neighboring source text.
The third component is the checker itself, built on local projection machinery reused from Yu et al.
This design differs from its nearest relatives in specific ways. Yu et al. verify a whole unbroken circuit. We add the contract interfaces that stop depth from accumulating. AutoQ 2.0 verifies programs with loops and measurements, but it needs human-written invariants and verifies monolithically. Our contracts play the role of those invariants, but they are local, per-segment, and machine-proposed. We restrict the first version to unitary programs and leave mid-circuit measurement for later. CiFold finds repeated modules to cut circuits for execution. Its module detection is a candidate segmenter for us, and identical modules can reuse one verified contract, but CiFold itself proves nothing about correctness.
Baselines
The first reference point is simply running the Yu et al. local-projection checker on the whole mirrored circuit $W$ with the same neighborhood radius and a fixed time and memory budget on comparable hardware. This is the reference because it is exactly our method with zero intermediate contracts. The file reports 4.46 seconds for weak equivalence of random 100-qubit, depth-3 circuits, and 19.8 seconds for constraint generation at depth 6, in Scalable Equivalence Checking. We beat it if we verify instances whose total depth puts them outside its budget, while staying within a small factor of its time on instances it can already handle.
The strongest monolithic symbolic verifier is symTDD from Decision Diagrams for Symbolic Verification of Quantum Circuits. It reports verifying a 160-qubit QFT in under 180 seconds with 8 GB of RAM, and 8-qubit Grover in 29 seconds, with node counts that blow up on unstructured, multi-iteration circuits. It is strongest on structured algorithms, so we run it on identical circuit files with equal memory and wall-clock limits. Beating it means verifying structured-but-deep instances where its node count explodes, and matching it on QFT and Bernstein-Vazirani.
AutoQ 2.0 reports about 20 minutes for a 100-qubit weak-measurement Grover program. We run it on our unitary suite with the best hand-written invariants we can give it. That makes it an upper bound on what monolithic deductive verification achieves when a human supplies the key insight.
The language-model-as-judge baseline asks a model directly whether two circuits are equivalent, as in QuantumSemEval. There, o4-mini reached 70.8% on equivalent pairs and 100% on non-equivalent pairs. We give the same model the same pairs and the same total token budget our pipeline spends.
ZX-calculus simplification with PyZX is an obvious automatic competitor. We found no reported equivalence-checking result on Lacuna for it, so we will measure it ourselves on the same suite.
Two ablations isolate the proposal's key ingredients. The isolation ablation checks each segment against the contract it should produce, but with no precondition. It measures how often preconditions are necessary, the quantum counterpart of the 71.7% figure. The full-context ablation gives the language model the entire unrolled circuit when proposing each contract, holding everything else fixed. It tests whether bounded context itself matters.
Why not just…?
Why not just ask a long-context model whether the circuits are equivalent? QuantumSemEval shows that most models do worse than chance on equivalent pairs, with mixtral-8x22b at 16.9%. Even the best model sits near 70%. A verifier that is wrong 30% of the time on true equivalences, with no certificate, is not usable. Our pipeline never lets the model decide equivalence. The full-context ablation will show whether longer context even helps the narrower task of proposing contracts.
Why not just use symTDD or AutoQ monolithically? On structured circuits they may win, and we will report where they do. The file documents their weak spot: node growth on circuits without exploitable symmetry, and the need for human invariants. Our experiments target layered programs such as multi-iteration Grover and stacked QAOA-style layers, where these tools are reported to struggle.
Why not generate contracts automatically, with no language model? This is the real threat. Pushing contracts forward handles Clifford segments exactly, and template search may cover many textbook algorithms. That is why both are tiers of our own contract source, and the model is called only when they fail. If template search closes the same fraction of instances as the model, we will report that the model adds nothing. The contribution would then be the contract-and-checker method alone.
Why not just verify on hardware with mirror circuits or local inversions? Scalable Full-Stack Benchmarks and local inversions estimate physical fidelity and gate sensitivity. They do not certify that a program matches an algorithmic specification, which is a different question from the one we answer. They are complementary, not competing.
Proposed Experiments
The first suite is QuantumSemEval's 260 pairs: up to 20 qubits, depths up to 681, and 130 non-equivalent pairs built from 7 mutation types. At this size statevector simulation provides ground truth. The decisive check here is soundness: zero false accepts on the non-equivalent pairs. We also report the fraction of equivalent pairs we certify, compared with the 70.8% figure above.
The second suite is a scaling set of QFT, Bernstein-Vazirani, and multi-iteration Grover from 50 to 190 qubits, matching the families used by symTDD and CiFold. We add layered variational circuits, including k-UpCCGSD-style and QAOA-style layers, of growing total depth. Non-equivalent instances are made by applying the QuantumSemEval mutation types. The decisive plot is verification time against total depth at fixed per-segment depth. Our method should stay roughly flat while the Yu et al. baseline grows exponentially. If it does not, the neighborhood checks are secretly growing and the approach fails.
The third suite consists of multi-file Qiskit programs that we assemble from Qiskit HumanEval-style subroutines. It tests procedure-boundary segmentation and the isolation ablation.
Across all suites we report certified fraction, false-accept rate, wall-clock time, language-model calls, and tokens per call. We also report how contract sources split across the three tiers, which directly settles whether the model earns its place.
References
- Scalable Equivalence Checking and Verification of Shallow Quantum Circuits
- On the Effectiveness of Function-Level Vulnerability Detectors for Inter-Procedural Vulnerabilities
- Graph Is the Verifier: Agentic Reinforcement Learning for Interprocedural Vulnerability Detection
- QuantumSemEval: Benchmarking LLMs' Understanding of Quantum Programs via Semantic Equivalence Checking
- RepoDebug: Repository-Level Multi-Task and Multi-Language Debugging Evaluation of Large Language Models
- Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation
- AutoQ 2.0: From Verification of Quantum Circuits to Verification of Quantum Programs
- Circuit Folding: Modular and Qubit-Level Workload Management in Quantum-Classical Systems
- Decision Diagrams for Symbolic Verification of Quantum Circuits
- Scalable Full-Stack Benchmarks for Quantum Computers
- Quantum circuit debugging and sensitivity analysis via local inversions
- Generalized Unitary Coupled Cluster Wave functions for Quantum Computation
- Qiskit HumanEval: An Evaluation Benchmark for Quantum Code Generative Models