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:
objectProvides 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
tokenis given no other user authentication parameters should be given.tokens_file (Optional[str]) – Path to a tokens file used for authentication. If
tokens_fileis given no other user authentication parameters should be given.auth_server_url (Optional[str]) – Base URL of the authentication server. If
auth_server_urlis given alsousernameandpasswordmust 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_USERNAMEandIQM_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__()_check_authentication_errors(result)_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_circuit_moves(architecture, circuit)Validates that the MOVE gates in the circuit are not exciting the resonator.
_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.
create_run_request(circuits, *[, ...])Creates a run request for executing circuits without sending it to the server.
Retrieve dynamic quantum architecture (DQA) for the given calibration set from server.
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.
submit_run_request(run_request)Submits a run request 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, options=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
Noneif allcircuitsalready use physical qubit names. Note that thequbit_mappingis used for allcircuits.custom_settings (dict[str, Any] | None) – Custom settings to override default settings and calibration data. Note: This field should always be
Nonein normal use.calibration_set_id (UUID | None) – ID of the calibration set to use, or
Noneto use the latest oneshots (int) – number of times
circuitsare executed, value must be greater than zerooptions (CircuitCompilationOptions | None) – Various discrete options for compiling quantum circuits to pulse schedules.
- Returns:
ID for the created job. This ID is needed to query the job status and the execution results.
- Return type:
- create_run_request(circuits, *, qubit_mapping=None, custom_settings=None, calibration_set_id=None, shots=1, options=None)#
Creates a run request for executing circuits without sending it to the server.
This is called inside
submit_circuits()and does not need to be called separately in normal usage.Can be used to inspect the run request that would be submitted by
submit_circuits(), without actually submitting it for execution.- Parameters:
qubit_mapping (dict[str, str] | None) – Mapping of logical qubit names to physical qubit names. Can be set to
Noneif allcircuitsalready use physical qubit names. Note that thequbit_mappingis used for allcircuits.custom_settings (dict[str, Any] | None) – Custom settings to override default settings and calibration data. Note: This field should always be
Nonein normal use.calibration_set_id (UUID | None) – ID of the calibration set to use, or
Noneto use the latest oneshots (int) – number of times
circuitsare executed, value must be greater than zeromax_circuit_duration_over_t2 – 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.0turns off circuit duration checking. The default valueNoneinstructs server to use server’s default value in the checking.heralding_mode – Heralding mode to use during the execution.
options (CircuitCompilationOptions | None) –
- Returns:
RunRequest that would be submitted by equivalent call to
submit_circuits().- Return type:
- submit_run_request(run_request)#
Submits a run request for execution on a quantum computer.
This is called inside
submit_circuits()and does not need to be called separately in normal usage.- Parameters:
run_request (RunRequest) – the run request to be submitted for execution.
- Returns:
ID for the created job. This ID is needed to query the job status and the execution results.
- 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:
ArchitectureRetrievalError – IQM server specific exceptions
ClientAuthenticationError – if no valid authentication is provided
HTTPException – HTTP exceptions
- Return type:
- get_dynamic_quantum_architecture(calibration_set_id=None, *, timeout_secs=60.0)#
Retrieve dynamic quantum architecture (DQA) for the given calibration set from server.
Caches the result and returns the same result on later invocations, unless
calibration_set_idisNone. Ifcalibration_set_idisNone, always retrieves the result from the server because the “default” calibration set may have changed.- Parameters:
- Returns:
dynamic quantum architecture corresponding to the given calibration set
- Raises:
ArchitectureRetrievalError – IQM server specific exceptions
ClientAuthenticationError – 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: