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?

  • $\begingroup$ 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. $\endgroup$ – narip Jun 28 at 4:51
  • $\begingroup$ @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. $\endgroup$ – DaftWullie Jun 28 at 8:34
  • $\begingroup$ @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? $\endgroup$ – narip Jun 28 at 10:34

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.

  • $\begingroup$ 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. $\endgroup$ – Weather Report Jun 28 at 10:35
  • $\begingroup$ Glad to help. My main source is the code, including this answer. $\endgroup$ – Egretta.Thula Jun 28 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.