API documentation

Backends for processing pytket circuits with Azure devices

class pytket.extensions.azure.AzureBackend(name, resource_id=None, location=None, connection_string=None, use_string=False)[source]

Interface to Azure Quantum.

__init__(name, resource_id=None, location=None, connection_string=None, use_string=False)[source]

Construct an Azure backend for a device.

If the environment variable AZURE_QUANTUM_CONNECTION_STRING is set, this is used for authentication. Otherwise, the Azure Quantum resource_id and location are read from pytket config, if set, or else from the provided arguments.

Parameters:
  • name (str) – Device name. Use AzureBackend.available_devices() to obtain a list of possible device names.

  • resource_id (Optional[str]) – Azure Quantum resource_id. If omitted this is read from config (see set_azure_config()), unless the environment variable AZURE_QUANTUM_CONNECTION_STRING is set in which case this is used.

  • location (Optional[str]) – Azure Quantum location. If omitted this is read from config (see set_azure_config()), unless the environment variable AZURE_QUANTUM_CONNECTION_STRING is set in which case this is used.

  • connection_string (Optional[str]) – Azure Quantum connection_string. The connection_string can be set on Azure Quantum. See https://learn.microsoft.com/en-us/azure/quantum/how-to-connect-workspace If omitted this is read from config (see set_azure_config()), unless the environment variable AZURE_QUANTUM_CONNECTION_STRING is set in which case this is used.

  • use_string (bool) – Use the connection_string. Defaults to False.

classmethod available_devices(cls, **kwargs)[source]

See pytket.backends.Backend.get_result().

Supported kwargs: :rtype: list[BackendInfo]

  • resource_id (str)

  • location (str)

  • connection_string (str)

  • use_string (bool) = False

If omitted these are read from config, unless the environment variable AZURE_QUANTUM_CONNECTION_STRING is set in which case it is used.

average_queue_time_s()[source]

Average queue time in seconds reported by the target.

Return type:

int

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_result(handle, **kwargs)[source]

See pytket.backends.Backend.get_result().

Supported kwargs: :rtype: BackendResult

  • timeout (int): timeout in seconds

is_available()[source]

Availability reported by the target.

Return type:

bool

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

See pytket.backends.Backend.process_circuits().

Supported kwargs: :rtype: list[ResultHandle]

  • option_params: a dictionary with string keys and arbitrary values; key-value pairs in the dictionary are passed as input parameters to the backend. Their semantics are backend-dependent.

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]