{
"cells": [
{
"cell_type": "markdown",
"id": "2106f560",
"metadata": {
"lines_to_next_cell": 0
},
"source": []
},
{
"cell_type": "markdown",
"id": "dbb74473",
"metadata": {
"tags": [
"header_banner"
]
},
"source": [
"\n",
" \n",
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "27f5bd1b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:04:22.181489Z",
"iopub.status.busy": "2025-03-12T18:04:22.181231Z",
"iopub.status.idle": "2025-03-12T18:04:23.894022Z",
"shell.execute_reply": "2025-03-12T18:04:23.893302Z"
},
"tags": [
"imports",
"header_0"
]
},
"outputs": [],
"source": [
"from __future__ import annotations\n",
"\n",
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"import rich # noqa:F401\n",
"from qcodes.parameters import ManualParameter\n",
"\n",
"import quantify_core.data.handling as dh\n",
"from quantify_core.analysis.single_qubit_timedomain import T1Analysis\n",
"from quantify_core.data.handling import load_dataset\n",
"from quantify_scheduler import QuantumDevice, Schedule, ScheduleGettable\n",
"from quantify_scheduler.operations import Measure, Reset, X\n",
"\n",
"from utils import display_dict, initialize_hardware, run_schedule, show_connectivity # noqa:F401"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c22d3be5",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:04:23.897173Z",
"iopub.status.busy": "2025-03-12T18:04:23.896431Z",
"iopub.status.idle": "2025-03-12T18:04:23.899659Z",
"shell.execute_reply": "2025-03-12T18:04:23.899217Z"
},
"tags": [
"config",
"header_1"
]
},
"outputs": [],
"source": [
"hw_config_path = \"configs/tuning_spin_coupled_pair_hardware_config.json\"\n",
"device_path = \"devices/spin_device_2q.json\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "0c7260b3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:04:23.901305Z",
"iopub.status.busy": "2025-03-12T18:04:23.901155Z",
"iopub.status.idle": "2025-03-12T18:04:23.904154Z",
"shell.execute_reply": "2025-03-12T18:04:23.903680Z"
},
"tags": [
"header_2"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data will be saved in:\n",
"/root/quantify-data\n"
]
}
],
"source": [
"# Enter your own dataset directory here!\n",
"dh.set_datadir(dh.default_datadir())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "58e118b8",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:04:23.905765Z",
"iopub.status.busy": "2025-03-12T18:04:23.905623Z",
"iopub.status.idle": "2025-03-12T18:04:24.430564Z",
"shell.execute_reply": "2025-03-12T18:04:24.429946Z"
},
"tags": [
"header_3"
]
},
"outputs": [],
"source": [
"quantum_device = QuantumDevice.from_json_file(device_path)\n",
"qubit = quantum_device.get_element(\"q0\")\n",
"quantum_device.hardware_config.load_from_json_file(hw_config_path)\n",
"cluster_ip = None\n",
"meas_ctrl, inst_coord, cluster = initialize_hardware(quantum_device, ip=cluster_ip)"
]
},
{
"cell_type": "markdown",
"id": "0eed43b1",
"metadata": {},
"source": [
"# T1\n",
"Here we measure the $T_1$ decoherence time of the qubit."
]
},
{
"cell_type": "markdown",
"id": "713c86f1",
"metadata": {
"tags": [
"no_demo"
]
},
"source": [
"## Setup\n",
"In this section we configure the hardware configuration which specifies the connectivity of our system.\n",
"\n",
"The experiments of this tutorial are meant to be executed with a Qblox Cluster controlling a transmon system.\n",
"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.\n",
"When using a dummy device, the analysis will not work because the experiments will return `np.nan` values.\n",
"\n",
"### Configuration file\n",
"\n",
"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.\n",
"\n",
"The hardware connectivity is as follows, by cluster slot:\n",
"\n",
"- **QCM** (Slot 2)\n",
" - $\\text{O}^{1}$: Flux line for `q0`.\n",
" - $\\text{O}^{2}$: Flux line for `q1`.\n",
"\n",
"- **QCM-RF** (Slot 6)\n",
" - $\\text{O}^{1}$: Drive line for `q0` using fixed 80 MHz IF.\n",
" - $\\text{O}^{2}$: Drive line for `q1` using fixed 80 MHz IF.\n",
"\n",
"- **QRM-RF** (Slot 8)\n",
" - $\\text{O}^{1}$ and $\\text{I}^{1}$: Shared readout line for `q0`/`q1` using a fixed LO set at 7.5 GHz.\n",
"\n",
"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."
]
},