# How efficient is Qiskit's unitary decomposition?

In Qiskit's extension package we have the UnitaryGate module that you can initialize using a unitary matrix and then add it to your circuit. How efficiently is this decomposition done under the hood?

Also, if I wanted to do the decomposition myself, what's the best way of doing so?

• Some basic information might be useful: Nielsen's chap 4(the part of general gates), and Solovay-Kitaev's algorithm. There is also some reinforce-learning way for gate decomposition, such as this paper. While I am also curious about the complexity lower bound of the problem. Jun 28, 2021 at 4:51
• @narip Solovay-Kitaev is largely irrelevant here. There, you're trying to decompose a gate from a finite gate set. In Qiskit, the rotations have a continuous parameter available to them. Jun 28, 2021 at 8:34
• @DaftWullie But does the problem mean that UnitaryGate(A) can add any unitary matrix $A$ into the circuit? So with the help of the UnitaryGate() function, we may have any unitary matrix at hand? Jun 28, 2021 at 10:34

## 1 Answer

For 2x2 unitary, it is just a U3-gate.

For 4x4 unitary, TwoQubitBasisDecomposer is used. TwoQubitBasisDecomposer implements KAK decomposition method described in arXiv:0806.4015 by Drury and Love. This method uses optimal number of CNOT gates.

For larger unitaries, Isometry class is used. This class implements the method introduced by Iten et al. in arXiv:1501.06911. This method achieves the theoretical lower bound on the number of used CNOT gates.

Update: In Qiskit version 0.37 a new module qiskit.quantum_info.synthesis.qsd is added to apply Quantum Shannon Decomposition of arbitrary unitaries. This functionality replaces the previous isometry-based approach.

The Quantum Shannon Decomposition (arXiv:quant-ph/0406176) uses about half the CNOT gates as the isometry implementation when decomposing unitary matrices of greater than two qubits.

• Thanks, this is very helpful! Do you think there is a detailed overview of the Qiskit comilation/transpilation process somewhere? Here is one qiskit.org/documentation/apidoc/transpiler.html but it is quite brief. Currently the bits and pieces that I pick from scattered posts on QC.SE are my main sources. Jun 28, 2021 at 10:35
• Glad to help. My main source is the code, including this answer. Jun 28, 2021 at 14:59
• Do you know which method the Isometry class in Qiskit uses? The cited paper by Iten et al. presents 3 methods: Knill, Column-by-column (CCD), Cosine-Sine (CSD). By the source code it looks to me like they use CCD, but I am not sure. Aug 22, 2022 at 0:57