Quantum computing · Theory (AI-assisted)
Exact CNOT synthesis: depth two takes quadratic time, depth three is NP-complete
arXiv:2611.40889v1 ↗PDF ↗Submitted 30 November 2026
- Question
- Quantum compilers cut out blocks of CNOT gates and resynthesize them, because two-qubit gates are slow and noisy, and the block's depth sets its latency. Such a block computes an invertible matrix \(M\) over \(\mathbb F_2\). Given \(M\) explicitly, with all-to-all connectivity, fixed wire labels and optionally clean ancillas, how hard is it to decide whether \(M\) can be implemented in \(k\) layers? Jiang et al. posed the question; only asymptotic and gate-count results were known.
- Result
- There is a sharp threshold. Whether \(M\) has a circuit of depth at most two can be decided, and a circuit built, in \(O(n^2)\) time, and clean ancillas never help at this depth. Deciding depth at most three is NP-complete, for every polynomially bounded ancilla budget, for unlimited clean workspace, and even for unit lower-triangular \(M\). At depth three, \(\lfloor n/3\rfloor\) clean ancillas suffice whenever any number does, and a five-wire example needs one ancilla to reach depth three instead of four.
The paper in detail
A CNOT gate adds one wire's value into another, so a CNOT circuit computes \(x\mapsto Mx\) for an invertible matrix \(M\) over \(\mathbb F_2\). One layer is a set of gates on disjoint wires, and its matrix is an involution \(I+P\), with \(P\) the adjacency matrix of a directed matching. Clean ancillas start at zero and must end at zero, so a circuit with \(m\) ancillas implements \(M\) when \(C(x,0^m)=(Mx,0^m)\) for all \(x\). The question is the minimum depth \(d_m(M)\).
Depth two is tractable because two matchings leave visible traces. A two-layer circuit gives \(M=(I+Q)(I+P)=I+P+Q+QP\). After cancelling repeated gates, every gate appears as an off-diagonal entry of \(M\), so its endpoints form an edge of the support graph \(H_M\), and every edge of \(H_M\) joins vertices at distance at most two in the union \(J\) of the two matchings. Since \(J\) has maximum degree two, it is a union of paths and cycles, and \[J\subseteq H_M\subseteq J^2\quad\Longrightarrow\quad\Delta(H_M)\le4,\ \ \operatorname{tw}(H_M)\le4.\] Each wire then has at most 81 roles across the two layers, the row equations become unary and binary constraints on \(H_M\), and dynamic programming over a width-four tree decomposition decides the question. Ancillas cannot help, because an ancilla used as a control within two layers is still zero.
Depth three leaves just enough time for one ancilla pattern: copy a data wire onto an ancilla, use the copy as a control, and erase it. Lemma 4.1 shows this is the only pattern. Every three-layer clean-ancilla circuit is equivalent to \[M=A_3(I+F)A_1,\] where \(A_1,A_3\) are matching layers on the data wires and \(F\) is a disjoint union of outward stars with one or two leaves. Each two-leaf star costs one ancilla, and its centre must be idle in \(A_1\) and \(A_3\). Since a two-leaf star uses three wires, \(\lfloor n/3\rfloor\) ancillas always suffice at depth three.
Hardness comes from edge colouring. If every edge of a bipartite graph of maximum degree three is one CNOT from a source to a target, a three-layer schedule is a proper three-edge-colouring, which always exists by Kőnig's theorem. Precoloured edges make the problem NP-complete (Fiala's theorem), and the authors reduce it to a restricted form with precoloured pins at leaves. Each pin becomes a four-wire clock whose output column records the layer in which the source injected. The soundness proof then shows that no circuit, however it resynthesizes \(M_G\), can escape this structure: sources hold their inputs throughout, each main target receives its three sources in three distinct layers, and the clocks fix the pin colours.
The authors note that sparsity does not explain the threshold, since the hard instances are unit lower-triangular with constant row and column weights. Open questions are the complexity at each fixed depth of four or more, and the models with borrowed ancillas, free permutations, restricted connectivity or mid-circuit measurement.
Transferable methods
Gate visibility and bounded treewidth at depth two
A synthesis algorithm receives only the product matrix, and a candidate circuit may route information anywhere. At depth two this freedom is limited: after cancellations no gate can hide, so the unknown circuit lives on the known graph \(H_M\), whose treewidth is at most four. That turns an existence question over all circuits into a constraint problem of bounded width.
For a first-layer gate \(j\to i\), \(P_{ij}=1\) is the only nonzero entry in column \(j\) of \(P\), so \((QP)_{ij}=Q_{ii}P_{ij}=0\), and \(Q_{ij}=0\) after cancellation. Hence \(M_{ij}=P_{ij}+Q_{ij}+(QP)_{ij}=1\). An entry \((QP)_{ij}=1\) needs a wire \(k\) with \(Q_{ik}=P_{kj}=1\), a path of length two in \(J\). The square of a cycle \(v_1,\dots,v_\ell\) has the path decomposition with bags \(\{v_1,v_2,v_i,v_{i+1},v_{i+2}\}\), of width four. Editorial check: over all \(4211\) depth-two matrices on five wires and \(68{,}791\) on six, the support graph never has a vertex of degree above four.
How to reuse it
Showing that a shallow circuit's gates must appear in the support of its product, and then solving a bounded-treewidth constraint problem, could decide other shallow synthesis problems exactly, for example depth-two circuits of CZ and CNOT gates or two-round parity networks on fixed hardware graphs.
A three-layer normal form against arbitrary resynthesis
A hardness proof for exact synthesis has to rule out every shortcut: intermediate parities, cancellations and routing through ancillas. Lemma 4.1 reduces all clean-ancilla circuits of depth three to one algebraic shape, and global invariants of the target matrix, such as column weights of \(M\) and \(M^{-1}\), then force any factorization to behave like the intended edge colouring.
Restrict a three-layer circuit to inputs \((x,0^m)\), so every wire holds a linear form in \(x\). An ancilla is nonzero after layer one only if a data wire \(i\) was copied onto it, and to finish at zero it must be cleared in layer three by a wire holding exactly the same form, which linear independence forces to be wire \(i\) itself, unchanged. So each active ancilla only relays \(x_i\) in the middle layer, giving the star \(F\). Lemma 4.4 adds rigidity: if row \(i\) of \(M\) is \(e_i^{\top}\) and both \(Me_i\) and \(M^{-1}e_i\) have weight at least four, wire \(i\) is never a target, because a wire overwritten early can spread \(x_i\) to at most three outputs within three layers. Editorial check: enumerating all three-layer circuits on four data wires with one or two clean ancillas, and on five with one, gives exactly the matrices \(A_3(I+F)A_1\) of the normal form (3,363 and 125,461 of them).
How to reuse it
Normal forms for shallow circuits with clean workspace could support hardness proofs for other compilation tasks, such as minimizing the depth of phase polynomials or of measurement-free Clifford circuits, where ancilla shortcuts otherwise defeat gadget reductions.
Context & limitations
Why it matters. This settles the complexity of exact depth minimization for CNOT circuits under all-to-all connectivity, which earlier hardness results for gate count, parity networks or the larger Clifford gate set did not imply. It explains why depth-optimal synthesis tools must rely on SAT solvers once depth three is allowed, while depth two needs none. The three-versus-four gap also rules out polynomial-time approximation of the minimum depth within any factor below \(4/3\) unless P = NP.
Limitations. Hardness is proved for threshold three. For each fixed depth of four or more, the complexity is open, and so are a normal form and tight workspace bounds there. The model excludes free qubit permutations, borrowed (dirty) ancillas, restricted connectivity and mid-circuit measurement, each used by some compilers. The linear-time part of the depth-two algorithm has a very large constant (up to \(81^5\) states per bag). The authors state that GPT-6.1 Sol assisted in developing the technical results and proofs of Sections 3 to 5, and that GPT-6.1 Sol and Gemini 4 Argon helped with drafting, the leaf-pin reduction and checking Example 4.3.