Gate Decomposition
Gate decomposition expresses a desired transformation as a sequence of gates available in a chosen alphabet. The main idea is to preserve useful structure: a parity rotation can need only a few entanglers even when its full matrix is large. A generic many-qubit unitary, in contrast, usually requires exponentially many gates. This page develops constructive synthesis and its approximation limits; circuit optimization explains how to simplify an already constructed circuit.
Required background. Circuit representations explain inputs, outputs and allowed operations; universal gate sets distinguish exact from approximate synthesis. Use the matrix and rotation conventions in single-qubit gates and multi-qubit gates.
Gate synthesis and the meaning of equality
Section titled “Gate synthesis and the meaning of equality”Write for the matrix of the synthesized circuit and for its target. For an isolated unitary, has the same physical action. A useful approximation measure is therefore
The operator norm bounds the largest state-vector error over normalized inputs. The same global phase can become relative if this block is later coherently controlled. In that setting, match the phase or supply its correction; controlled operations explains why.
Fix the available gates, their angle units, allowed ancillas and connectivity before counting resources. Three CNOTs, three native entanglers and three logical gates are different costs. Likewise, an exact symbolic rotation does not imply a noiseless physical implementation. Keep synthesis error, implementation noise and fault-tolerant logical failure distinct.
Preserve Structure Before Expanding a Matrix
Section titled “Preserve Structure Before Expanding a Matrix”A generic -qubit matrix has complex entries before constraints are used. Materializing it can destroy precisely the structure that made the original operation efficient. The first synthesis decision is therefore not which matrix factorization to call. It is whether the target has a better description.
| Recognized structure | Preferred first reduction | Why it matters |
|---|---|---|
| tensor product | synthesize factors independently | avoids artificial entanglers |
| controlled or block diagonal | controlled-unitary or multiplexor construction | retains shared substructure |
| diagonal | phase polynomial or diagonal synthesis | avoids generic off-diagonal work |
| Pauli exponential | basis change, parity computation, one rotation | cost scales with support |
| Clifford operation | symplectic or tableau synthesis | preserves efficient discrete structure |
| state preparation or isometry | synthesize only required columns | avoids completing a full arbitrary unitary |
| sparse permutation | reversible-logic synthesis | exploits combinatorial action |
| dense one- or two-qubit block | Euler or Cartan/KAK decomposition | closed-form bounded-size synthesis |
| dense multiqubit unitary | cosine–sine or Quantum Shannon decomposition | asymptotically appropriate generic fallback |
Structure recognition must itself be reliable. A matrix that is numerically close to diagonal is not exactly diagonal, and treating it as such spends an approximation budget. Likewise, inferring a tensor product from rounded entries requires a residual and a threshold. Exact symbolic predicates and numerical near-structure tests should be separate compiler modes.
One-Qubit Leaves
Section titled “One-Qubit Leaves”Every admits an Euler form
The Euler construction derives these angles. A common choice is . At its endpoints, some angles become redundant: choose a convenient representative and reconstruct the matrix to check it. Smooth targets need not admit a globally continuous choice of Euler angles. A jump in a coordinate is not necessarily a jump in the implemented gate.
Leave symbolic angles available for later fusion. A native continuous alphabet can implement the Euler factors exactly at the ideal-matrix level; a finite alphabet such as Clifford+ usually needs an approximation stage.
Controlled Unitaries
Section titled “Controlled Unitaries”Let
be a one-control operation. For every , one can choose one-qubit gates , , and satisfying
For , a constructive choice is
The adjacent rotations cancel in . In , conjugation by reverses both rotation axes in , producing the desired Euler angles. This is the controlled-unitary construction of Barenco and colleagues.
Then, in matrix-product order,
On the control- block the two actions are absent and the target sees . On the control- block it sees . If , the missing phase is a phase gate on the control. It cannot be discarded as a global phase of the full controlled operation.
Worked example: controlled z rotation
Section titled “Worked example: controlled z rotation”Take
Because ,
Thus a controlled uses two CNOTs and two nontrivial target rotations in this exact continuous-angle construction. A later optimizer may merge either rotation with neighboring local gates. A target with a native controlled-phase family may use a different and cheaper decomposition.
Multiplexors and Uniformly Controlled Gates
Section titled “Multiplexors and Uniformly Controlled Gates”A multiplexed one-qubit operation has the block form
where control qubits select one of target operations. An ordinary controlled gate is the special case , . Uniformly controlled rotations restrict all to rotations about one axis with branch-dependent angles.
Gray-code constructions order control patterns so that only one control bit changes between adjacent branches. This turns a direct exponential collection of separately controlled gates into a regular network of one-qubit rotations and CNOTs. The size still grows exponentially with the number of independent branches, as it must for generic independent , but common structure and a residual diagonal factor can reduce constants.
For example, to select or using one control, set and . Apply to the target, in time order, , CNOT, , CNOT. The two control branches see respectively and , so they recover the specified angles. This small example explains how sums and differences of branch angles become ordinary gates.
Multiplexors are the bridge between block matrix factorizations and circuits. They are central to cosine–sine and Quantum Shannon decompositions, state preparation, and uniformly controlled rotation networks.
Two-Qubit Cartan Decomposition
Section titled “Two-Qubit Cartan Decomposition”Every can be written in a Cartan, or KAK, form
where
Here . The three Pauli products commute, so the nonlocal factor can also be written as three commuting exponentials. Using local symmetries and global phase, coordinates can be chosen in the region
Boundary points can still represent the same class; one may choose when to remove this remaining duplication. The coordinates describe local equivalence, not the amount of entanglement generated on every input. SWAP, for example, is nonlocal but preserves product states. Representative points include:
| Gate class | Canonical coordinates |
|---|---|
| local gate | |
| CNOT or CZ | |
| iSWAP | |
| SWAP |
Signs and chamber labels vary across references because authors choose different Pauli, exponential, magic-basis, and tensor-order conventions. A compiler should attach the convention to the coordinates rather than treating the triple as self-describing.
With arbitrary one-qubit gates and CNOT as the entangler, three CNOTs are necessary and sufficient for a generic two-qubit unitary. Special chamber subsets need zero, one, or two. This is a worst-case exact statement for that alphabet, not a claim that three of an arbitrary native entangler always suffice at the same local cost.
KAK algorithms extract these coordinates in a magic or Bell basis and recover the surrounding local factors. Degenerate eigenvalues at chamber boundaries make some factors nonunique. Check the reconstructed matrix in the original basis rather than demanding smoothness of every intermediate factor. Zhang and colleagues develop the geometry; Vidal–Dawson and Vatan–Williams give three-CNOT constructions.
Native Entanglers and Local Equivalence
Section titled “Native Entanglers and Local Equivalence”KAK coordinates separate two questions:
- Which nonlocal operation is needed?
- Which local basis changes surround it?
For example,
CNOT and CZ therefore have the same canonical nonlocal coordinates. A CZ-native target pays one entangler plus local basis changes rather than a three-CNOT generic construction.
For a parameterized native entangler , synthesis becomes a reachability problem in the Weyl chamber: choose parameters and interleaved local gates so that the composed canonical point reaches the target class. The shortest word depends on the native family, allowed parameter range, directionality, and whether inverse interactions are available. Calibration quality and crosstalk can change which exact word is preferable, but those device-state choices belong to error-aware compilation rather than the algebraic KAK theorem.
Dense Multiqubit Unitaries
Section titled “Dense Multiqubit Unitaries”The special efficiency of one- and two-qubit synthesis does not continue for a generic -qubit unitary. The Lie group has
real parameters. Without ancillary qubits or measurements, a circuit over arbitrary one-qubit gates and CNOTs can carry at most independent continuous parameters after redundant local degrees of freedom are removed. Therefore a generic exact circuit needs at least
CNOTs. For this gives three; for it gives fourteen. The parameter count does not prove that the lower bound is achievable at every , but it does establish exponential worst-case scaling.
Two classical matrix factorizations organize generic constructions.
QR and two-level elimination
Section titled “QR and two-level elimination”QR-style synthesis uses Givens rotations to eliminate matrix entries. Each Givens rotation is a two-level unitary: it acts nontrivially only on the span of two computational basis states. That two-level action is then implemented with controlled one-qubit gates and basis-state permutations.
This route is constructive and conceptually direct, but naively translating every eliminated entry can produce large multi-controlled networks. Gray-code ordering, ancillas, and shared-control simplifications improve the circuit.
Cosine–sine decomposition
Section titled “Cosine–sine decomposition”Partition a unitary into equal blocks. A cosine–sine decomposition has the form
where and are unitaries of half the dimension, while and are real diagonal matrices satisfying
The middle factor is a uniformly controlled rotation. The outer block-diagonal factors become multiplexors and are decomposed recursively. Quantum Shannon decomposition reorganizes this recursion to reduce CNOT counts. The construction of Shende, Bullock and Markov has leading CNOT count
while the parameter lower bound has leading coefficient . Both are : generic dense synthesis is exponentially large and cannot be made polynomial merely by choosing a clever universal alphabet.
The classical input is already exponential. A dense unitary contains complex entries, and stable factorization requires exponential memory and arithmetic. These generic algorithms are appropriate for small blocks, compiler validation, or genuinely unstructured targets. They are not a scalable way to compile an algorithm whose efficient structure was discarded.
Isometries and State Preparation
Section titled “Isometries and State Preparation”An isometry with obeys
Only orthonormal columns are prescribed. Completing them arbitrarily to a unitary and then invoking generic unitary synthesis solves a larger problem than necessary.
State preparation is the case : only the image of is fixed. A normalized pure state has real parameters after normalization and global phase, exponentially fewer than the parameters of a generic special unitary. Isometry-specific constructions exploit this gap and can also expose ancilla tradeoffs.
If an isometry is implemented by adding qubits in , only that input subspace is prescribed. The remaining columns can be chosen to reduce cost. This freedom does not permit losing relative phases between specified columns: an isometry must act correctly on their superpositions.
Worked Decomposition: A Pauli-String Rotation
Section titled “Worked Decomposition: A Pauli-String Rotation”Let
and let be the number of nonidentity factors. The target is
Choose a local basis change such that
One valid choice on the support is for , for , and for .
Select one support qubit as a parity target. Let be a ladder of CNOTs from every other support qubit into . Conjugation gives
Functional calculus then yields the circuit identity
With all-to-all interactions, the complete compute–uncompute sequence uses CNOTs: to compute parity and to uncompute it. Connectivity can require routing; several adjacent Pauli rotations can share or cancel parity work; and a target with native Pauli interactions may avoid the ladder. Those are later optimization and mapping decisions. The identity above is exact for the stated rotation convention.
For a basis string, the target stores the parity of all support bits. Its eigenvalue is for even parity and for odd parity. Applying the rotation therefore multiplies these two sectors by and . Uncomputing restores the original bits while retaining that relative phase.
Read the circuit from left to right. For , four CNOTs compute and erase the parity while supplies its phase. The dashed division marks the moment when the bottom bit is ; all three bits return to their initial values at the output.
If , then and is a global phase. No parity target exists. Discard the phase only in a phase-insensitive setting; after adding a control it becomes a phase gate on that control.
Ancillas are unnecessary for this construction. If an ancilla-assisted variant is used, a clean ancilla must return to , while a dirty ancilla must return to its unknown input state, including its correlations with any external reference. Leaving residual entanglement is not deallocation.
Exact and Approximate Finite-Alphabet Synthesis
Section titled “Exact and Approximate Finite-Alphabet Synthesis”A continuous alphabet containing arbitrary rotations has uncountably many parameter values. A finite alphabet has only countably many finite words, so a generic continuous target cannot be synthesized exactly. The compiler must first ask whether the target belongs to the exactly synthesizable subgroup.
For the one-qubit Clifford+ alphabet, exact synthesis is characterized by matrix entries in
under the standard phase convention. Efficient exact algorithms can produce optimal or tightly controlled counts for this algebraic domain. For multiple qubits, Giles and Selinger prove that the same ring condition is necessary and sufficient when at most one ancillary qubit initialized and restored to is allowed. Without that ancilla, further determinant restrictions can matter.
A generic does not satisfy that ring condition and must be approximated. Number-theoretic Clifford+ synthesis for one-qubit rotations achieves, in the typical ancilla-free case,
This is a typical-case scaling, not a uniform guarantee for every angle and tolerance. Ross and Selinger give exact optimality with a factoring oracle, and near-optimality under a stated number-theoretic hypothesis without one; their worst cases have a leading coefficient four rather than three. This is much closer to the logarithmic information-theoretic lower scaling than a generic Solovay–Kitaev construction. The Universal Gate Sets page states the Solovay–Kitaev assumptions and explains why the theorem is a general fallback rather than an optimal compiler for every structured alphabet.
Allocate Approximation Error
Section titled “Allocate Approximation Error”Suppose a structural decomposition exposes rotations and rotation is approximated to operator-norm error . The telescoping bound derived on Universal Gate Sets gives the sufficient condition
Equal allocation is simple but not always cost optimal. If the synthesis model for rotation is
for , minimizing the continuous cost under a saturated linear budget gives the interior solution
The formula follows from a Lagrange multiplier and says that a rotation whose precision is more expensive receives a larger share of the allowed error. Integer gate counts, shared subcircuits, error cancellation, and physical noise make real allocation discrete and target dependent, but the calculation is a useful baseline.
An exact rewrite of the synthesized circuit preserves its matrix and hence the existing error bound. An additional approximate rewrite spends more of the tolerance. If phase is ignored, the rewrite must preserve equality in the same phase-insensitive setting. Bounds remain valid after exact cancellation even when their per-gate decomposition is no longer visible.
Checking a synthesized circuit
Section titled “Checking a synthesized circuit”For a small circuit, multiply its matrices in the stated time and tensor order and form . Exact agreement up to phase means that is a scalar multiple of the identity. If , the angle
minimizes the Frobenius residual . It need not minimize the operator norm, even when is very close to . For a worst-case tolerance, evaluate that norm at the chosen phase to obtain an upper bound, or minimize it directly. For unitary with eigenvalues ,
Thus the problem is to cover the eigenvalues on the unit circle with the smallest chord radius about a phase point. A small average infidelity cannot replace this worst-case check. Floating-point multiplication supplies a numerical residual; a rigorous tolerance also needs control of rounding.
Large circuits need algebraic identities, compact invariants or a suitable equivalence checker. Testing random states can reveal mistakes but cannot establish the action on every input. Check the allowed ancilla subspace and output ordering as well as the gate product. Connectivity and physical noise are separate questions, developed in routing and error-aware compilation.
Exercises
Section titled “Exercises”1. Verify the controlled rotation construction
Section titled “1. Verify the controlled rotation construction”For
verify the control- and control- blocks of the two-CNOT construction.
Solution
On control , both CNOTs act trivially on the target, so the target product in matrix order is
On control , each CNOT contributes . Using ,
The full operation is therefore .
2. Derive a two-qubit ZZ rotation
Section titled “2. Derive a two-qubit ZZ rotation”Show that
Solution
CNOT is self-adjoint and conjugates the target Pauli as
For any unitary and operator ,
Since , conjugating it by CNOT gives the claimed identity. The construction uses two CNOTs and one rotation before any neighboring-gate optimization.
3. Apply the parameter lower bound
Section titled “3. Apply the parameter lower bound”Evaluate the CNOT parameter-count lower bound for generic unitaries on two, three, and four qubits.
Solution
Use
Therefore
For , . These are generic lower bounds from continuous parameter counting, not constructive gate counts for every unitary.
4. Use local equivalence
Section titled “4. Use local equivalence”Prove that CNOT and CZ need the same number of entanglers on a target where arbitrary one-qubit gates are free and CZ is native.
Solution
Hadamard exchanges and , so
Thus each CNOT can be replaced by one CZ and two local Hadamards, and the inverse replacement is identical. The gates lie in the same KAK local equivalence class . They have equal entangler count under the stated model, though duration or one-qubit cost can differ on real hardware.
5. Find the phase that becomes observable
Section titled “5. Find the phase that becomes observable”Let . Compare and and show that their difference is not generally a global phase on the joint system.
Solution
The controlled operations are
Only the control- block acquires the phase. Indeed,
This is a relative phase between control branches unless . A phase-insensitive isolated-gate certificate therefore cannot be reused unchanged after adding a control.
6. Allocate an unequal error budget
Section titled “6. Allocate an unequal error budget”Three rotations have asymptotic costs
Minimize their continuous total cost subject to .
Solution
Introduce a multiplier :
Stationarity gives
so . Summing the errors gives and therefore
The most precision-expensive rotation receives the largest allowed error. Integer word lengths can shift the discrete optimum.
7. Count state-preparation parameters
Section titled “7. Count state-preparation parameters”Why can state preparation require asymptotically fewer parameters than a generic unitary? Count the real degrees of freedom in both cases.
Solution
A complex state vector in dimension has real components. Normalization removes one degree of freedom and global phase removes another, leaving
A generic element of has
real parameters. State preparation fixes one output ray rather than every column of a unitary, so completing the remaining columns and synthesizing them solves an exponentially larger problem than the source contract requires.
8. Construct a Pauli-string rotation
Section titled “8. Construct a Pauli-string rotation”A compiler synthesizes using qubit as the parity target. Give valid local basis changes and the all-to-all CNOT count before optimization.
Solution
Choose
These map to by conjugation. Compute parity into qubit with CNOTs and , apply , undo the two CNOTs in reverse order, and undo the basis changes. The support weight is , so the decomposition uses
CNOTs before cancellation, routing, or native-interaction substitution.
9. Compare average and worst-case phase alignment
Section titled “9. Compare average and worst-case phase alignment”Let with . Find the operator-norm minimizing phase and compare it with when is small.
Solution
The distinct eigenvalues lie at the ends of an arc of length . Its midpoint balances their chord distances, so
In contrast, . The three repeated eigenvalues pull the Frobenius optimum toward zero; multiplicity does not change the maximum distance. Its operator residual is approximately , compared with at the optimum. The distinction persists arbitrarily near the identity.
References
Section titled “References”- A. Barenco et al., “Elementary gates for quantum computation,” Physical Review A 52, 3457–3467 (1995), doi:10.1103/PhysRevA.52.3457.
- V. Bergholm, J. J. Vartiainen, M. Möttönen, and M. M. Salomaa, “Quantum circuits with uniformly controlled one-qubit gates,” Physical Review A 71, 052330 (2005), doi:10.1103/PhysRevA.71.052330.
- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press (2010), doi:10.1017/CBO9780511976667.
- G. Vidal and C. M. Dawson, “A universal quantum circuit for two-qubit transformations with three CNOT gates,” Physical Review A 69, 010301(R) (2004), doi:10.1103/PhysRevA.69.010301.
- N. Khaneja and S. J. Glaser, “Cartan decomposition of and control of spin systems,” Chemical Physics 267, 11–23 (2001), doi:10.1016/S0301-0104(01)00318-4.
- R. Iten, R. Colbeck, I. Kukuljan, J. Home, and M. Christandl, “Quantum circuits for isometries,” Physical Review A 93, 032318 (2016), doi:10.1103/PhysRevA.93.032318.
- V. Kliuchnikov, D. Maslov, and M. Mosca, “Fast and efficient exact synthesis of single-qubit unitaries generated by Clifford and gates,” Quantum Information and Computation 13, 607–630 (2013), arXiv:1206.5236.
- S. S. Bullock and I. L. Markov, “Asymptotically optimal circuits for arbitrary -qubit diagonal computations,” Quantum Information and Computation 4, 27–47 (2004), arXiv:quant-ph/0303039.
- M. Möttönen, J. J. Vartiainen, V. Bergholm, and M. M. Salomaa, “Quantum circuits for general multiqubit gates,” Physical Review Letters 93, 130502 (2004), doi:10.1103/PhysRevLett.93.130502.
- C. M. Dawson and M. A. Nielsen, “The Solovay–Kitaev algorithm,” Quantum Information and Computation 6, 81–95 (2006), arXiv:quant-ph/0505030.
- B. Giles and P. Selinger, “Exact synthesis of multiqubit Clifford+ circuits,” Physical Review A 87, 032332 (2013), doi:10.1103/PhysRevA.87.032332.
- N. J. Ross and P. Selinger, “Optimal ancilla-free Clifford+ approximation of -rotations,” Quantum Information and Computation 16, 901–953 (2016), arXiv:1403.2975.
- P. Selinger, “Efficient Clifford+ approximation of single-qubit operators,” Quantum Information and Computation 15, 159–180 (2015), arXiv:1212.6253.
- V. V. Shende, I. L. Markov, and S. S. Bullock, “Minimal universal two-qubit controlled-NOT-based circuits,” Physical Review A 69, 062321 (2004), doi:10.1103/PhysRevA.69.062321.
- V. V. Shende, S. S. Bullock, and I. L. Markov, “Synthesis of quantum-logic circuits,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 25, 1000–1010 (2006), doi:10.1109/TCAD.2005.855930.
- F. Vatan and C. Williams, “Optimal quantum circuits for general two-qubit gates,” Physical Review A 69, 032315 (2004), doi:10.1103/PhysRevA.69.032315.
- J. Zhang, J. Vala, S. Sastry, and K. B. Whaley, “Geometric theory of nonlocal two-qubit operations,” Physical Review A 67, 042313 (2003), doi:10.1103/PhysRevA.67.042313.