3
$\begingroup$

Does anyone know of a web site, paper etc. that has a list of "gate decompositions" e.g. the kind of decompositions that occur when the transpiler decomposes non-native gates to native gates.

This document is really nice and has some decompositions, but I'm looking for a kind of summary.

$\endgroup$
2
  • $\begingroup$ Generally, a transpiler has a list of target gates that it is compiling to. Do you have a specific set of target gates in mind? $\endgroup$ Dec 7, 2022 at 0:37
  • $\begingroup$ @FrankYellin No, I am not targetting a specific architecture (yet) - at present I'm just looking for general gate decomps/identities for long term reference. $\endgroup$
    – John
    Dec 7, 2022 at 1:08

1 Answer 1

4
$\begingroup$

You can use Qiskit's StandardEquivalenceLibrary to get a list of gate decompositions.

StandardEquivalenceLibrary is an instance of EquivalenceLibrary class. It is used by Qiskit's during transpilation to translate the circuit gates to the target basis. Currently, it contains 80+ equivalences.

You can easily generate a nice image for these equivalences as follows:

from qiskit.circuit.library.standard_gates.equivalence_library import StandardEquivalenceLibrary
   
StandardEquivalenceLibrary.draw('equivalence_library.png')

If, however, you need a simple list, you can generate it using this code snippet:

keys = StandardEquivalenceLibrary.keys()

sorted_keys = { 1: [], 2: [], 3: [] }
for key in keys:
    sorted_keys[key[1]].append(key)

sorted_keys[1].sort()
sorted_keys[2].sort()
sorted_keys[3].sort()

for num_qubits in sorted_keys:
    for key in sorted_keys[num_qubits]:
        print("{} ({} qubits)".format(key.name, key.num_qubits))
        equivalences = StandardEquivalenceLibrary._get_equivalences(key)
        for equivalence in equivalences:
            display(equivalence.circuit.draw('mpl'))

Here is a part of the result:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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