{ "cells": [ { "cell_type": "markdown", "id": "53a9c50b", "metadata": {}, "source": [ "# Single transmon qubit characterization\n", "\n", "The experiments of this tutorial are meant to be executed with a Qblox Cluster controlling a transmon system.\n", "\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", "\n", "However, when using a dummy device, the analysis will not work because the experiments will return `np.nan` values.\n", "\n", "When using this notebook together with a dummy device, example data is loaded from the `\"./example_data/\"` directory." ] }, { "cell_type": "markdown", "id": "40311007", "metadata": {}, "source": [ "## Setup\n", "In this section we configure the hardware configuration which specifies the connectivity of our system." ] }, { "cell_type": "markdown", "id": "7c91abe3", "metadata": {}, "source": [ "### Configuration file\n", "\n", "This is a template hardware configuration file for a 1-qubit system with a flux-control line which can be used to tune the qubit frequency.\n", "\n", "The hardware setup is as follows, by cluster slot:\n", "- **QCM-RF** (Slot 6)\n", " - Drive line for `qubit` using fixed 80 MHz IF.\n", "- **QCM** (Slot 2)\n", " - Flux line for `qubit`.\n", "- **QRM-RF** (Slot 8)\n", " - Readout line for `qubit` 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": "code", "execution_count": 1, "id": "f037dd56", "metadata": {}, "outputs": [], "source": [ "from __future__ import annotations\n", "\n", "hardware_cfg = {\n", " \"backend\": \"quantify_scheduler.backends.qblox_backend.hardware_compile\",\n", " \"cluster0\": {\n", " \"sequence_to_file\": False, # Boolean flag which dumps waveforms and program dict to JSON file\n", " \"ref\": \"internal\", # Use shared clock reference of the cluster\n", " \"instrument_type\": \"Cluster\",\n", " # ============ DRIVE ============#\n", " \"cluster0_module6\": {\n", " \"instrument_type\": \"QCM_RF\",\n", " \"complex_output_0\": {\n", " \"output_att\": 0,\n", " \"dc_mixer_offset_I\": 0.0,\n", " \"dc_mixer_offset_Q\": 0.0,\n", " \"portclock_configs\": [\n", " {\n", " \"port\": \"qubit:mw\",\n", " \"clock\": \"qubit.01\",\n", " \"interm_freq\": 80e6,\n", " \"mixer_amp_ratio\": 1.0,\n", " \"mixer_phase_error_deg\": 0.0,\n", " }\n", " ],\n", " },\n", " },\n", " # ============ FLUX ============#\n", " \"cluster0_module2\": {\n", " \"instrument_type\": \"QCM\",\n", " \"real_output_0\": {\"portclock_configs\": [{\"port\": \"qubit:fl\", \"clock\": \"cl0.baseband\"}]},\n", " },\n", " # ============ READOUT ============#\n", " \"cluster0_module8\": {\n", " \"instrument_type\": \"QRM_RF\",\n", " \"complex_output_0\": {\n", " \"output_att\": 0,\n", " \"input_att\": 0,\n", " \"dc_mixer_offset_I\": 0.0,\n", " \"dc_mixer_offset_Q\": 0.0,\n", " \"lo_freq\": 7.5e9,\n", " \"portclock_configs\": [\n", " {\n", " \"port\": \"qubit:res\",\n", " \"clock\": \"qubit.ro\",\n", " \"mixer_amp_ratio\": 1.0,\n", " \"mixer_phase_error_deg\": 0.0,\n", " }\n", " ],\n", " },\n", " },\n", " },\n", "}" ] }, { "cell_type": "code", "execution_count": 2, "id": "be5a9e32", "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "import numpy as np\n", "from qcodes.instrument import find_or_create_instrument\n", "from qcodes.parameters import ManualParameter\n", "\n", "import quantify_core.data.handling as dh\n", "from qblox_instruments import Cluster, ClusterType\n", "from quantify_core.analysis.single_qubit_timedomain import RabiAnalysis, RamseyAnalysis, T1Analysis\n", "from quantify_core.analysis.spectroscopy_analysis import (\n", " QubitFluxSpectroscopyAnalysis,\n", " QubitSpectroscopyAnalysis,\n", " ResonatorFluxSpectroscopyAnalysis,\n", ")\n", "from quantify_core.measurement.control import MeasurementControl\n", "from quantify_core.visualization.pyqt_plotmon import PlotMonitor_pyqt as PlotMonitor\n", "from quantify_scheduler.device_under_test.quantum_device import QuantumDevice\n", "from quantify_scheduler.device_under_test.transmon_element import BasicTransmonElement\n", "from quantify_scheduler.gettables import ScheduleGettable\n", "from quantify_scheduler.instrument_coordinator import InstrumentCoordinator\n", "from quantify_scheduler.instrument_coordinator.components.qblox import ClusterComponent\n", "from quantify_scheduler.operations.gate_library import Measure, Reset\n", "from quantify_scheduler.operations.pulse_library import SetClockFrequency, SquarePulse\n", "from quantify_scheduler.resources import ClockResource\n", "from quantify_scheduler.schedules import heterodyne_spec_sched_nco, rabi_sched, t1_sched\n", "from quantify_scheduler.schedules.schedule import Schedule\n", "from quantify_scheduler.schedules.timedomain_schedules import ramsey_sched" ] }, { "cell_type": "markdown", "id": "2e0189c2", "metadata": {}, "source": [ "### Scan For Clusters\n", "\n", "We scan for the available devices connected via ethernet using the Plug & Play functionality of the Qblox Instruments package (see [Plug & Play](https://qblox-qblox-instruments.readthedocs-hosted.com/en/main/api_reference/tools.html#api-pnp) for more info)." ] }, { "cell_type": "code", "execution_count": 3, "id": "8013006b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "No devices found\n" ] } ], "source": [ "!qblox-pnp list" ] }, { "cell_type": "code", "execution_count": 4, "id": "7135b2ca", "metadata": {}, "outputs": [], "source": [ "cluster_ip = None # To run this tutorial on hardware, fill in the IP address of the cluster here\n", "cluster_name = \"cluster0\"" ] }, { "cell_type": "markdown", "id": "e8d66a47", "metadata": {}, "source": [ "### Connect to Cluster\n", "\n", "We now make a connection with the Cluster." ] }, { "cell_type": "code", "execution_count": 5, "id": "39364d86", "metadata": {}, "outputs": [], "source": [ "cluster = find_or_create_instrument(\n", " Cluster,\n", " recreate=True,\n", " name=cluster_name,\n", " identifier=cluster_ip,\n", " dummy_cfg=(\n", " {\n", " 2: ClusterType.CLUSTER_QCM,\n", " 4: ClusterType.CLUSTER_QRM,\n", " 6: ClusterType.CLUSTER_QCM_RF,\n", " 8: ClusterType.CLUSTER_QRM_RF,\n", " }\n", " if cluster_ip is None\n", " else None\n", " ),\n", ")" ] }, { "cell_type": "markdown", "id": "d3af3708", "metadata": {}, "source": [ "### Reset the Cluster\n", "\n", "We reset the Cluster to enter a well-defined state. Note that resetting will clear all stored parameters and repeats startup calibration, so resetting between experiments is usually not desirable." ] }, { "cell_type": "code", "execution_count": 6, "id": "71faa7a6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Status: CRITICAL, Flags: TEMPERATURE_OUT_OF_RANGE, Slot flags: SLOT2_TEMPERATURE_OUT_OF_RANGE, SLOT4_TEMPERATURE_OUT_OF_RANGE, SLOT6_TEMPERATURE_OUT_OF_RANGE, SLOT8_TEMPERATURE_OUT_OF_RANGE\n" ] } ], "source": [ "cluster.reset()\n", "print(cluster.get_system_state())" ] }, { "cell_type": "markdown", "id": "94e8a6af", "metadata": {}, "source": [ "Note that a dummy cluster will raise error flags, this is expected behavior and can be ignored." ] }, { "cell_type": "markdown", "id": "4e5d8157", "metadata": {}, "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." ] }, { "cell_type": "code", "execution_count": 7, "id": "cf8f9bea", "metadata": { "lines_to_next_cell": 2 }, "outputs": [], "source": [ "qubit = find_or_create_instrument(BasicTransmonElement, recreate=True, name=\"qubit\")\n", "qubit.measure.acq_channel(0)\n", "\n", "quantum_device = find_or_create_instrument(QuantumDevice, recreate=True, name=\"device_1q\")\n", "quantum_device.hardware_config(hardware_cfg)\n", "quantum_device.add_element(qubit)" ] }, { "cell_type": "markdown", "id": "b0f775fd", "metadata": { "lines_to_next_cell": 2 }, "source": [ "### Configure measurement control loop\n", "We will use a `MeasurementControl` object for data acquisition as well as an `InstrumentCoordinator` for controlling the instruments in our setup.\n", "\n", "The `PlotMonitor` is used for live plotting.\n", "\n", "All of these are then associated with the `QuantumDevice`." ] }, { "cell_type": "code", "execution_count": 8, "id": "397a93b3", "metadata": {}, "outputs": [], "source": [ "def configure_measurement_control_loop(\n", " device: QuantumDevice, cluster: Cluster, live_plotting: bool = False\n", ") -> tuple[MeasurementControl, InstrumentCoordinator]:\n", " meas_ctrl = find_or_create_instrument(MeasurementControl, recreate=True, name=\"meas_ctrl\")\n", " ic = find_or_create_instrument(InstrumentCoordinator, recreate=True, name=\"ic\")\n", "\n", " # Add cluster to instrument coordinator\n", " ic_cluster = ClusterComponent(cluster)\n", " ic.add_component(ic_cluster)\n", "\n", " if live_plotting:\n", " # Associate plot monitor with measurement controller\n", " plotmon = find_or_create_instrument(PlotMonitor, recreate=False, name=\"PlotMonitor\")\n", " meas_ctrl.instr_plotmon(plotmon.name)\n", "\n", " # Associate measurement controller and instrument coordinator with the quantum device\n", " device.instr_measurement_control(meas_ctrl.name)\n", " device.instr_instrument_coordinator(ic.name)\n", "\n", " return (meas_ctrl, ic)\n", "\n", "\n", "meas_ctrl, instrument_coordinator = configure_measurement_control_loop(quantum_device, cluster)" ] }, { "cell_type": "markdown", "id": "4eb64951", "metadata": {}, "source": [ "### Set data directory\n", "This directory is where all of the experimental data as well as all of the post processing will go." ] }, { "cell_type": "code", "execution_count": 9, "id": "eb001cb0", "metadata": {}, "outputs": [], "source": [ "# Enter your own dataset directory here!\n", "dh.set_datadir(Path(\"example_data\").resolve())" ] }, { "cell_type": "markdown", "id": "97b3f2c3", "metadata": {}, "source": [ "### Configure external flux control\n", "In the case of flux-tunable transmon qubits, we need to have some way of controlling the external flux.\n", "\n", "This can be done by setting an output bias on a module of the cluster which is then connected to the flux line.\n", "\n", "If your system is not using flux-tunable transmons, then you can skip to the next section." ] }, { "cell_type": "code", "execution_count": 10, "id": "d29a07d9", "metadata": {}, "outputs": [], "source": [ "flux_settable: callable = cluster.module2.out0_offset\n", "flux_settable.inter_delay = 100e-9 # Delay time in seconds between consecutive set operations.\n", "flux_settable.step = 0.3e-3 # Stepsize in V that this Parameter uses during set operation.\n", "flux_settable(0.0)" ] }, { "cell_type": "markdown", "id": "526decf6", "metadata": {}, "source": [ "### Activate NCO delay compensation\n", "Compensate for the digital propagation delay for each qubit (i.e each sequencer)\n", "\n", "For more info, please see the [API reference](https://qblox-qblox-instruments.readthedocs-hosted.com/en/main/api_reference/sequencer.html#Sequencer.nco_prop_delay_comp).\n", "\n", "To avoid mismatches between modulation and demodulation, the delay between any readout frequency or phase changes and the next acquisition should be equal or greater than the total propagation delay (146ns + user defined value)." ] }, { "cell_type": "code", "execution_count": 11, "id": "95248190", "metadata": {}, "outputs": [], "source": [ "for i in range(6):\n", " getattr(cluster.module8, f\"sequencer{i}\").nco_prop_delay_comp_en(True)\n", " getattr(cluster.module8, f\"sequencer{i}\").nco_prop_delay_comp(50)" ] }, { "cell_type": "markdown", "id": "3421449e", "metadata": {}, "source": [ "## Characterization experiments\n", "The sweep setpoints for all experiments (e.g. `frequency_setpoints` in the spectroscopy experiments) are only examples. The sweep setpoints should be changed to match your own system.\n", "\n", "We show two sets of experiments: The first contains generic characterization experiments for transmon qubits. The second contains 2D experiments for finding the flux sweetspot, applicable for flux-tunable qubits.\n", "\n", "Here we consider five standard characterization experiments for single qubit tuneup. The experiments are:\n", "1. Resonator spectroscopy\n", " - Used to find the frequency response of the readout resonator when the qubit is in $|0\\rangle$.\n", "2. Qubit spectroscopy (a.k.a two-tone)\n", " - Used to find the $|0\\rangle \\rightarrow |1\\rangle$ drive frequency.\n", "3. Rabi oscillations\n", " - Used to find precise excitation pulse required to excite the qubit to $|1\\rangle$.\n", "4. Ramsey oscillations\n", " - Used to tune the $|0\\rangle \\rightarrow |1\\rangle$ drive frequency more precisely.\n", " - Used to measure $T_2^*$.\n", "5. T1\n", " - Used to find the time it takes for the qubit to decay from $|1\\rangle$ to $|0\\rangle$, the $T_1$ time." ] }, { "cell_type": "markdown", "id": "0872fd5f", "metadata": {}, "source": [ "## Resonator spectroscopy" ] }, { "cell_type": "code", "execution_count": 12, "id": "dc1d0aac", "metadata": { "lines_to_next_cell": 2 }, "outputs": [], "source": [ "freq = ManualParameter(name=\"freq\", unit=\"Hz\", label=\"Frequency\")\n", "freq.batched = True\n", "freq.batch_size = 100\n", "\n", "spec_sched_kwargs = dict(\n", " pulse_amp=1 / 6,\n", " pulse_duration=2e-6,\n", " frequencies=freq,\n", " acquisition_delay=196e-9,\n", " integration_time=2e-6,\n", " init_duration=10e-6,\n", " port=qubit.ports.readout(),\n", " clock=qubit.name + \".ro\",\n", ")\n", "gettable = ScheduleGettable(\n", " quantum_device,\n", " schedule_function=heterodyne_spec_sched_nco,\n", " schedule_kwargs=spec_sched_kwargs,\n", " real_imag=False,\n", " batched=True,\n", ")\n", "\n", "meas_ctrl.gettables(gettable)" ] }, { "cell_type": "code", "execution_count": 13, "id": "a66abc5e", "metadata": {}, "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 freq \n", "Batch size limit: 100\n", "\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "c13c039565584b58ac62ec502eb96965", "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>\n", "Dimensions: (dim_0: 300)\n", "Coordinates:\n", " x0 (dim_0) float64 7.68e+09 7.68e+09 7.68e+09 ... 7.72e+09 7.72e+09\n", "Dimensions without coordinates: dim_0\n", "Data variables:\n", " y0 (dim_0) float64 nan nan nan nan nan nan ... nan nan nan nan nan nan\n", " y1 (dim_0) float64 nan nan nan nan nan nan ... nan nan nan nan nan nan\n", "Attributes:\n", " tuid: 20240422-183616-460-6bdb16\n", " name: resonator spectroscopy\n", " grid_2d: False\n", " grid_2d_uniformly_spaced: False\n", " 1d_2_settables_uniformly_spaced: False