What is qBraid?
The qBraid-SDK is an open-source Python framework providing a complete, platform-agnostic quantum runtime solution. Distinguishing itself through a streamlined and highly-configurable approach to cross-platform integration, the qBraid-SDK does not adhere to a fixed circuit-building library or quantum program representation. Instead, it allows clients to dynamically register and submit quantum programs of any type compatible with the architecture of the target device. This flexibility extends to customizable pipelines for program validation, transpilation, and compilation. The qbraid.runtime.IonQProvider provides support for IonQ’s trapped-ion systems. This means that you can write quantum circuits in Qiskit, Cirq, Amazon Braket, PennyLane, PyTKET, or any other library compatible with OpenQASM (version 2 or 3), and run them on IonQ’s simulators and trapped-ion quantum computers, all from within the qBraid Runtime framework.Getting started
Before you begin, make sure you have an IonQ Quantum Cloud account and API key. For help, see our guide on creating and managing API keys.Set up the qBraid-SDK
Install qBraid with theionq extra from PyPI using pip:
Note: The qBraid-SDK requires Python 3.10 or greater. You can check your
Python version by running
python --version from the command line.Set up your environment
By default, qBraid will look in your local environment for a variable namedIONQ_API_KEY, so if you’ve already followed our guide on
setting up and managing your API keys, qBraid will automatically find it.
Alternatively, you can set a “temporary” environment variable from your command line:
IONQ_API_KEY, or if you are working from a Python environment
where accessing environment variables is not straightforward. You can import your key explicitly or load it from a file, and pass it into
the IonQProvider() object directly:
IonQProvider() initialized with no arguments and assume that qBraid will automatically find your API key,
but you can always use this approach instead.
List available devices
Use theIonQProvider to list all of the devices to which you have access:
Submit a circuit to the simulator
First, let’s try running a simple Bell state circuit on the ideal simulator. Here, we’ll use 1000 shots, and give the circuit a name that will show up in the IonQ Cloud Console.result.data.get_probabilities().
You can return histogram data in decimal format for either of these result.data methods using argument decimal=True.
Submit a circuit with noise
Get a list of all noise models supported by the IonQ simulator:Submit a circuit to a QPU
You can view your access to IonQ systems in the “Backends” tab of the IonQ Cloud Console. Before submitting to any QPU, we recommend testing your code on a simulator (including with noise model) and following the other steps in the QPU submission checklist to confirm your access and the QPU availability. To run a circuit on a QPU, use the same setup as before, just with a different device ID:ONLINE:
Estimate Cost
You can use thedevice.run() method with the preflight=True option to obtain a cost estimate for the anticipated job
without actually executing the program on a QPU.
error_mitigation parameter in the preflight submission to ensure it is accounted for in the cost estimate:
Submit to QPU
When you are ready to submit the job on the QPU, simply setpreflight=False, or don’t specify any preflight value.
Optionally include job tags or other metadata for your convenience, specifying up to 10 key-value pairs.
COMPLETED, you can retrieve the results:
Submit a multicircuit job
The flexibility of qBraid-SDK allows you to write your circuit not just in OpenQASM, but in Qiskit, Cirq, Amazon Braket, PyTKET, or any other registered program type that can be transpiled to qBraid’sqasm2 or qasm3 format.
In this example, we’ll install the qiskit and cirq extras,
device.run() method. However, you can also perform
this “transpile” step manually, if needed (e.g. to inspect the ultimate OpenQASM submission format). This can be done as follows:
Manage jobs
Retrieve a job
You can retrieve results for a previously run job using its job ID. You can save the job ID after submitting a job (as in the QPU example above) or copy it from the “ID” column in the “My Jobs” tab on the IonQ Cloud Console.Cancel a job
You can cancel a job while it’s waiting in the queue:Visualize Results
To plot the results of a job, first, install the qBraid visualization extra:plot_histogram, or display the probability distribution with plot_distribution.
decimal=True when retrieving measurement
counts with get_counts(). If decimal=False or left unspecified, the default quantum state labels in hexadecimal will be used.
See Plot Experimental Results for more.
Supported gates
For actual execution, gates will be compiled into optimal operations for our trapped ion hardware. For convenience, IonQ provide a more expressive gateset for programming. However, not all gates supported by the OpenQASM 3 standard library are accepted by IonQ backends. See full list of supported gates. You can also view a list of the OpenQASM gates supported by a given device directly from anIonQDevice. For example:

