See also

A Jupyter notebook version of this tutorial can be downloaded here.

image0

[1]:
from __future__ import annotations

import numpy as np
import rich  # noqa:F401
from pycqed_randomized_benchmarking.utils import randomized_benchmarking_schedule

import quantify_core.data.handling as dh
from quantify_scheduler import QuantumDevice
from quantify_scheduler.gettables import ScheduleGettable

from utils import (  # noqa:F401  # noqa:F401
    display_dict,
    initialize_hardware,
    run_schedule,
    show_connectivity,
)
[2]:
hw_config_path = "configs/tuning_transmon_coupled_pair_hardware_config.json"
device_path = "devices/transmon_device_2q.json"
[3]:
# Enter your own dataset directory here!
dh.set_datadir(dh.default_datadir())
Data will be saved in:
/root/quantify-data
[4]:
quantum_device = QuantumDevice.from_json_file(device_path)
qubit = quantum_device.get_element("q0")
quantum_device.hardware_config.load_from_json_file(hw_config_path)
cluster_ip = None
meas_ctrl, inst_coord, cluster = initialize_hardware(quantum_device, ip=cluster_ip)

Two qubit randomized benchmarking#

This application example is qubit type agnostic, i.e. it can be applied for any type of qubit (e.g. transmon, spin, etc.).

For demonstration, we will assume that the qubit type is two flux-tunable transmons.

The experiments can also be executed using a dummy Qblox device that is created via an instance of the Cluster class, and is initialized with a dummy configuration. However, when using a dummy device, the analysis will not work because the experiments will return np.nan values.

Setup#

In this section we configure the hardware configuration which specifies the connectivity of our system.

The experiments of this tutorial are meant to be executed with a Qblox Cluster controlling a transmon system. The experiments can also be executed using a dummy Qblox device that is created via an instance of the Cluster class, and is initialized with a dummy configuration. When using a dummy device, the analysis will not work because the experiments will return np.nan values.

Configuration file#

This is a template hardware configuration file for a 2-qubit system with a flux-control line which can be used to tune the qubit frequency. We will only work with qubit 0.

The hardware connectivity is as follows, by cluster slot:

  • QCM (Slot 2)

    • \(\text{O}^{1}\): Flux line for q0.

    • \(\text{O}^{2}\): Flux line for q1.

  • QCM-RF (Slot 6)

    • \(\text{O}^{1}\): Drive line for q0 using fixed 80 MHz IF.

    • \(\text{O}^{2}\): Drive line for q1 using fixed 80 MHz IF.

  • QRM-RF (Slot 8)

    • \(\text{O}^{1}\) and \(\text{I}^{1}\): Shared readout line for q0/q1 using a fixed LO set at 7.5 GHz.

Note that in the hardware configuration below the mixers are uncorrected, but for high fidelity experiments this should also be done for all the modules.

Quantum device settings#

Here we initialize our QuantumDevice and our qubit parameters, checkout this tutorial for further details.

In short, a QuantumDevice contains device elements where we save our found parameters. Here we are loading a template for 2 qubits, but we will only use qubit 0.

[5]:
cluster_ip = None  # To run this tutorial on hardware, fill in the IP address of the cluster here
[6]:
q0 = quantum_device.get_element("q0")
q1 = quantum_device.get_element("q1")

Configure external flux control#

We need to have some way of controlling the external flux.

This can be done by setting an output bias on a module of the cluster which is then connected to the flux-control line.

Here we are nullifying the external flux on both qubits.

[7]:
flux_settables = {q0.name: cluster.module2.out0_offset, q1.name: cluster.module2.out1_offset}

for flux_settable in flux_settables.values():
    flux_settable.inter_delay = 100e-9  # Delay time in seconds between consecutive set operations.
    flux_settable.step = 0.3e-3  # Stepsize in V that this Parameter uses during set operation.
    flux_settable()  # Get before setting to avoid jumps.
    flux_settable(0.0)
[8]:
flux_settables[q0.name](0.0)  # enter your own value here for qubit 0
flux_settables[q1.name](0.0)  # enter your own value here for qubit 1

Two qubit RB#

Set up the measurement control gettables#

[9]:
rb_sched_kwargs = {
    "qubit_specifier": [q0.name, q1.name],
    "lengths": np.arange(1, 5),
    "seeds": np.random.randint(0, 2**31 - 1, size=3, dtype=np.int32),
}

gettable = ScheduleGettable(
    quantum_device,
    schedule_function=randomized_benchmarking_schedule,
    schedule_kwargs=rb_sched_kwargs,
    real_imag=False,
    batched=True,
    num_channels=1,
    max_batch_size=16,
)

gettable.get()
gettable.compiled_schedule.plot_circuit_diagram()
[9]:
(<Figure size 1000x200 with 1 Axes>,
 <Axes: title={'center': 'Randomized benchmarking on q0 and q1'}>)
../../../_images/applications_quantify_transmon_two_qubit_randomized_benchmarking_15_1.png
[10]:
inst_coord.last_schedule.compiled_instructions
[11]:
display_dict(quantum_device.hardware_config())
[11]:
[12]:
quantum_device.to_json_file("devices/")
[12]:
'devices/device_2q_2025-08-06_01-44-02_UTC.json'