I want to use the Qiskit transpile function to decompose an arbitrary unitary matrix/ quantum circuit into a special kind of basis gates.
(from qiskit.compiler import transpile
)
But for me it seems the only accepted basis gates are 'u1', 'u2', 'u3' and 'cx'. Is there a way to use for example 'rx', 'ry' and 'cx' as basis gates instead of 'u1', 'u2', 'u3' and 'cx'?
The following error
Exception has occurred: QiskitError "Cannot unroll the circuit to the given basis, ['id', 'ry', 'rx', 'cx']. No rule to expand instruction h."
for example is obtained from the code:
from qiskit.quantum_info import Operator
from qiskit.compiler import transpile
import matplotlib.pyplot as plt
from qiskit.compiler.transpile import CouplingMap
coupling_string = [[0, 1], [0,2], [1,2]]
CM = CouplingMap(coupling_string)
qc = QuantumCircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
result = transpile(qc, coupling_map=CM, basis_gates=['id', 'ry', 'rx', 'cx'], optimization_level=1, seed_transpiler=1)
result.draw(output='mpl')
plt.show()