9

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?

glS
  • 24,708
  • 5
  • 34
  • 108
Dani007
  • 532
  • 2
  • 9
  • 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. – narip Jun 28 '21 at 04: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. – DaftWullie Jun 28 '21 at 08: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? – narip Jun 28 '21 at 10:34

1 Answers1

8

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.

Egretta.Thula
  • 9,972
  • 1
  • 11
  • 30
  • Thanks, this is very helpful! Do you think there is a detailed overview of the Qiskit comilation/transpilation process somewhere? Here is one https://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. – Nikita Nemkov Jun 28 '21 at 10:35
  • Glad to help. My main source is the code, including this answer. – Egretta.Thula Jun 28 '21 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. – Andreas Burger Aug 22 '22 at 00:57