{ "cells": [ { "cell_type": "markdown", "id": "d3fcd466", "metadata": {}, "source": [ "# Time of flight measurement\n", "Here show how to measure time of flight for your system.\n", "This is useful to calibrate the acquisition delay for subsequent experiments." ] }, { "cell_type": "code", "execution_count": 1, "id": "6ea2f6fc", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:22.639388Z", "iopub.status.busy": "2024-11-13T02:35:22.639086Z", "iopub.status.idle": "2024-11-13T02:35:24.275507Z", "shell.execute_reply": "2024-11-13T02:35:24.274675Z" }, "tags": [ "imports" ] }, "outputs": [], "source": [ "import json\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.time_of_flight_analysis import TimeOfFlightAnalysis\n", "from quantify_scheduler import Schedule\n", "from quantify_scheduler.backends.qblox import constants\n", "from quantify_scheduler.device_under_test.quantum_device import QuantumDevice\n", "from quantify_scheduler.gettables import ScheduleGettable\n", "from quantify_scheduler.math import closest_number_ceil\n", "from quantify_scheduler.operations.gate_library import Measure\n", "\n", "from utils import initialize_hardware, run # noqa:F401" ] }, { "cell_type": "code", "execution_count": 2, "id": "c402b131", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:24.278533Z", "iopub.status.busy": "2024-11-13T02:35:24.277809Z", "iopub.status.idle": "2024-11-13T02:35:24.281695Z", "shell.execute_reply": "2024-11-13T02:35:24.281052Z" }, "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": "a08a8921", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:24.283540Z", "iopub.status.busy": "2024-11-13T02:35:24.283377Z", "iopub.status.idle": "2024-11-13T02:35:24.287630Z", "shell.execute_reply": "2024-11-13T02:35:24.286991Z" }, "tags": [ "header_2" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Data will be saved in:\n", "/root/quantify-data\n" ] } ], "source": [ "with open(hw_config_path) as hw_cfg_json_file:\n", " hardware_cfg = json.load(hw_cfg_json_file)\n", "\n", "# Enter your own dataset directory here!\n", "dh.set_datadir(dh.default_datadir())" ] }, { "cell_type": "code", "execution_count": 4, "id": "1c9c006f", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:24.289429Z", "iopub.status.busy": "2024-11-13T02:35:24.289264Z", "iopub.status.idle": "2024-11-13T02:35:24.873342Z", "shell.execute_reply": "2024-11-13T02:35:24.872512Z" }, "tags": [ "header_3" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/builds/qblox/packages/software/qblox_instruments_docs/.venv/lib/python3.9/site-packages/quantify_scheduler/backends/types/qblox.py:1220: ValidationWarning: Setting `auto_lo_cal=on_lo_interm_freq_change` will overwrite settings `dc_offset_i=0.0` and `dc_offset_q=0.0`. To suppress this warning, do not set either `dc_offset_i` or `dc_offset_q` for this port-clock.\n", " warnings.warn(\n", "/builds/qblox/packages/software/qblox_instruments_docs/.venv/lib/python3.9/site-packages/quantify_scheduler/backends/types/qblox.py:1235: ValidationWarning: Setting `auto_sideband_cal=on_interm_freq_change` will overwrite settings `amp_ratio=1.0` and `phase_error=0.0`. To suppress this warning, do not set either `amp_ratio` or `phase_error` for this port-clock.\n", " warnings.warn(\n" ] } ], "source": [ "quantum_device = QuantumDevice.from_json_file(device_path)\n", "qubit = quantum_device.get_element(\"q0\")\n", "quantum_device.hardware_config(hardware_cfg)\n", "meas_ctrl, _, cluster = initialize_hardware(quantum_device, ip=None)" ] }, { "cell_type": "markdown", "id": "ed5476fc", "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": "83c394bd", "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": "420c1ceb", "metadata": { "lines_to_next_cell": 0 }, "source": [ "## Schedule definition" ] }, { "cell_type": "code", "execution_count": 5, "id": "e917f0da", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:24.876383Z", "iopub.status.busy": "2024-11-13T02:35:24.876100Z", "iopub.status.idle": "2024-11-13T02:35:24.880502Z", "shell.execute_reply": "2024-11-13T02:35:24.879696Z" } }, "outputs": [], "source": [ "def tof_trace_schedule(\n", " qubit_name: str,\n", " repetitions: int = 1,\n", ") -> Schedule:\n", " schedule = Schedule(\"Trace measurement schedule\", repetitions=repetitions)\n", " schedule.add(Measure(qubit_name, acq_protocol=\"Trace\"))\n", " return schedule" ] }, { "cell_type": "markdown", "id": "4521aead", "metadata": { "lines_to_next_cell": 0 }, "source": [ "## Measuring time of flight with trace acquisition" ] }, { "cell_type": "code", "execution_count": 6, "id": "e6eada52", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:24.883032Z", "iopub.status.busy": "2024-11-13T02:35:24.882748Z", "iopub.status.idle": "2024-11-13T02:35:24.887855Z", "shell.execute_reply": "2024-11-13T02:35:24.887089Z" }, "lines_to_next_cell": 0 }, "outputs": [], "source": [ "def set_readout_attenuation_hardware_config(attenuation_dB: int):\n", " hwcfg = quantum_device.hardware_config()\n", " output_att = hwcfg[\"hardware_options\"][\"output_att\"]\n", " output_att[f\"{qubit.ports.readout()}-{qubit.name}.ro\"] = attenuation_dB\n", " quantum_device.hardware_config(hwcfg)\n", "\n", "\n", "set_readout_attenuation_hardware_config(0)\n", "qubit.measure.pulse_duration(300e-9)\n", "qubit.measure.integration_time(1e-6)\n", "qubit.measure.pulse_amp(0.1)\n", "qubit.measure.acq_delay(4e-9)" ] }, { "cell_type": "code", "execution_count": 7, "id": "8e2103a4", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:24.890333Z", "iopub.status.busy": "2024-11-13T02:35:24.890040Z", "iopub.status.idle": "2024-11-13T02:35:24.895550Z", "shell.execute_reply": "2024-11-13T02:35:24.894739Z" }, "lines_to_next_cell": 0 }, "outputs": [], "source": [ "tof_t = ManualParameter(name=\"tof_t\", unit=\"ns\", label=\"Trace acquisition sample\")\n", "tof_t.batched = True\n", "tof_t.batch_size = round(qubit.measure.integration_time() * constants.SAMPLING_RATE)\n", "\n", "tof_sched_kwargs = dict(\n", " qubit_name=qubit.name,\n", ")\n", "\n", "# set gettable\n", "gettable = ScheduleGettable(\n", " quantum_device,\n", " schedule_function=tof_trace_schedule,\n", " schedule_kwargs=tof_sched_kwargs,\n", " real_imag=False,\n", " batched=True,\n", ")\n", "\n", "# set measurement control\n", "meas_ctrl.gettables(gettable)" ] }, { "cell_type": "code", "execution_count": 8, "id": "8dd87d5a", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:24.898177Z", "iopub.status.busy": "2024-11-13T02:35:24.897847Z", "iopub.status.idle": "2024-11-13T02:35:25.070702Z", "shell.execute_reply": "2024-11-13T02:35:25.070027Z" } }, "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 tof_t \n", "Batch size limit: 1000\n", "\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ca44221fc0004ca1960a35b6ac24f7e6", "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: 24kB\n", "Dimensions: (x0: 1000)\n", "Coordinates:\n", " * x0 (x0) int64 8kB 0 1 2 3 4 5 6 7 ... 992 993 994 995 996 997 998 999\n", "Data variables:\n", " y0 (x0) float64 8kB 0.001239 -0.00163 ... 0.0002749 -0.0004191\n", " y1 (x0) float64 8kB 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0\n", "Attributes:\n", " tuid: 20241113-023524-902-de490d\n", " name: Time of flight measurement q0\n", " grid_2d: False\n", " grid_2d_uniformly_spaced: False\n", " 1d_2_settables_uniformly_spaced: False