Integration Guide#
IQM client is designed to be the Python adapter to IQM’s quantum computers for application-level quantum computing frameworks. For example integrations maintained by IQM, please refer to the Qiskit and Cirq packages.
IQM client offers the functionality to submit quantum circuits to an IQM quantum computer, query a job or a job status, and retrieve the quantum architecture of the quantum computer.
The following sections illustrate how to integrate IQM quantum computers into your quantum computing framework.
Code example#
Initialising the IQM client is simple, and in case you perform authentication as described below, requires only the URL of the IQM quantum computer.
from iqm.iqm_client import IQMClient
server_url = "https://IQM_SERVER_URL/station"
iqm_client = IQMClient(server_url)
To submit a quantum circuit for execution, it has to be specified using the
iqm.pulse.Circuit class. The available native instructions are documented in
iqm.iqm_client.models and in iqm.pulse.CircuitOperation.
from math import pi
from iqm.pulse.builder import CircuitOperation
from iqm.pulse.circuit_operations import Circuit
instructions = (
    CircuitOperation(
        name="prx", locus=("QB1",), args={"phase": 1.4 * pi, "angle": 0.5 * pi}
    ),
    CircuitOperation(name="cz", locus=("QB1", "QB2"), args={}),
    CircuitOperation(name="measure", locus=("QB2",), args={"key": "Qubit 2"}),
)
circuit = Circuit(name="quantum_circuit", instructions=instructions)
Then the circuit can be submitted, and its status and result can be queried with the job id.
job_id = iqm_client.submit_circuits([circuit])
job_status = iqm_client.get_run_status(job_id)
job_result = iqm_client.wait_for_results(job_id)
A dict containing arbitrary metadata can be attached to the circuit before submitting it for
execution. The attached metadata should consist only of values of JSON serializable datatypes.
A utility function to_json_dict() can be used to convert supported datatypes,
e.g. numpy.ndarray, to equivalent JSON serializable types.
The progress of the job can be followed with IQMClient.get_run_status(). Once the job is ready,
the results can be read with IQMClient.get_run(). Both of these actions are combined in
IQMClient.wait_for_results() which waits until the job is ready and then returns the result.
In addition to the actual results, job result contains also metadata of the job execution. The metadata includes the original request, ID of the calibration set used in the execution, and a collection of timestamps describing the duration of the execution.
Authentication#
IQM uses bearer token authentication to manage access to quantum computers.
Get your personal token from the web dashboard. The generated token can be provided to IQM
client via an environment variable IQM_TOKEN.
Alternatively, the token can be provided as argument token to IQMClient constructor.
Circuit transpilation#
IQM does not provide an open source circuit transpilation library, so this will have to be supplied
by the quantum computing framework or a third party library.  To obtain the necessary information
for circuit transpilation, IQMClient.get_dynamic_quantum_architecture() returns the names of the
QPU components (qubits and computational resonators), and the native operations available
in the given calibration set. This information should enable circuit transpilation for the
IQM Crystal quantum architectures.
The notable exception is the transpilation for the IQM Star quantum architectures, which have
computational resonators in addition to qubits. Some specialized transpilation logic involving
the MOVE gates specific to these architectures is provided, in the form of the functions
transpile_insert_moves() and transpile_remove_moves().
See iqm.iqm_client.transpile for the details.
A typical Star architecture use case would look something like this:
from iqm.iqm_client import IQMClient, simplify_architecture, transpile_insert_moves, transpile_remove_moves
from iqm.pulse.circuit_operations import Circuit
client = IQMClient(URL_TO_STAR_SERVER)
dqa = client.get_dynamic_quantum_architecture()
simplified_dqa = simplify_architecture(dqa)
# circuit valid for simplified_dqa
circuit = Circuit(name="quantum_circuit", instructions=[...])
# intended use
circuit_with_moves = transpile_insert_moves(circuit, dqa)
client.submit_circuits([circuit_with_moves])
# back to simplified dqa
circuit_without_moves = transpile_remove_moves(circuit_with_moves)
assert circuit == circuit_without_moves
Note on qubit mapping#
We encourage to transpile circuits to use the physical IQM qubit names before submitting them to IQM quantum computers. In case the quantum computing framework does not allow for this, providing a qubit mapping can do the translation from the framework qubit names to IQM qubit names. Note, that qubit mapping is not supposed to be associated with individual circuits, but rather with the entire job request to IQM server. Typically, you would have some local representation of the QPU and transpile the circuits against that representation, then use qubit mapping along with the generated circuits to map from the local representation to the IQM representation of qubit names. We discourage exposing this feature to end users of the quantum computing framework.
Note on circuit duration check#
Before performing circuit execution, IQM server checks how long it would take to run each circuit.
If any circuit in a job would take too long to execute compared to the T2 time of the qubits,
the server will disqualify the job, not execute any circuits, and return a detailed error message.
In some special cases, it makes sense to adjust or disable this check using
the max_circuit_duration_over_t2 attribute of CircuitCompilationOptions,
and then passing the options to IQMClient.submit_circuits().
Note on environment variables#
Set IQM_CLIENT_REQUESTS_TIMEOUT environment variable to override the network requests default
timeout value. The default value is 60 seconds and might not be sufficient when fetching run results
of larger circuits via slow network connections.
On Linux:
$ export IQM_CLIENT_REQUESTS_TIMEOUT=120
On Windows:
set IQM_CLIENT_REQUESTS_TIMEOUT=120
Once set, this environment variable will control network request timeouts for IQMClient methods
abort_job, get_quantum_architecture, get_dynamic_quantum_architecture, get_run, and get_run_status.
Set IQM_CLIENT_SECONDS_BETWEEN_CALLS to control the polling frequency when waiting for
compilation and run results with the IQMClient.wait_for_compilation() and
IQMClient.wait_for_results() methods. The default value is set to 1 second.
Set IQM_CLIENT_DEBUG=1 to print the run request when it is submitted for execution in
IQMClient.submit_circuits() or IQMClient.submit_run_request(). To inspect the run request without sending
it for execution, use IQMClient.create_run_request().
Integration testing#
IQM provides a demo environment to test the integration against a mock quantum computer. If you’d like to request access to that environment, please contact IQM.
