For the best results, please submit quantum programs in the ionq.circuit.v0 format, as demonstrated below.

In the compilation and optimization process, your submitted circuit will be converted to an equivalent, optimized circuit expressed in terms of IonQ’s native gates, which may involve combining or canceling out some operations. If you wish to guarantee that the quantum computer executes the exact series of operations that you define, please bypass our compiler and submit directly to our native gate interface.

For more examples and the full API specification for defining circuits, refer to the API reference.

To write a quantum program using Qiskit or another SDK, refer to our SDK guides.


Bell State

We can create a maximally entangled Bell state by applying a Hadamard gate to a single qubit, and applying a controlled-not gate to a second qubit.

Half of the time the second qubit will be measured as 0|0⟩, the other half will be measured as 1|1⟩.

{
    "format": "ionq.circuit.v0",
    "gateset": "qis",
    // The fields above are optional, as they are the default.
    "qubits": 2,
    "circuit": [
        {
        "gate": "h",
        "target": 0
        },
        {
        "gate": "cnot",
        "target": 1,
        "control": 0
        }
    ]
}

GHZ State

We can create a three qubit GHZ state by first applying a Hadamard gate to a single qubit, and then using it as the control qubit for a series of controlled-not gates.

{
    "qubits": 4,
    "circuit": [
        {
        "gate": "h",
        "target": 0
        },
        {
        "gate": "cnot",
        "control": 0,
        "target": 1
        },
        {
        "gate": "cnot",
        "control": 0,
        "target": 2
        },
        {
        "gate": "cnot",
        "control": 0,
        "target": 3
        }
    ]
    }

Toffoli gate

The Toffoli gate, or controlled-controlled-not gate, is a universal reversible logic gate. We can simply apply a cnot to our target qubit, with two control qubits provided via array.

{
    "qubits": 3,
    "circuit": [
        {
        "gate": "cnot",
        "target": 0,
        "controls": [1, 2]
        }
    ]
}

Supported Gates

For actual execution, gates will be compiled into optimal operations for our trapped ion hardware. For convenience, we provide a more expressive gateset for programming.

GateDescription
xPauli X gate
yPauli Y gate
zPauli Z gate
rxX-axis rotation
ryY-axis rotation
rzZ-axis rotation
hHadamard gate
notConvenient alias for Pauli-X gate
cnotConvenient alias for controlled-not gate
sS gate
siConjugate transpose of S gate
tT gate
tiConjugate transpose of T gate
vSquare root of not gate
viConjugate transpose of square-root-of-not gate
swapSwaps two qubits

Each operation in a circuit specifies a gate and a target qubit index (or a list of multiple targets). Rotation gates also specify a rotation in radians.

In addition, any gate can be expressed as a controlled gate by specifying a control qubit, or as its multi-controlled variant by specifying a list of up to seven controls (for any gate except swap). This can often be used to simplify the circuit’s description. In general, circuits expressed in fewer QIS gates will be further optimized for runtime, so using multi-controlled variants of gates is recommended.

Examples:

  • Hadamard gate: {"gate": "h", "target": 0}
  • Controlled-not gate: {"gate": "cnot", "target": 1, "control": 0}
  • Toffoli gate (multi-controlled not gate): {"gate": "cnot", "target": 0, "controls": [1, 2]}
  • Rx gate with π/2\pi/2 rotation: {"gate": "rx", "target": 0, "rotation": 1.5708}
  • Swap gate: {"gate": "swap", "targets": [0,1]}

For more examples and the full API specification for defining circuits, refer to the API reference.

Native Specification

For information about writing quantum programs using IonQ’s hardware-native gate set, refer to our guides on getting started with native gates and using native gates with the IonQ API.


Other Formats (experimental)

Support for submitting programs in QASM/OpenQASM and Quipper is currently experimental. If you use these languages, we will compile your code to a logically-equivalent representation using our Supported Gates. (For billing purposes, we’ll calculate your program’s resource requirements after it’s been compiled this way.)

OpenQASM

{
  "format": "openqasm",
  "data": "string"
}

QASM

{
  "format": "qasm",
  "data": "string"
}

Quipper

{
  "format": "quipper",
  "data": "string"
}

Is there a language format you’d like to see supported? Drop us a line and let us know.