API documentation#

Backends for processing pytket circuits with IQM devices

class pytket.extensions.iqm.IQMBackend(url: str, arch: List[List[str]] | None = None, auth_server_url: str | None = None, username: str | None = None, password: str | None = None)#

Interface to an IQM device or simulator.

__init__(url: str, arch: List[List[str]] | None = None, auth_server_url: str | None = None, username: str | None = None, password: str | None = None)#

Construct a new IQM backend.

Requires _either_ a valid auth server URL, username and password, _or_ a tokens file.

Auth server URL, username and password can either be provided as parameters or set in config using pytket.extensions.iqm.set_iqm_config().

Path to the tokens file is read from the environmment variable IQM_TOKENS_FILE. If set, this overrides any other credentials provided as arguments.

Parameters:
  • url – base URL for requests

  • arch – Optional list of couplings between the qubits defined, if

not set the default value from the server is used. :param auth_server_url: base URL of authentication server :param username: IQM username :param password: IQM password

circuit_status(handle: ResultHandle) CircuitStatus#

Return a CircuitStatus reporting the status of the circuit execution corresponding to the ResultHandle

default_compilation_pass(optimisation_level: int = 1) BasePass#

A suggested compilation pass that will will, if possible, produce an equivalent circuit suitable for running on this backend.

At a minimum it will ensure that compatible gates are used and that all two- qubit interactions are compatible with the backend’s qubit architecture. At higher optimisation levels, further optimisations may be applied.

This is a an abstract method which is implemented in the backend itself, and so is tailored to the backend’s requirements.

Parameters:

optimisation_level (int, optional) –

The level of optimisation to perform during compilation.

  • Level 0 does the minimum required to solves the device constraints, without any optimisation.

  • Level 1 additionally performs some light optimisations.

  • Level 2 (the default) adds more computationally intensive optimisations that should give the best results from execution.

Returns:

Compilation pass guaranteeing required predicates.

Return type:

BasePass

get_metadata(handle: ResultHandle, **kwargs: int | float | str | None) Metadata#

Return the metadata corresponding to the handle.

Use keyword arguments to specify parameters to be used in retrieving the metadata.

  • timeout: maximum time to wait for remote job to finish

Example usage:

n_shots = 100 backend.run_circuit(circuit, n_shots=n_shots, timeout=30) handle = backend.process_circuits([circuit], n_shots=n_shots)[0] result = backend.get_result(handle) metadata = backend.get_metadata(handle) print([qm.physical_name for qm in metadata.request.qubit_mapping])

Parameters:

handle (ResultHandle) – handle to results

Returns:

Metadata corresponding to handle

Return type:

Metadata

get_result(handle: ResultHandle, **kwargs: int | float | str | None) BackendResult#

See pytket.backends.Backend.get_result(). Supported kwargs: timeout (default 900).

process_circuits(circuits: Sequence[Circuit], n_shots: None | int | Sequence[int | None] = None, valid_check: bool = True, **kwargs: int | float | str | None) List[ResultHandle]#

See pytket.backends.Backend.process_circuits().

Supported kwargs: - postprocess: apply end-of-circuit simplifications and classical

postprocessing to improve fidelity of results (bool, default False)

  • simplify_initial: apply the pytket SimplifyInitial pass to improve fidelity of results assuming all qubits initialized to zero (bool, default False)

rebase_pass() BasePass#

A single compilation pass that when run converts all gates in a Circuit to an OpType supported by the Backend (ignoring architecture constraints).

Returns:

Compilation pass that converts gates to primitives supported by Backend.

Return type:

BasePass

property backend_info: BackendInfo#

Retrieve all Backend properties in a BackendInfo object, including device architecture, supported gate set, gate errors and other hardware-specific information.

Returns:

The BackendInfo describing this backend if it exists.

Return type:

Optional[BackendInfo]

property required_predicates: List[Predicate]#

The minimum set of predicates that a circuit must satisfy before it can be successfully run on this backend.

Returns:

Required predicates.

Return type:

List[Predicate]

IQM config.

class pytket.extensions.iqm.backends.config.IQMConfig(auth_server_url: str | None, username: str | None, password: str | None)#

Holds config parameters for pytket-iqm.

classmethod from_extension_dict(ext_dict: Dict[str, Any]) IQMConfig#

Abstract method to build PytketExtConfig from dictionary serialized form.

pytket.extensions.iqm.backends.config.set_iqm_config(auth_server_url: str | None = None, username: str | None = None, password: str | None = None) None#

Set default value for IQM API token.