
{
"cell_type": "markdown",
"id": "0f6455aa",
"metadata": {
"tags": [
"no_demo"
]
},
"source": [
"### Quantum device settings\n",
"Here we initialize our `QuantumDevice` and our qubit parameters, checkout this [tutorial](https://quantify-os.org/docs/quantify-scheduler/tutorials/Operations%20and%20Qubits.html) for further details.\n",
"\n",
"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."
]
},
{
"cell_type": "markdown",
"id": "d7090575",
"metadata": {
"title": "BODY"
},
"source": [
"## T1"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "ec1fb8da",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:04:24.433308Z",
"iopub.status.busy": "2025-03-12T18:04:24.433139Z",
"iopub.status.idle": "2025-03-12T18:04:24.438388Z",
"shell.execute_reply": "2025-03-12T18:04:24.437924Z"
}
},
"outputs": [],
"source": [
"# This schedule can also be imported from quantify_scheduler.schedules.\n",
"\n",
"\n",
"def t1_sched(\n",
" times: np.ndarray | float,\n",
" qubit: str,\n",
" repetitions: int = 1,\n",
") -> Schedule:\n",
" \"\"\"\n",
" Generate a schedule for performing a :math:`T_1` experiment.\n",
"\n",
" This measures the qubit relaxation time.\n",
"\n",
" Schedule sequence\n",
" .. centered:: Reset -- pi -- Idle(tau) -- Measure\n",
"\n",
" See section III.B.2. of :cite:t:`krantz_quantum_2019` for an explanation of the Bloch-Redfield\n",
" model of decoherence and the :math:`T_1` experiment.\n",
"\n",
" Parameters\n",
" ----------\n",
" times\n",
" an array of wait times tau between the start of pi-pulse and the measurement.\n",
" qubit\n",
" the name of the device element e.g., :code:`\"q0\"` to perform the T1 experiment on.\n",
" repetitions\n",
" The amount of times the Schedule will be repeated.\n",
"\n",
" Returns\n",
" -------\n",
" :\n",
" An experiment schedule.\n",
"\n",
" \"\"\"\n",
" device_element = qubit\n",
" # ensure times is an iterable when passing floats.\n",
" times = np.asarray(times)\n",
" times = times.reshape(times.shape or (1,))\n",
"\n",
" schedule = Schedule(\"T1\", repetitions)\n",
" for i, tau in enumerate(times):\n",
" schedule.add(Reset(device_element), label=f\"Reset {i}\")\n",
" schedule.add(X(device_element), label=f\"pi {i}\")\n",
" schedule.add(\n",
" Measure(device_element, acq_index=i),\n",
" ref_pt=\"start\",\n",
" rel_time=tau,\n",
" label=f\"Measurement {i}\",\n",
" )\n",
" return schedule"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "51e31be3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:04:24.439681Z",
"iopub.status.busy": "2025-03-12T18:04:24.439530Z",
"iopub.status.idle": "2025-03-12T18:04:24.443221Z",
"shell.execute_reply": "2025-03-12T18:04:24.442756Z"
},
"lines_to_next_cell": 2
},
"outputs": [],
"source": [
"tau = ManualParameter(name=\"tau_delay\", unit=\"s\", label=\"Delay\")\n",
"tau.batched = True\n",
"\n",
"t1_sched_kwargs = {\"qubit\": qubit.name, \"times\": tau}\n",
"\n",
"gettable = ScheduleGettable(\n",
" quantum_device,\n",
" schedule_function=t1_sched,\n",
" schedule_kwargs=t1_sched_kwargs,\n",
" real_imag=False,\n",
" batched=True,\n",
")\n",
"meas_ctrl.gettables(gettable)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "173eaffb",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:04:24.444496Z",
"iopub.status.busy": "2025-03-12T18:04:24.444351Z",
"iopub.status.idle": "2025-03-12T18:04:25.333406Z",
"shell.execute_reply": "2025-03-12T18:04:25.332929Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Starting batched measurement...\n",
"Iterative settable(s) [outer loop(s)]:\n",
"\t --- (None) --- \n",
"Batched settable(s):\n",
"\t tau_delay \n",
"Batch size limit: 400\n",
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "233d58173cb84eae9df572908d531cff",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Completed: 0%| [ elapsed time: 00:00 | time left: ? ] it"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"
<xarray.Dataset> Size: 10kB\n", "Dimensions: (dim_0: 400)\n", "Coordinates:\n", " x0 (dim_0) float64 3kB 4e-08 5.4e-07 1.04e-06 ... 0.000199 0.0001995\n", "Dimensions without coordinates: dim_0\n", "Data variables:\n", " y0 (dim_0) float64 3kB nan nan nan nan nan nan ... nan nan nan nan nan\n", " y1 (dim_0) float64 3kB nan nan nan nan nan nan ... nan nan nan nan nan\n", "Attributes:\n", " tuid: 20250312-180424-446-80e691\n", " name: T1 experiment\n", " grid_2d: False\n", " grid_2d_uniformly_spaced: False\n", " 1d_2_settables_uniformly_spaced: False
setting | \nvalue | \n
---|---|
instrument_type | \nQCM_RF | \n
setting | \nvalue | \n
---|---|
instrument_type | \nCluster | \n
sequence_to_file | \nFalse | \n
ref | \ninternal | \n
setting | \nvalue | \n
---|---|
acq_protocol | \nSSBIntegrationComplex | \n
bin_mode | \naverage | \n
acq_return_type | \n<class 'complex'> | \n
repetitions | \n300 | \n
setting | \nvalue | \n
---|---|
num_bins | \n400 | \n
index | \n0 | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQRM | \n
setting | \nvalue | \n
---|---|
repetitions | \n300 | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
acq_channel | \n0 | \n
acq_indices | \n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... | \n
thresholded_trigger_count | \nNone | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQCM | \n
setting | \nvalue | \n
---|---|
graph | \n[[cluster0.module2.real_output_0, q0:gt], [clu... | \n
setting | \nvalue | \n
---|---|
sync_en | \nTrue | \n
channel_name | \nreal_output_0 | \n
channel_name_measure | \n[real_input_1, real_input_0] | \n
connected_output_indices | \n(0,) | \n
connected_input_indices | \n(0, 1) | \n
seq_fn | \nNone | \n
thresholded_acq_trigger_write_en | \nNone | \n
thresholded_acq_trigger_write_address | \nNone | \n
thresholded_acq_trigger_write_invert | \nFalse | \n
nco_en | \nTrue | \n
init_offset_awg_path_I | \n0.0 | \n
init_offset_awg_path_Q | \n0.0 | \n
init_gain_awg_path_I | \n1.0 | \n
init_gain_awg_path_Q | \n1.0 | \n
modulation_freq | \n120000000.0 | \n
mixer_corr_phase_offset_degree | \nNone | \n
mixer_corr_gain_ratio | \nNone | \n
auto_sideband_cal | \nSidebandCalEnum.OFF | \n
integration_length_acq | \n1900 | \n
thresholded_acq_threshold | \nNone | \n
thresholded_acq_rotation | \nNone | \n
ttl_acq_input_select | \nNone | \n
ttl_acq_threshold | \nNone | \n
ttl_acq_auto_bin_incr_en | \nNone | \n
setting | \nvalue | \n
---|---|
offset_ch0_path_I | \nNone | \n
offset_ch0_path_Q | \nNone | \n
offset_ch1_path_I | \nNone | \n
offset_ch1_path_Q | \nNone | \n
in0_gain | \nNone | \n
in1_gain | \nNone | \n
distortion_corrections | \n[{'bt': {'coeffs': None, 'config': 'QbloxFilte... | \n
out0_lo_freq_cal_type_default | \nLoCalEnum.OFF | \n
out1_lo_freq_cal_type_default | \nLoCalEnum.OFF | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
offset_ch0_path_I | \nNone | \n
offset_ch0_path_Q | \nNone | \n
offset_ch1_path_I | \nNone | \n
offset_ch1_path_Q | \nNone | \n
in0_gain | \nNone | \n
in1_gain | \nNone | \n
distortion_corrections | \n[{'bt': {'coeffs': None, 'config': 'QbloxFilte... | \n
out0_lo_freq_cal_type_default | \nLoCalEnum.OFF | \n
out1_lo_freq_cal_type_default | \nLoCalEnum.OFF | \n
lo0_freq | \nNone | \n
lo1_freq | \nNone | \n
out0_att | \nNone | \n
out1_att | \nNone | \n
in0_att | \nNone | \n
setting | \nvalue | \n
---|---|
interm_freq | \n70000000.0 | \n
setting | \nvalue | \n
---|---|
config_type | \nquantify_scheduler.backends.qblox_backend.Qblo... | \n
setting | \nvalue | \n
---|---|
interm_freq | \n80000000.0 | \n
setting | \nvalue | \n
---|---|
repetitions | \n300 | \n
setting | \nvalue | \n
---|---|
reference_source | \ninternal | \n
sync_on_external_trigger | \nNone | \n
setting | \nvalue | \n
---|---|
repetitions | \n300 | \n
setting | \nvalue | \n
---|---|
sync_en | \nTrue | \n
channel_name | \ncomplex_output_0 | \n
channel_name_measure | \nNone | \n
connected_output_indices | \n(0, 1) | \n
connected_input_indices | \n() | \n
seq_fn | \nNone | \n
thresholded_acq_trigger_write_en | \nNone | \n
thresholded_acq_trigger_write_address | \nNone | \n
thresholded_acq_trigger_write_invert | \nFalse | \n
nco_en | \nTrue | \n
init_offset_awg_path_I | \n0.0 | \n
init_offset_awg_path_Q | \n0.0 | \n
init_gain_awg_path_I | \n1.0 | \n
init_gain_awg_path_Q | \n1.0 | \n
modulation_freq | \n80000000.0 | \n
mixer_corr_phase_offset_degree | \n0.0 | \n
mixer_corr_gain_ratio | \n1.0 | \n
auto_sideband_cal | \nSidebandCalEnum.ON_INTERM_FREQ_CHANGE | \n
integration_length_acq | \nNone | \n
thresholded_acq_threshold | \nNone | \n
thresholded_acq_rotation | \nNone | \n
ttl_acq_input_select | \nNone | \n
ttl_acq_threshold | \nNone | \n
ttl_acq_auto_bin_incr_en | \nNone | \n
setting | \nvalue | \n
---|---|
sync_en | \nTrue | \n
channel_name | \nreal_output_0 | \n
channel_name_measure | \nNone | \n
connected_output_indices | \n(0,) | \n
connected_input_indices | \n() | \n
seq_fn | \nNone | \n
thresholded_acq_trigger_write_en | \nNone | \n
thresholded_acq_trigger_write_address | \nNone | \n
thresholded_acq_trigger_write_invert | \nFalse | \n
nco_en | \nTrue | \n
init_offset_awg_path_I | \n0.0 | \n
init_offset_awg_path_Q | \n0.0 | \n
init_gain_awg_path_I | \n1.0 | \n
init_gain_awg_path_Q | \n1.0 | \n
modulation_freq | \n0 | \n
mixer_corr_phase_offset_degree | \nNone | \n
mixer_corr_gain_ratio | \nNone | \n
auto_sideband_cal | \nSidebandCalEnum.OFF | \n
integration_length_acq | \nNone | \n
thresholded_acq_threshold | \nNone | \n
thresholded_acq_rotation | \nNone | \n
ttl_acq_input_select | \nNone | \n
ttl_acq_threshold | \nNone | \n
ttl_acq_auto_bin_incr_en | \nNone | \n
setting | \nvalue | \n
---|---|
q0:mw-q0.f_larmor | \n0 | \n
q1:mw-q1.f_larmor | \n0 | \n
setting | \nvalue | \n
---|---|
offset_ch0_path_I | \nNone | \n
offset_ch0_path_Q | \nNone | \n
offset_ch1_path_I | \nNone | \n
offset_ch1_path_Q | \nNone | \n
in0_gain | \nNone | \n
in1_gain | \nNone | \n
distortion_corrections | \n[{'bt': {'coeffs': None, 'config': 'QbloxFilte... | \n
out0_lo_freq_cal_type_default | \nLoCalEnum.ON_LO_INTERM_FREQ_CHANGE | \n
out1_lo_freq_cal_type_default | \nLoCalEnum.OFF | \n
lo0_freq | \n5020000000.0 | \n
lo1_freq | \nNone | \n
out0_att | \n0 | \n
out1_att | \nNone | \n
in0_att | \nNone | \n