Learn how to use the qBraid-SDK to submit quantum circuits to IonQ’s simulators and quantum computers.
ionq
extra from PyPI using pip:
python --version
from the command line.IONQ_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.
IonQProvider
to list all of the devices to which you have access:
result.data.get_probabilities()
.
You can return histogram data in decimal format for either of these result.data
methods using argument decimal=True
.
ONLINE
:
device.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:
preflight=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:
qasm2
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:
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.
IonQDevice
. For example: