::: AQT PennyLane Tutorial

AQT supports Xanadu PennyLane which is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations. You can find more information and documentation on PennyLane documentation.

PennyLane is hosted on Github

License Build Status Downloads


Use pip to install PennyLane from the command line by

pip install pennylane --upgrade

For more information on installing and using PennyLane please see the Install Instructions guide.

Next, you need to install the PennyLane AQT plugin using the pip tool by:

python3 -m pip install pennylane-aqt

After installation has completed, you are ready to use the AQT plugin in PennyLane.

Use your AQT credentials

An AQT backend is available as device in PennyLane by specifiying its name, e.g. aqt.sim for the ideal simulator.

For example:

import pennylane as qml
from pennylane_aqt import ops

dev = qml.device("aqt.sim", wires=2)

For using the AQT devices the access token has to be provided via the PennyLane configuration file config.toml or via the environment variable AQT_TOKEN. A minimum example for a configuration file is provided below.


shots = 200

    api_key = "MY_TOKEN"

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.

Execute a quantum circuit

You can now create a QNode object on this specific device and let it return the expectation value of an observable, e.g. the Pauli Z operator. For example, defining a circuit that prepares and measures the Bell state

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

is done by writing

def circuit(t):
    ops.MS(t, wires=[0, 1])
    return [qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))]

See the PennyLane AQT plugin documentation for details of AQT-specific quantum gates.

In above example a Mølmer-Sørenson (MS) gate is applied on qubits 0 and 1 with a pulse area in units of \(\pi\), which can be specified by the parameter \(t\). Both qubits are measured in the Pauli Z basis and the expectation values are returned for both qubits respectively.

To prepare above-mentioned Bell state, draw the circuit, and show the results, use the following lines

result = circuit(0.5)

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 device in above example.

For running a simulation without noise model use

dev = qml.device("aqt.sim", wires=2)

whereas for a simulation with noise model use

dev = qml.device("aqt.noisy_sim", wires=2)

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


PennyLane and the PennyLane AQT plugin are licensed under the Apache License 2.0.

Logo AQT Alpine Quantum Technologies
Logo AQT Alpine Quantum Technologies