# 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 '21 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 '21 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 '21 at 10:34

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.