I have a certain quantum circuit (qc) in qiskit. My goal is to see it transpiled in IonQ Native Gates, to see the qc that is effectively run on the hardware.
However, the Ionq basis gate set which I see by using qiskit is the following:
['ccx', 'ch', 'cnot', 'cp', 'crx', 'cry', 'crz', 'csx', 'cx', 'cy', 'cz', 'h', 'i', 'id', 'mcp', 'mcphase', 'mct', 'mcx', 'mcx_gray', 'measure', 'p', 'rx', 'rxx', 'ry', 'ryy', 'rz', 'rzz', 's', 'sdg', 'swap', 'sx', 'sxdg', 't', 'tdg', 'toffoli', 'x', 'y', 'z']
While reading the IonQ guides I see that their native gates are GPi, GPi2 and MS gates.
If I specify this as basis_gate in the transpile function of qiskit I get errors:
qiskit.transpiler.exceptions.TranspilerError: "Unable to map source basis {('x', 1), ('reset', 1), ('ccx', 3), ('measure', 1), ('cx', 2), ('ry', 1), ('barrier', 5)} to target basis {'reset', 'delay', 'gpi', 'snapshot', 'gpi2', 'ms', 'barrier', 'measure'} over library <qiskit.circuit.equivalence.EquivalenceLibrary object at 0x7f9f030ea580>."
Also, looking at the IonQ guide about their Native Gates (https://ionq.com/docs/getting-started-with-native-gates), they introduce the general algorithm they use to compile the qc in terms of IonQ Native Gates: it should work as follows:
- Decompose the gates used in the circuit so that each gate involves at most two qubits.
- Convert all easy-to-convert gates into RX, RY, RZ, and CNOT gates.
- Convert CNOT gates into XX gates using the decomposition described here and at the bottom of this section.
- For hard-to-convert gates, first calculate the matrix representation of the unitary, then use either KAK decomposition or the method introduced in this Phys, Rev. A. paper to implement the unitary using RX, RY, RZ and XX. Note that Cirq and Qiskit also have subroutines that can do this automatically, although potentially not optimally. See cirq.linag.kak_decomposition and qiskit.quantum_info.TwoQubitBasisDecomposer.
- Write RX, RY, RZ and XX into GPi, GPi2 and MS gates as documented above.
However also if I try to specify the set ['rx', 'ry', 'rz', 'xx'] as basis gate in the transpile I get:
qiskit.transpiler.exceptions.TranspilerError: "Unable to map source basis {('reset', 1), ('measure', 1), ('ry', 1), ('cx', 2), ('ccx', 3), ('barrier', 5), ('x', 1)} to target basis {'delay', 'reset', 'xx', 'barrier', 'rx', 'ry', 'snapshot', 'measure', 'rz'} over library <qiskit.circuit.equivalence.EquivalenceLibrary object at 0x7fa8b8ab14f0>."
Any hint about this? How can I see the quantum circuit as close as possible to what is run on an IonQ machine ?