See also

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

image0

[1]:
import numpy as np
import rich  # noqa:F401
from qcodes.parameters import ManualParameter
from simulated_data import get_simulated_tof_data

import quantify_core.data.handling as dh
from quantify_core.analysis.time_of_flight_analysis import TimeOfFlightAnalysis
from quantify_scheduler import QuantumDevice, Schedule, ScheduleGettable
from quantify_scheduler.backends.qblox import constants
from quantify_scheduler.device_under_test.transmon_element import BasicTransmonElement
from quantify_scheduler.math import closest_number_ceil
from quantify_scheduler.operations import Measure

from utils import display_dict, initialize_hardware, run_schedule, show_connectivity  # noqa:F401
[2]:
hw_config_path = "configs/tuning_transmon_coupled_pair_hardware_config.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("transmon_device")
quantum_device.hardware_config.load_from_json_file(hw_config_path)
qubit = BasicTransmonElement("q0")
qubit.measure.acq_channel(0)
quantum_device.add_element(qubit)
cluster_ip = None
meas_ctrl, inst_coord, cluster = initialize_hardware(quantum_device, ip=cluster_ip)

Time of flight measurement#

Here show how to measure time of flight for your system. This is useful to calibrate the acquisition delay for subsequent experiments.

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)

    • O1: Flux line for q0.

    • O2: Flux line for q1.

  • QCM-RF (Slot 6)

    • O1: Drive line for q0 using fixed 80 MHz IF.

    • O2: Drive line for q1 using fixed 80 MHz IF.

  • QRM-RF (Slot 8)

    • O1 and I1: 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.

Schedule definition#

[5]:
def tof_trace_schedule(
    qubit_name: str,
    repetitions: int = 1,
) -> Schedule:
    schedule = Schedule("Trace measurement schedule", repetitions=repetitions)
    schedule.add(Measure(qubit_name, acq_protocol="Trace"))
    return schedule

Measuring time of flight with trace acquisition#

[6]:
def set_readout_attenuation_hardware_config(attenuation_dB: int):
    hwcfg = quantum_device.hardware_config()
    output_att = hwcfg["hardware_options"]["output_att"]
    output_att[f"{qubit.ports.readout()}-{qubit.name}.ro"] = attenuation_dB
    quantum_device.hardware_config(hwcfg)


set_readout_attenuation_hardware_config(0)
qubit.measure.pulse_duration(300e-9)
qubit.measure.integration_time(1e-6)
qubit.measure.pulse_amp(0.1)
qubit.measure.acq_delay(4e-9)
qubit.clock_freqs.readout(7.2e9)
[7]:
tof_t = ManualParameter(name="tof_t", unit="ns", label="Trace acquisition sample")
tof_t.batched = True
tof_t.batch_size = round(qubit.measure.integration_time() * constants.SAMPLING_RATE)

tof_sched_kwargs = dict(
    qubit_name=qubit.name,
)

# set gettable
gettable = ScheduleGettable(
    quantum_device,
    schedule_function=tof_trace_schedule,
    schedule_kwargs=tof_sched_kwargs,
    real_imag=False,
    batched=True,
)

# set measurement control
meas_ctrl.gettables(gettable)
[8]:
tof_t_setpoints = np.arange(tof_t.batch_size)

meas_ctrl.settables(tof_t)
meas_ctrl.setpoints(tof_t_setpoints)

if cluster_ip is None:

    def dummy_gettable():
        gettable.initialize()
        return get_simulated_tof_data()

    gettable.get = dummy_gettable

tof_ds = dh.to_gridded_dataset(meas_ctrl.run("Time of flight measurement " + qubit.name))
Starting batched measurement...
Iterative settable(s) [outer loop(s)]:
         --- (None) ---
Batched settable(s):
         tof_t
Batch size limit: 1000

Completed: 100%
 [ elapsed time: 00:00 | time left: 00:00 ]  last batch size: 1000

Analysis#

[9]:
# use fake data in case the cluster is a dummy
tof_analysis = TimeOfFlightAnalysis(tuid=dh.get_latest_tuid())
tof_analysis.run(playback_delay=149e-9).display_figs_mpl()
../../../_images/applications_quantify_transmon_time_of_flight_16_0.png
[10]:
fit_results = tof_analysis.quantities_of_interest
nco_prop_delay = fit_results["nco_prop_delay"]
measured_tof = fit_results["tof"]

qubit.measure.acq_delay(
    closest_number_ceil(
        measured_tof * constants.SAMPLING_RATE, constants.MIN_TIME_BETWEEN_OPERATIONS
    )
    / constants.SAMPLING_RATE
)
[11]:
inst_coord.last_schedule.compiled_instructions
[12]:
display_dict(quantum_device.hardware_config())
[12]:
[13]:
quantum_device.to_json_file("devices/")
[13]:
'devices/transmon_device_2025-03-12_18-00-32_UTC.json'