This guide includes how to use IonQ’s native gates in Qiskit. To learn more about what the native gates are and when to use them, refer to our guide on getting started with native gates.
Introduction
IonQ backends accept circuits defined in either a standard set of QIS gates (Hadamard, CNOT, Rx, etc.) or in our hardware-native gateset. This guide covers:- How to convert from other Qiskit gates and instructions into IonQ-supported QIS gates using
qiskit.transpile()
- How to convert from standard QIS gates into IonQ’s native gateset using
qiskit.transpile()
- How to build a circuit directly in IonQ’s native gates
Native gates are an advanced-level feature. Using the hardware-native gate interface without a thorough understanding of quantum circuits is likely to result in less-optimal circuit structure and worse algorithmic performance overall than using our abstract gate interface.
Transpiling to supported QIS gates
The IonQ Quantum Cloud API accepts a specific set of QIS gates, including the gates listed in this table as well as their controlled and multi-controlled variants. In many cases, gates in Qiskit’s circuit library will automatically be converted to the equivalent IonQ syntax. However, more complex abstractions and gate operations in Qiskit’s library may not be directly accepted by IonQ backends. Trying to submit these would give anIonQGateError
. In these cases, you can use Qiskit’s transpile()
function to convert to IonQ’s supported QIS gateset before submission.
For example, here’s a circuit using Qiskit’s UnitaryGate:
.measure_all()
to the UnitaryGate example in Qiskit’s documentation, since IonQ backends require explicit measurement.)
If we submitted this circuit directly to an IonQ backend, we’d get an error:
Transpilation warnings
In Qiskit versions newer than 1.3.0, the defaultoptimization_level
used in transpile()
is set to 2 instead of 1. With an optimization level of 2 or 3, Qiskit may perform transpiler passes that are not compatible with the further optimization performed by IonQ’s compiler, resulting in a significant net reduction in efficiency and overall performance. If you’re using Qiskit’s transpiler to convert to supported QIS gates before submitting to IonQ backends, we recommend always using optimization level 0 or 1. This provides a better starting point for IonQ’s compiler and our hardware-specific circuit optimizations.
Depending on your Qiskit version and its default optimization level, versions of the IonQ Provider for Qiskit (qiskit-ionq package) newer than 1.0.2 may alert you to this potential issue by showing an IonQTranspileLevelWarning
when creating an IonQProvider or retrieving an IonQ backend. Performance will only be affected if you are using Qiskit’s transpilation before submitting your circuit to IonQ, but in those cases we strongly recommend using optimization level 0 or 1 by passing optimization_level=0
to transpile()
. You may also change the default value in your Qiskit user configuration file.
Additionally, in some versions of Qiskit (1.0.3 through 1.4.x) and the IonQ Provider, you may see warnings like RuntimeWarning: No gate definition for [gate] can be found...
. Transpilation in these situations may be unreliable, and we recommend upgrading to Qiskit >2.0 and qiskit-ionq >1.0 if possible. Otherwise, you may transpile to a list of basis gates (you may need more or different gates than the ones listed in this example) instead of a backend, which should ultimately give similar results when submitted:
Transpiling a circuit to native gates
Converting a circuit to either Forte-class (ZZ two-qubit gate) or Aria-class (MS two-qubit gate) native gates with Qiskit’s transpilation is supported as of v1.0.0 of the IonQ Provider for Qiskit. Support for transpilation to Aria-class native gates was previously available since v0.5.1. Start with the usual imports, plus Qiskit’stranspile()
method:

IonQProvider
and backend, using gateset="native"
. Qiskit’s transpiler can use the target gateset defined by this backend.
transpile()
method and the native-gates backend to convert the circuit to IonQ’s native gateset:

Building circuits with native gates
Native gate circuit construction is supported as ofv0.3.1
of the Qiskit IonQ Provider.
Gates are provided as part of the qiskit-ionq
package, including:
GPIGate(phi)
GPI2Gate(phi)
MSGate(phi0, phi1, theta=0.25)
for Aria systemsZZGate(theta)
for Forte systems
The parameters in the IonQ native gate specification are always defined in turns, not in radians. One turn is 2π radians.
circuit.append()
method:

qiskit.circuit.library
, but these gates are not equivalent to the IonQ native gates. To build a circuit in IonQ native gates, make sure you’re using the gates imported from qiskit_ionq
.
For a complete code example including circuit submission, skip to the full code examples below.
Submitting a circuit that uses native gates
Whether you built a circuit in native gates originally, or you built a circuit in abstract gates and transpiled it with Qiskit, you’ll need to submit it to an IonQ backend that was set up with the native gateset. Circuits submitted this way will bypass IonQ’s compiler and optimizer. Set up an IonQ backend and specify the native gateset: here, we’ll use the ideal simulator, but you can also use the noisy simulator or an IonQ QPU. This tells the backend to expect circuits defined in native gates, and to bypass IonQ’s compiler and optimizer. With the default setting,gateset="qis"
, the backend will expect circuits defined in abstract gates.
qc_native
, either by building it in native gates directly or building it in abstract gates and then transpiling it, you can submit it to the native gate backend:
Each quantum circuit submitted to the IonQ Cloud must use a consistent gateset throughout—you cannot mix and match native gates and abstract gates in the same circuit.