API Reference: qbraid.runtime.ionq

Installation & Setup

To interface with IonQ devices directly through the IonQ API, install the ionq extra:

pip install 'qbraid[ionq]'

To gain access to IonQ QPUs and/or simulators, you must obtain an IonQ API token.

Basic Usage

Now we can go through an example of using the IonQProvider to submit a job to an IonQ device.

from qbraid.runtime import IonQProvider

provider = IonQProvider(<YOUR_API_TOKEN>)

provider.get_devices()
# [<qbraid.runtime.ionq.device.IonQDevice('qpu.harmony')>,
#  <qbraid.runtime.ionq.device.IonQDevice('qpu.aria-1')>,
#  <qbraid.runtime.ionq.device.IonQDevice('qpu.aria-2')>,
#  <qbraid.runtime.ionq.device.IonQDevice('qpu.forte-1')>,
#  <qbraid.runtime.ionq.device.IonQDevice('simulator')>]

device = provider.get_device("simulator")

type(device)
# qbraid.runtime.ionq.device.IonQDevice

device.metadata()
# {'device_id': 'simulator',
#  'device_type': 'QPU',
#  'num_qubits': 29,
#  'status': 'ONLINE',
#  'queue_depth': None}

We choose to submit to the IonQ Simulator:

program = """
OPENQASM 3;
include "stdgates.inc";
qubit[2] q;
h q[0];
cx q[0], q[1];
"""
job = device.run(program, shots=10)

So now we have job which is of type IonQJob, which inherits from QuantumJob. To see the results, we can do the following:

res = job.result()

res.data.get_counts()
# {'00': 4, '11': 6}

See how to visualize these results in the Visualization section.