It's well known that the single-qubit rotation gate $U(\theta, \phi, \lambda)$ and the controlled-not gate $CX_{i,j}$ form one of the universal set of gates for quantum computation. So here's my question: is the Qiskit transpile
function able to compile any given quantum circuit by using u
and cx
gates only?
In particular, I would assume that the following code will always work with no errors:
from qiskit.circuit.random import random_circuit
from qiskit.compiler import transpile
qc = random_circuit(num_qubits=5, depth=10)
tqc = transpile(qc, basis_gates=['u', 'cx'])
Unfortunately, it would seem not to be so and I was wondering why. I also noticed that, if I add the identity gate id
in the list of basis_gates
, the transpilation looks to always run successfully and I'm not sure about the reason for this.
The error produced by qiskit is:
QiskitError: "Cannot unroll the circuit to the given basis, ['u', 'cx'].
Instruction id not found in equivalence library and no rule found to expand."
random_circuit(num_qubits=5, depth=10, seed=1)
: you should be able to reproduce the issue (I'm using Qiskit Terra version 0.22.3). $\endgroup$