Propagation delay¶
This notebook shows you how to perform a propagation delay experiment. You'll sweep the delay of the qantum analyzer integration and then find the maximum result.
0. LabOne Q Imports¶
You'll begin by importing laboneq.simple
and some extra helper functions to run the examples.
# LabOne Q:
from laboneq.simple import *
# Helpers:
from laboneq.contrib.example_helpers.plotting.plot_helpers import plot_results
from laboneq.contrib.example_helpers.generate_example_datastore import (
generate_example_datastore,
get_first_named_entry,
)
from pathlib import Path
import time
# Build an in-memory data store with device setup and qubit parameters for the
# example notebooks
setup_db = generate_example_datastore(in_memory=True)
1. Device Setup¶
Below, you'll create a device setup and specify to run in an emulated mode or on hardware, emulate = True/False
respectively.
If you run on your hardware, the descriptor called by create_device_setup
should be replaced by one of your own, generally stored as a YAML file. Once you have this descriptor, it can be reused for all your experiments.
# load a calibrated device setup from the dummy database
device_setup = get_first_named_entry(
db=setup_db, name="6_qubit_setup_shfsg_shfqa_hdawg_pqsc_calibrated"
)
emulate = True
# create and connect to a session
session = Session(device_setup=device_setup)
session.connect(do_emulation=emulate)
2. Experiment Parameters¶
Now you'll define the frequency sweep parameters and pulse to use in your experiment.
delay_sweep = LinearSweepParameter(
uid="delay_sweep_param", start=0, stop=1.0e-6, count=21
)
# define number of averages
# used for 2^num_averages, maximum: num_averages = 17
num_averages = 4
# readout pulse parameters and definition
envelope_duration = 2.048e-6
envelope_rise_fall_time = 0.05e-6
readout_pulse = pulse_library.gaussian_square(
uid="readout_pulse", length=envelope_duration, amplitude=0.9
)
3. Experiment Definition¶
You'll now create a function to generate your propagation delay experiment. In this experiment, you'll pass the delay_sweep
defined previously as an argument to the near-time sweep section. Within the real-time acquisition section, you'll set use INTEGRATION
as your acquisition type, and you'll create a section containing a play
and an acquire
command.
# function that defines a resonator spectroscopy experiment, and takes the frequency sweep as a parameter
def propagation_delay(readout_pulse, delay_sweep):
# Create resonator spectroscopy experiment - uses only readout drive and signal acquisition
exp_prop_delay = Experiment(
uid="Propagation Delay Measurement",
signals=[
ExperimentSignal("measure"),
ExperimentSignal("acquire"),
],
)
## define experimental sequence
# outer loop - vary drive frequency
with exp_prop_delay.sweep(uid="del_sweep", parameter=delay_sweep):
with exp_prop_delay.acquire_loop_rt(
uid="shots",
count=2**num_averages,
acquisition_type=AcquisitionType.INTEGRATION,
):
# readout pulse and data acquisition
with exp_prop_delay.section(uid="spectroscopy"):
# play resonator excitation pulse
exp_prop_delay.play(signal="measure", pulse=readout_pulse)
# resonator signal readout
exp_prop_delay.acquire(
signal="acquire", handle="res_prop_delay", kernel=readout_pulse
)
with exp_prop_delay.section(uid="delay"):
# holdoff time after signal acquisition - minimum 1us required for data processing on UHFQA
exp_prop_delay.delay(signal="measure", time=1e-6)
cal = Calibration()
cal["acquire"] = SignalCalibration(port_delay=delay_sweep)
exp_prop_delay.set_calibration(cal)
return exp_prop_delay
3.1 Signal Map¶
Before running the experiment, you'll define and set the mapping between the experimental and logical lines.
# signal maps for a qubit - maps the logical signal of the device setup to the experimental signals of the experiment
def res_spec_map(qubit):
signal_map = {
"measure": device_setup.logical_signal_groups[f"{qubit}"].logical_signals[
"measure_line"
],
"acquire": device_setup.logical_signal_groups[f"{qubit}"].logical_signals[
"acquire_line"
],
}
return signal_map
# pass sweep and pulse to experiment and apply signal map
exp_prop_delay = propagation_delay(readout_pulse, delay_sweep)
exp_prop_delay.set_signal_map(res_spec_map("q0"))
3.2 Compile and Generate Pulse Sheet¶
Now, you'll compile the experiment and generate a pulse sheet.
# compile the experiment on the open instrument session
compiled_prop_delay = session.compile(exp_prop_delay)
Path("Pulse_Sheets").mkdir(parents=True, exist_ok=True)
# generate a pulse sheet to inspect experiment before runtime
show_pulse_sheet("Pulse_Sheets/Propagation_Delay", compiled_prop_delay)
3.3 Run, Save, and Plot Results¶
Finally, you'll run the experiment, save, and plot the results.
# run the compiled experiemnt
prop_delay_results = session.run(compiled_prop_delay)
timestamp = time.strftime("%Y%m%dT%H%M%S")
Path("Results").mkdir(parents=True, exist_ok=True)
session.save_results(f"Results/{timestamp}_prop_delay_results.json")
print(f"File saved as Results/{timestamp}_prop_delay_results.json")
plot_results(prop_delay_results, phase=True)