iqm.iqm_client.iqm_client.IQMClient#
- class iqm.iqm_client.iqm_client.IQMClient(url, *, client_signature=None, token=None, tokens_file=None, auth_server_url=None, username=None, password=None)#
Bases:
object
Provides access to IQM quantum computers.
- Parameters:
url (str) – Endpoint for accessing the server. Has to start with http or https.
client_signature (Optional[str]) – String that IQMClient adds to User-Agent header of requests it sends to the server. The signature is appended to IQMClients own version information and is intended to carry additional version information, for example the version information of the caller.
token (Optional[str]) – Long-lived IQM token in plain text format. If
token
is given no other user authentication parameters should be given.tokens_file (Optional[str]) – Path to a tokens file used for authentication. If
tokens_file
is given no other user authentication parameters should be given.auth_server_url (Optional[str]) – Base URL of the authentication server. If
auth_server_url
is given alsousername
andpassword
must be given.username (Optional[str]) – Username to log in to authentication server.
password (Optional[str]) – Password to log in to authentication server.
Alternatively, the user authentication related keyword arguments can also be given in environment variables
IQM_TOKEN
,IQM_TOKENS_FILE
,IQM_AUTH_SERVER
,IQM_AUTH_USERNAME
andIQM_AUTH_PASSWORD
. All parameters must be given either as keyword arguments or as environment variables. Same combination restrictions apply for values given as environment variables as for keyword arguments.Methods
__del__
()_default_headers
()_retry_request_on_error
(request)This is a temporary workaround for 502 errors.
_validate_circuit_instructions
(architecture, ...)Validates that the instructions target correct qubits in the given circuits.
_validate_instruction
(architecture, instruction)Validates that the instruction targets correct qubits in the given architecture.
_validate_qubit_mapping
(architecture, circuits)Validates the given qubit mapping, if defined.
abort_job
(job_id, *[, timeout_secs])Abort a job that was submitted for execution.
Terminate session with authentication server if there was one created.
get_quantum_architecture
(*[, timeout_secs])Retrieve quantum architecture from server.
get_run
(job_id, *[, timeout_secs])Query the status and results of a submitted job.
get_run_status
(job_id, *[, timeout_secs])Query the status of a submitted job.
submit_circuits
(circuits, *[, ...])Submits a batch of quantum circuits for execution on a quantum computer.
wait_for_compilation
(job_id[, timeout_secs])Poll results until a job is either pending execution, ready, failed, aborted, or timed out.
wait_for_results
(job_id[, timeout_secs])Poll results until a job is either ready, failed, aborted, or timed out.
- submit_circuits(circuits, *, qubit_mapping=None, custom_settings=None, calibration_set_id=None, shots=1, max_circuit_duration_over_t2=None, heralding_mode=HeraldingMode.NONE)#
Submits a batch of quantum circuits for execution on a quantum computer.
- Parameters:
qubit_mapping (dict[str, str] | None) – Mapping of logical qubit names to physical qubit names. Can be set to
None
if allcircuits
already use physical qubit names. Note that thequbit_mapping
is used for allcircuits
.custom_settings (dict[str, Any] | None) – Custom settings to override default settings and calibration data. Note: This field should always be
None
in normal use.calibration_set_id (UUID | None) – ID of the calibration set to use, or
None
to use the latest oneshots (int) – number of times
circuits
are executed, value must be greater than zeromax_circuit_duration_over_t2 (float | None) – Circuits are disqualified on the server if they are longer than this ratio of the T2 time of the qubits. Setting this value to
0.0
turns off circuit duration checking. The default valueNone
instructs server to use server’s default value in the checking.heralding_mode (HeraldingMode) – Heralding mode to use during the execution.
- Returns:
ID for the created job. This ID is needed to query the job status and the execution results.
- Return type:
- get_run(job_id, *, timeout_secs=60.0)#
Query the status and results of a submitted job.
- Parameters:
- Returns:
result of the job (can be pending)
- Raises:
CircuitExecutionError – IQM server specific exceptions
HTTPException – HTTP exceptions
- Return type:
- get_run_status(job_id, *, timeout_secs=60.0)#
Query the status of a submitted job.
- Parameters:
- Returns:
status of the job
- Raises:
CircuitExecutionError – IQM server specific exceptions
HTTPException – HTTP exceptions
- Return type:
- wait_for_compilation(job_id, timeout_secs=900)#
Poll results until a job is either pending execution, ready, failed, aborted, or timed out.
- Parameters:
- Returns:
job result
- Raises:
APITimeoutError – time exceeded the set timeout
- Return type:
- wait_for_results(job_id, timeout_secs=900)#
- Poll results until a job is either ready, failed, aborted, or timed out.
Note, that jobs handling on the server side is async and if we try to request the results right after submitting the job (which is usually the case) we will find the job is still pending at least for the first query.
- Parameters:
- Returns:
job result
- Raises:
APITimeoutError – time exceeded the set timeout
- Return type:
- abort_job(job_id, *, timeout_secs=60.0)#
Abort a job that was submitted for execution.
- Parameters:
- Raises:
HTTPException – HTTP exceptions
JobAbortionError – if aborting the job failed
- Return type:
None
- get_quantum_architecture(*, timeout_secs=60.0)#
Retrieve quantum architecture from server. Caches the result and returns the same result on later invocations.
- Parameters:
timeout_secs (float) – network request timeout
- Returns:
quantum architecture
- Raises:
APITimeoutError – time exceeded the set timeout
ClientConfigurationError – if no valid authentication is provided
HTTPException – HTTP exceptions
- Return type:
- close_auth_session()#
Terminate session with authentication server if there was one created.
- Returns:
True iff session was successfully closed
- Raises:
ClientAuthenticationError – if logout failed
ClientAuthenticationError – if asked to close externally managed authentication session
- Return type: