In qiskit
, I can transpile a given circuit into a some predefined gate set as follows (just an example)
from qiskit import QuantumCircuit
from qiskit.compiler import transpile
from qiskit.circuit.random import random_circuit
basis_gates = ['id', 'u3', 'cx']
qc = random_circuit(3, 1, seed=0)
qc_trans = transpile(qc, basis_gates=basis_gates)
I have several related questions.
- Where can I find an exhaustive list of operators allowed as
basis_gates
? - For any operator label from the list of allowed basis gates, how can I find the precise meaning of the corresponding gate, say as a matrix representation?
- Most importantly, can I add my own custom gates to use as basis gates? Can I add parametric gates? For examples as far as I can tell
qiskit
standard tools includeRxz
andRyz
gates but noRxy
gate. Can I make one?
Example of a (trivial) transpilation into custom gate set failing
from qiskit import QuantumCircuit
from qiskit.compiler import transpile
qc = QuantumCircuit(2, name='mycx')
qc.cx(0, 1)
mycx = qc.to_gate()
qc = QuantumCircuit(2)
qc.cx(0, 1)
transpile(qc, basis_gates=['id','mycx'])
gives me a TranspileError
.