{ "cells": [ { "cell_type": "markdown", "id": "39735caa", "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": "a9d3008b", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:28.298905Z", "iopub.status.busy": "2024-11-13T02:35:28.298088Z", "iopub.status.idle": "2024-11-13T02:35:29.941629Z", "shell.execute_reply": "2024-11-13T02:35:29.940771Z" }, "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": "a86c16c4", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:29.944643Z", "iopub.status.busy": "2024-11-13T02:35:29.943927Z", "iopub.status.idle": "2024-11-13T02:35:29.947739Z", "shell.execute_reply": "2024-11-13T02:35:29.947196Z" }, "tags": [ "config", "header_1" ] }, "outputs": [], "source": [ "hw_config_path = \"configs/tuning_transmon_coupled_pair_hardware_config.json\"\n", "device_path = \"devices/transmon_device_2q.json\"" ] }, { "cell_type": "code", "execution_count": 3, "id": "f2bccfbd", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:29.949580Z", "iopub.status.busy": "2024-11-13T02:35:29.949258Z", "iopub.status.idle": "2024-11-13T02:35:29.953221Z", "shell.execute_reply": "2024-11-13T02:35:29.952590Z" }, "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": "f07203d0", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:29.954871Z", "iopub.status.busy": "2024-11-13T02:35:29.954706Z", "iopub.status.idle": "2024-11-13T02:35:30.470994Z", "shell.execute_reply": "2024-11-13T02:35:30.470275Z" }, "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": "63f2e17a", "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": "1f05a132", "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": "a572682b", "metadata": { "lines_to_next_cell": 0 }, "source": [ "## Schedule definition" ] }, { "cell_type": "code", "execution_count": 5, "id": "b277614c", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:30.473425Z", "iopub.status.busy": "2024-11-13T02:35:30.473220Z", "iopub.status.idle": "2024-11-13T02:35:30.477129Z", "shell.execute_reply": "2024-11-13T02:35:30.476448Z" } }, "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": "74b1b10d", "metadata": { "lines_to_next_cell": 0 }, "source": [ "## Measuring time of flight with trace acquisition" ] }, { "cell_type": "code", "execution_count": 6, "id": "a93ab46e", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:30.479029Z", "iopub.status.busy": "2024-11-13T02:35:30.478838Z", "iopub.status.idle": "2024-11-13T02:35:30.483127Z", "shell.execute_reply": "2024-11-13T02:35:30.482521Z" }, "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": "10c0a437", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:30.484827Z", "iopub.status.busy": "2024-11-13T02:35:30.484664Z", "iopub.status.idle": "2024-11-13T02:35:30.488728Z", "shell.execute_reply": "2024-11-13T02:35:30.488121Z" }, "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": "ed667dc0", "metadata": { "execution": { "iopub.execute_input": "2024-11-13T02:35:30.490431Z", "iopub.status.busy": "2024-11-13T02:35:30.490264Z", "iopub.status.idle": "2024-11-13T02:35:30.648772Z", "shell.execute_reply": "2024-11-13T02:35:30.648089Z" } }, "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": "2d259e7e47ca471fb8220cc4642a8045", "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.0003358 -0.001058 ... 0.0007684 0.0002685\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-023530-493-5de724\n", " name: Time of flight measurement q0\n", " grid_2d: False\n", " grid_2d_uniformly_spaced: False\n", " 1d_2_settables_uniformly_spaced: False