API documentation

Backends for processing pytket circuits with IonQ devices

class pytket.extensions.ionq.IonQBackend(device_name: str = 'qpu.harmony', api_key: Optional[str] = None, label: Optional[str] = 'job', _machine_debug: bool = False)

Interface to an IonQ device.

Requires a valid API key/access token, this can either be provided as a parameter or set in config using pytket.extensions.ionq.set_ionq_config()

__init__(device_name: str = 'qpu.harmony', api_key: Optional[str] = None, label: Optional[str] = 'job', _machine_debug: bool = False)

Construct a new IonQ backend.

  • device_name (Optional[string]) – device name, either “qpu” or “simulator”. Default is “qpu.harmony”.

  • api_key (Optional[string]) – IonQ API key. Default is None (read from config).

  • label (Optional[string]) – label to apply to submitted jobs. Default is “job”.

classmethod available_devices(**kwargs: Any) List[pytket.backends.backendinfo.BackendInfo]

Retrieve all available devices as a list of BackendInfo objects, including device name, architecture, supported gate set, gate errors, and other hardware-specific information.


A list of BackendInfo objects describing available devices.

Return type


cancel(handle: pytket.backends.resulthandle.ResultHandle) None

Cancel a job.


handle (ResultHandle) – handle to job


NotImplementedError – If backend does not support job cancellation

circuit_status(handle: pytket.backends.resulthandle.ResultHandle) pytket.backends.status.CircuitStatus

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

default_compilation_pass(optimisation_level: int = 1) pytket.passes.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.


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.


Compilation pass guaranteeing required predicates.

Return type


get_result(handle: pytket.backends.resulthandle.ResultHandle, **kwargs: Optional[Union[int, float, str]]) pytket.backends.backendresult.BackendResult

See pytket.backends.Backend.get_result(). Supported kwargs: timeout, wait.

process_circuits(circuits: Sequence[pytket.circuit.Circuit], n_shots: Union[None, int, Sequence[Optional[int]]] = None, valid_check: bool = True, **kwargs: Optional[Union[int, float, str]]) List[pytket.backends.resulthandle.ResultHandle]

See pytket.backends.Backend.process_circuits(). Supported kwargs: none.

rebase_pass() pytket.passes.BasePass

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


Compilation pass that converts gates to primitives supported by Backend.

Return type


property backend_info: Optional[pytket.backends.backendinfo.BackendInfo]

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


The BackendInfo describing this backend if it exists.

Return type


property required_predicates: List[pytket.predicates.Predicate]

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


Required predicates.

Return type


IonQ config.

class pytket.extensions.ionq.backends.config.IonQConfig(api_key: Optional[str])

Holds config parameters for pytket-ionq.

classmethod from_extension_dict(ext_dict: Dict[str, Any]) pytket.extensions.ionq.backends.config.IonQConfig

Abstract method to build PytketExtConfig from dictionary serialized form.

pytket.extensions.ionq.backends.config.set_ionq_config(api_key: Optional[str] = None) None

Set default value for IonQ API key.