API Reference: qbraid.runtime.ionq

Installation & Setup

Using IonQ provider is straightforward and requires no additional extras. Simply install the basic qbraid package, which already includes all necessary requirements:

pip install qbraid

However, to gain access to the IonQ devices, 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.ionq import IonQProvider
>>> provider = IonQProvider(<YOUR_API_TOKEN>)
>>> provider.get_devices()
>>> device = provider.get_device("simulator")
>>> type(device)
>>> 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 = """
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.measurements()
array([[0, 0],
       [1, 1],
       [1, 1],
       [1, 1],
       [0, 0],
       [0, 0],
       [0, 0],
       [1, 1],
       [1, 1],
       [1, 1]])

See how to visualize these results in the Visualization section.