API documentation#

Backends for processing pytket circuits with IQM devices

class pytket.extensions.iqm.IQMBackend(url, arch=None, auth_server_url=None, username=None, password=None)[source]#

Interface to an IQM device or simulator.

__init__(url, arch=None, auth_server_url=None, username=None, password=None)[source]#

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 (str) – base URL for requests

  • arch (Optional[List[List[str]]]) – Optional list of couplings between the qubits defined, if

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

circuit_status(handle)[source]#

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

Return type:

CircuitStatus

default_compilation_pass(optimisation_level=1)[source]#

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, **kwargs)[source]#

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, **kwargs)[source]#

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

Return type:

BackendResult

process_circuits(circuits, n_shots=None, valid_check=True, **kwargs)[source]#

See pytket.backends.Backend.process_circuits().

Return type:

List[ResultHandle]

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()[source]#

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, username, password)[source]#

Holds config parameters for pytket-iqm.

classmethod from_extension_dict(ext_dict)[source]#

Abstract method to build PytketExtConfig from dictionary serialized form.

Return type:

IQMConfig

pytket.extensions.iqm.backends.config.set_iqm_config(auth_server_url=None, username=None, password=None)[source]#

Set default value for IQM API token.

Return type:

None