::: AQT Pytket Tutorial

AQT supports integration with the Pytket optimizing compiler. For more information about Pytket see the API documentation.

Pytket is hosted on Github

PyPI package Downloads


Use pip to install Pytket from the command line by

pip install pytket

For more information on installing and using Pytket please see the Getting Started guide.

Next install the Pytket AQT connector

pip install pytket-aqt

After installation has completed, you are ready to execute circuits compiled by Pytket on AQT devices.

Use your AQT credentials

The AQTBackend Python class provides access to all available AQT backends. To create an instance of this class, you need your AQT access token and the name of the target device.

For example:

from pytket.backends.aqt import AQTBackend

backend = AQTBackend("MY_TOKEN", device_name="sim/noise-model-1")

Where MY_TOKEN is your access token for a specific AQT device. You need to subscribe to an AQT backend at the AQT Gateway Portal and retreive the access token. The device_name argument is just the last part of the URL as listed on your subscriptions page. It defaults to sim (the simulator without noise) if not specified.

An optional label argument may also be provided. This is attached to any submitted jobs.

Execute a quantum circuit

You can now run any circuit from Pytket on the AQT device. For example, to execute a circuit that prepares and measures the Bell state

\[ \ket{\psi}=\frac{1}{\sqrt{2}}(\ket{00}+\ket{11}) \]

write the follwing

from pytket.circuit import Circuit

circuit = Circuit(2, 2)
circuit.H(0).CX(0, 1)


n_shots = 100
handle = backend.process_circuits([circuit], n_shots)[0]
print(backend.get_counts(handle, n_shots))

See the Pytket AQT backend documentation for details of this and other methods that can be called on the AQT backend.

The compile_circuit method converts the circuit to an equivalent sequence of gates suitable for passing to an AQT backend (X, Y and MS gates). This sequence is then executed on the backend by process_circuits and the result can be accessed via get_counts by using the returned handle.

The tk_to_aqt method is also available to perform the conversion from circuit to sequence independently by

from pytket.aqt import tk_to_aqt

circuit = Circuit(2).H(0).CX(0, 1)

AQT Simulators

The AQT simulators are capable of running ideal simulations (without a noise model) and real simulations (with a noise model) of a quantum circuit. Using a simulator with noise model allows you to estimate the performance of running a circuit on the real hardware. Switching between the two simulation types is done by using the respective backend in above example.

For running a simulation without noise model use

backend = AQTBackend("MY_TOKEN", device_name="sim/")

whereas for a simulation with noise model use

backend = AQTBackend("MY_TOKEN", device_name="sim/noise-model-1")

We will provide different noise models in the future, which will be added as new backends to the Pytket AQT provider. Available backends are listed on the AQT Gateway Portal.


Pytket and the Pytket AQT provider are licensed under the CQC Non-Commercial Use Software Licence.