::: AQT Cirq Tutorial

AQT supports the Cirq software library for noisy intermediate-scale quantum computers (NISQ).

Cirq is hosted on Github

License Build Status Downloads

Installation

Use pip to install Cirq from the master branch on the command line by:

python -m pip install git+https://github.com/quantumlib/Cirq.git

For more detailed information on how to install Cirq please visit Installing Cirq.

After the installation has finished successfully, you are ready to use different backends supported by AQT using Cirq.

Use your AQT credentials

import cirq
from cirq.aqt.aqt_device import get_aqt_device
from cirq.aqt.aqt_sampler import AQTSampler
access_token = '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. Then you can access the AQT device by:

device, qubits = get_aqt_device(2)
print(device)

Sample a quantum circuit

You can then use that device in Cirq. For example, preparing the Bell state

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

by writing

circuit = cirq.Circuit()
circuit.append([cirq.XX(qubits[0], qubits[1])**0.5])
device.validate_circuit(circuit)
print(circuit, qubits)

This circuit can then be sampled on the real-hardware backend as well as on a simulator.

url = 'BACKEND_URL'
aqt_sampler = AQTSampler(url, access_token=access_token)
aqt_sweep = aqt_sampler.run(circuit, repetitions=100)
print(aqt_sweep)

Where BACKEND_URL is the API URL of the AQT backend as specified in your subscription.

Note: At the moment, the run() method of the AQTSampler implicitly performs measurements on all qubits at the end of the circuit, so explicit measurement operations aren’t required. In fact, using explicit measurements will cause the the AQTSampler to fail. More fine-grained measuement operations will be added to the AQT API in the future.

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

For running a simulation without noise model use

url = 'https://gateway.aqt.eu/marmot/sim/'

whereas for a simulation with noise model use

url = 'https://gateway.aqt.eu/marmot/sim/noise-model-1'

We will provide different noise models in the future, which will be listed on the subscriptions page at the AQT Gateway Portal.

License

Cirq is licensed under the Apache License 2.0.