IQMClient#
Module: iqm.iqm_client.iqm_client
- class iqm.iqm_client.iqm_client.IQMClient(iqm_server_url: str, *, quantum_computer: str | None = None, token: str | None = None, tokens_file: str | None = None, client_signature: str | None = None)#
Bases:
objectProvides access to IQM quantum computers, enabling e.g. quantum circuit execution.
- Parameters:
iqm_server_url (str) – URL for accessing the IQM Server. Has to start with http or https.
quantum_computer (str | None) – ID or alias of the quantum computer to connect to, if the IQM Server instance controls more than one.
token (str | None) – Long-lived authentication token in plain text format. If
tokenis given no other user authentication parameters should be given.tokens_file (str | None) – Path to a tokens file used for authentication. If
tokens_fileis given no other user authentication parameters should be given.client_signature (str | None) – String that IQMClient adds to User-Agent header of requests it sends to the server. The signature is appended to IQMClient’s own version information and is intended to carry additional version information, for example the version information of the caller.
Alternatively, the user authentication related keyword arguments can also be given in environment variables
IQM_TOKEN,IQM_TOKENS_FILE.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
Cancel a job that has been submitted for execution.
Create a run request for executing circuits without sending it to the server.
Delete a job that has been submitted for execution.
Information about the quantum computer.
Retrieve the given calibration set and related quality metrics from the server.
Retrieve the given calibration set from the server.
Retrieve the dynamic quantum architecture (DQA) for the given calibration set from the server.
Retrieve groups of qubits that can receive real-time feedback signals from each other.
Health status of the quantum computer.
Build a new job object for a submitted job.
Query the measurement counts of an executed job.
Query the measurement results of an executed job.
Retrieve the latest quality metric set for the given calibration set from the server.
Retrieve the static quantum architecture (SQA) from the server.
Submit a batch of quantum circuits for execution on a quantum computer.
Submit a request to execute a circuit batch to a quantum computer.
- submit_circuits(circuits: list[Circuit | _Circuit | str], *, qubit_mapping: WithJsonSchema(json_schema={'anyOf': [{'type': 'array', 'items': {'type': 'object', 'required': ['logical_name', 'physical_name'], 'properties': {'logical_name': {'type': 'string'}, 'physical_name': {'type': 'string'}}, 'additionalProperties': False}}, {'type': 'null'}]}, mode=None)] | None = None, calibration_set_id: UUID | None = None, shots: int = 1, options: CircuitCompilationOptions | None = None, use_timeslot: bool = False) CircuitJob#
Submit a batch of quantum circuits for execution on a quantum computer.
- Parameters:
circuits (list[Circuit | _Circuit | str]) – Circuits to be executed.
qubit_mapping (Annotated[dict[str, str], BeforeValidator(func=~iqm.station_control.interface.models.circuit._parse_legacy_qubit_mapping, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~iqm.station_control.interface.models.circuit._serialize_as_legacy_qubit_mapping, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={'anyOf': [{'type': 'array', 'items': {'type': 'object', 'required': ['logical_name', 'physical_name'], 'properties': {'logical_name': {'type': 'string'}, 'physical_name': {'type': 'string'}}, 'additionalProperties': False}}, {'type': 'null'}]}, mode=None)] | 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.calibration_set_id (UUID | None) – ID of the calibration set to use, or
Noneto use the current default calibration.shots (int) – Number of times
circuitsare executed. Must be greater than zero.options (CircuitCompilationOptions | None) – Various discrete options for compiling quantum circuits to instruction schedules.
use_timeslot (bool) – Submits the job to the timeslot queue if set to
True. If set toFalse, the job is submitted to the normal on-demand queue.
- Returns:
Job object, containing the ID for the created job. You can query the job status and the execution results using the methods of this object.
- Return type:
- create_run_request(circuits: list[Circuit | _Circuit | str], *, qubit_mapping: WithJsonSchema(json_schema={'anyOf': [{'type': 'array', 'items': {'type': 'object', 'required': ['logical_name', 'physical_name'], 'properties': {'logical_name': {'type': 'string'}, 'physical_name': {'type': 'string'}}, 'additionalProperties': False}}, {'type': 'null'}]}, mode=None)] | None = None, calibration_set_id: UUID | None = None, shots: int = 1, options: CircuitCompilationOptions | None = None) PostJobsRequest#
Create a run request for executing circuits without sending it to the server.
This is called in
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:
circuits (list[Circuit | _Circuit | str]) – Circuits to be executed.
qubit_mapping (Annotated[dict[str, str], BeforeValidator(func=~iqm.station_control.interface.models.circuit._parse_legacy_qubit_mapping, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~iqm.station_control.interface.models.circuit._serialize_as_legacy_qubit_mapping, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={'anyOf': [{'type': 'array', 'items': {'type': 'object', 'required': ['logical_name', 'physical_name'], 'properties': {'logical_name': {'type': 'string'}, 'physical_name': {'type': 'string'}}, 'additionalProperties': False}}, {'type': 'null'}]}, mode=None)] | 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.calibration_set_id (UUID | None) – ID of the calibration set to use, or
Noneto use the current default calibration.shots (int) – Number of times
circuitsare executed. Must be greater than zero.options (CircuitCompilationOptions | None) – Various discrete options for compiling quantum circuits to instruction schedules.
- Returns:
RunRequest that would be submitted by equivalent call to
submit_circuits().- Return type:
- submit_run_request(run_request: PostJobsRequest, use_timeslot: bool = False) CircuitJob#
Submit a request to execute a circuit batch to a quantum computer.
This is called in
submit_circuits()and does not need to be called separately in normal usage.- Parameters:
run_request (PostJobsRequest) – Run request to be submitted for execution.
use_timeslot (bool) – Submits the job to the timeslot queue if set to
True. If set toFalse, the job is submitted to the normal on-demand queue.
- Returns:
Job object, containing the ID for the created job.
- Return type:
- get_job(job_id: UUID) CircuitJob#
Build a new job object for a submitted job.
Can be used e.g. when you wish to query the results of a job submitted in a different Python session.
- Parameters:
job_id (UUID) – ID of the job to query.
- Returns:
Job object, can be used to query the results.
- Return type:
- cancel_job(job_id: UUID) None#
Cancel a job that has been submitted for execution.
A canceled job will remain in the server database, but it will not be executed. If the job is currently being executed, it is interrupted. If the job was already executed (or failed), it will remain in its current terminal state.
- Parameters:
job_id (UUID) – ID of the job to be canceled.
- Return type:
None
- delete_job(job_id: UUID) None#
Delete a job that has been submitted for execution.
Works like
cancel_job(), but also removes the job from the IQM Server database.Warning
There is no way to recover a deleted job.
- Parameters:
job_id (UUID) – ID of the job to be deleted.
- Return type:
None
- get_static_quantum_architecture() StaticQuantumArchitecture#
Retrieve the static quantum architecture (SQA) from the server.
Caches the result and returns it on later invocations.
- Returns:
Static quantum architecture of the server.
- Return type:
- get_quality_metric_set(calibration_set_id: UUID | None = None) ObservationSetWithObservations#
Retrieve the latest quality metric set for the given calibration set from the server.
- Parameters:
calibration_set_id (UUID | None) – ID of the calibration set for which the quality metrics are returned. If
None, the current default calibration set is used.- Returns:
Requested quality metric set.
- Return type:
- get_calibration_set(calibration_set_id: UUID | None = None) ObservationSetWithObservations#
Retrieve the given calibration set from the server.
- Parameters:
calibration_set_id (UUID | None) – ID of the calibration set to retrieve. If
None, the current default calibration set is retrieved.- Returns:
Requested calibration set.
- Return type:
- get_dynamic_quantum_architecture(calibration_set_id: UUID | None = None) DynamicQuantumArchitecture#
Retrieve the dynamic quantum architecture (DQA) for the given calibration set from the 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:
calibration_set_id (UUID | None) – ID of the calibration set for which the DQA is retrieved. If
None, use current default calibration set on the server.- Returns:
Dynamic quantum architecture corresponding to the given calibration set.
- Return type:
- get_feedback_groups() tuple[frozenset[str], ...]#
Retrieve groups of qubits that can receive real-time feedback signals from each other.
Real-time feedback enables conditional gates such as cc_prx. Some hardware configurations support routing real-time feedback only between certain qubits.
- get_job_measurement_counts(job_id: UUID) list[CircuitMeasurementCounts]#
Query the measurement counts of an executed job.
- Parameters:
job_id (UUID) – ID of the job to query.
- Returns:
For each circuit in the batch, measurement results in histogram representation.
- Return type:
- get_job_measurements(job_id: UUID) list[dict[str, list[list[int]]]]#
Query the measurement results of an executed job.
- get_calibration_quality_metrics(calibration_set_id: UUID | None = None) ObservationFinder#
Retrieve the given calibration set and related quality metrics from the server.
Warning
This method is an experimental interface to the quality metrics and calibration data. The API may change considerably in the next versions with no backwards compatibility, including the API of the ObservationFinder class.
- Parameters:
calibration_set_id (UUID | None) – ID of the calibration set to retrieve. If
None, the current default calibration set is retrieved.- Returns:
Requested calibration set and related quality metrics in a searchable structure.
- Return type:
Inheritance
