{ "cells": [ { "cell_type": "markdown", "id": "83efecaa", "metadata": {}, "source": [ "# Single transmon qubit spectroscopy\n", "Here we will carry out qubit spectroscopy on a single transmon in order to find the $|0\\rangle \\rightarrow |1\\rangle$ drive frequency." ] }, { "cell_type": "code", "execution_count": 1, "id": "90cd918c", "metadata": { "execution": { "iopub.execute_input": "2025-06-23T09:10:04.955618Z", "iopub.status.busy": "2025-06-23T09:10:04.955455Z", "iopub.status.idle": "2025-06-23T09:10:06.732050Z", "shell.execute_reply": "2025-06-23T09:10:06.731249Z" }, "tags": [ "imports" ] }, "outputs": [], "source": [ "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.spectroscopy_analysis import QubitSpectroscopyAnalysis\n", "from quantify_scheduler import ClockResource, QuantumDevice, Schedule, ScheduleGettable\n", "from quantify_scheduler.device_under_test.device_element import DeviceElement\n", "from quantify_scheduler.operations import (\n", " IdlePulse,\n", " Measure,\n", " Reset,\n", " SetClockFrequency,\n", " VoltageOffset,\n", ")\n", "from quantify_scheduler.operations.control_flow_library import LoopOperation\n", "\n", "from utils import ( # noqa:F401 # noqa:F401\n", " display_dict,\n", " initialize_hardware,\n", " run_schedule,\n", " show_connectivity,\n", ")" ] }, { "cell_type": "code", "execution_count": 2, "id": "a27b911c", "metadata": { "execution": { "iopub.execute_input": "2025-06-23T09:10:06.735114Z", "iopub.status.busy": "2025-06-23T09:10:06.734039Z", "iopub.status.idle": "2025-06-23T09:10:06.737658Z", "shell.execute_reply": "2025-06-23T09:10:06.737180Z" }, "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": "0a6e7ef3", "metadata": { "execution": { "iopub.execute_input": "2025-06-23T09:10:06.739098Z", "iopub.status.busy": "2025-06-23T09:10:06.738835Z", "iopub.status.idle": "2025-06-23T09:10:06.741961Z", "shell.execute_reply": "2025-06-23T09:10:06.741455Z" }, "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": "ee7a0776", "metadata": { "execution": { "iopub.execute_input": "2025-06-23T09:10:06.743362Z", "iopub.status.busy": "2025-06-23T09:10:06.743108Z", "iopub.status.idle": "2025-06-23T09:10:07.343633Z", "shell.execute_reply": "2025-06-23T09:10:07.343009Z" }, "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": "fb60d20a", "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": "96a360d5", "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": "1f15f999", "metadata": { "lines_to_next_cell": 2, "title": "BODY" }, "source": [ "## Qubit spectroscopy" ] }, { "cell_type": "code", "execution_count": 5, "id": "f201ff8f", "metadata": { "execution": { "iopub.execute_input": "2025-06-23T09:10:07.346288Z", "iopub.status.busy": "2025-06-23T09:10:07.345935Z", "iopub.status.idle": "2025-06-23T09:10:07.353414Z", "shell.execute_reply": "2025-06-23T09:10:07.352920Z" }, "lines_to_next_cell": 0 }, "outputs": [], "source": [ "def two_tone_spec(\n", " qubit: DeviceElement,\n", " spec_pulse_frequencies: np.array,\n", " spec_pulse_amp: float = 0.05,\n", " repetitions: int = 1,\n", ") -> Schedule:\n", " \"\"\"\n", " Generate a schedule for performing fast two-tone spectroscopy.\n", "\n", " To avoid the qubit reset time, the schedule uses sequential averaging.\n", "\n", " Parameters\n", " ----------\n", " qubit\n", " qubit that should be used.\n", " spec_pulse_frequencies\n", " Sample frequencies for the spectroscopy pulse in Hertz.\n", " spec_pulse_amp\n", " Amplitude of the continuous spectroscopy tone.\n", " repetitions\n", " The amount of times the Schedule will be repeated.\n", "\n", " \"\"\"\n", " sched = Schedule(\"two-tone\", repetitions=1)\n", " sched.add_resource(ClockResource(name=qubit.name + \".01\", freq=spec_pulse_frequencies.flat[0]))\n", "\n", " # Turn on the drive\n", " sched.add(\n", " VoltageOffset(\n", " offset_path_I=spec_pulse_amp,\n", " offset_path_Q=0,\n", " port=f\"{qubit.name}:mw\",\n", " clock=f\"{qubit.name}.01\",\n", " )\n", " )\n", " for acq_idx, spec_pulse_freq in enumerate(spec_pulse_frequencies):\n", " sched.add(Reset(qubit.name))\n", "\n", " # Setting the probing frequency to a new value\n", " sched.add(SetClockFrequency(clock=f\"{qubit.name}.01\", clock_freq_new=spec_pulse_freq))\n", "\n", " # Create a subschedule that measures the qubit.\n", " subsched = Schedule(\"meas\")\n", " subsched.add(Measure(qubit.name, acq_index=acq_idx))\n", " # Add required time between certain operations\n", " subsched.add(IdlePulse(8e-9))\n", " # measure `repetitions` times at every frequency point\n", " sched.add(LoopOperation(subsched, repetitions=repetitions))\n", "\n", " # Turn off the drive at the end of the experiment\n", " sched.add(\n", " VoltageOffset(\n", " offset_path_I=0.0, offset_path_Q=0, port=f\"{qubit.name}:mw\", clock=f\"{qubit.name}.01\"\n", " )\n", " )\n", " # Add required time at the end\n", " sched.add(IdlePulse(8e-9))\n", " return sched\n", "\n", "\n", "freqs = ManualParameter(name=\"freq\", unit=\"Hz\", label=\"Frequency\")\n", "freqs.batched = True\n", "\n", "qubit_spec_sched_kwargs = dict(qubit=qubit, spec_pulse_frequencies=freqs, spec_pulse_amp=0.05)\n", "\n", "gettable = ScheduleGettable(\n", " quantum_device,\n", " schedule_function=two_tone_spec,\n", " schedule_kwargs=qubit_spec_sched_kwargs,\n", " real_imag=False,\n", " batched=True,\n", ")\n", "\n", "meas_ctrl.gettables(gettable)" ] }, { "cell_type": "code", "execution_count": 6, "id": "3cda3f7c", "metadata": { "execution": { "iopub.execute_input": "2025-06-23T09:10:07.354828Z", "iopub.status.busy": "2025-06-23T09:10:07.354671Z", "iopub.status.idle": "2025-06-23T09:10:08.800972Z", "shell.execute_reply": "2025-06-23T09:10:08.800332Z" } }, "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: 300\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/builds/qblox/packages/software/qblox_instruments_docs/.venv/lib/python3.9/site-packages/quantify_scheduler/backends/circuit_to_device.py:433: RuntimeWarning: Clock 'q0.01' has conflicting frequency definitions: 5080000000.0 Hz in the schedule and 5100000000.0 Hz in the device config. The clock is set to '5080000000.0'. Ensure the schedule clock resource matches the device config clock frequency or set the clock frequency in the device config to np.NaN to omit this warning.\n", " warnings.warn(\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7be2787ddf4d42e9b3ec2830aa19e735", "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: 7kB\n", "Dimensions: (dim_0: 300)\n", "Coordinates:\n", " x0 (dim_0) float64 2kB 5.08e+09 5.08e+09 ... 5.12e+09 5.12e+09\n", "Dimensions without coordinates: dim_0\n", "Data variables:\n", " y0 (dim_0) float64 2kB nan nan nan nan nan nan ... nan nan nan nan nan\n", " y1 (dim_0) float64 2kB nan nan nan nan nan nan ... nan nan nan nan nan\n", "Attributes:\n", " tuid: 20250623-091007-356-4c97a9\n", " name: Two-tone\n", " grid_2d: False\n", " grid_2d_uniformly_spaced: False\n", " 1d_2_settables_uniformly_spaced: False
setting | \nvalue | \n
---|---|
interm_freq | \n80000000.0 | \n
setting | \nvalue | \n
---|---|
interm_freq | \n80000000.0 | \n
setting | \nvalue | \n
---|---|
lo_freq | \n7.500000e+09 | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
reference_source | \ninternal | \n
sync_on_external_trigger | \nNone | \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
---|---|
q0:mw-q0.01 | \n10 | \n
q1:mw-q1.01 | \n10 | \n
q0:res-q0.ro | \n60 | \n
q1:res-q1.ro | \n60 | \n
setting | \nvalue | \n
---|---|
instrument_type | \nCluster | \n
sequence_to_file | \nFalse | \n
ref | \ninternal | \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 | \n5000000000.0 | \n
lo1_freq | \nNone | \n
lo2_freq | \nNone | \n
lo3_freq | \nNone | \n
lo4_freq | \nNone | \n
lo5_freq | \nNone | \n
in0_freq | \nNone | \n
in1_freq | \nNone | \n
out0_att | \n10 | \n
out1_att | \nNone | \n
out2_att | \nNone | \n
out3_att | \nNone | \n
out4_att | \nNone | \n
out5_att | \nNone | \n
in0_att | \nNone | \n
in1_att | \nNone | \n
setting | \nvalue | \n
---|---|
sync_en | \nTrue | \n
channel_name | \ncomplex_output_0 | \n
channel_name_measure | \n[complex_input_0] | \n
connected_output_indices | \n(0, 1) | \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 | \n100000000.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 | \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
---|---|
repetitions | \n1 | \n
setting | \nvalue | \n
---|---|
acq_protocol | \nSSBIntegrationComplex | \n
bin_mode | \naverage | \n
acq_return_type | \n<class 'complex'> | \n
repetitions | \n1 | \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 | \n7500000000.0 | \n
lo1_freq | \nNone | \n
lo2_freq | \nNone | \n
lo3_freq | \nNone | \n
lo4_freq | \nNone | \n
lo5_freq | \nNone | \n
in0_freq | \n7500000000.0 | \n
in1_freq | \nNone | \n
out0_att | \n60 | \n
out1_att | \nNone | \n
out2_att | \nNone | \n
out3_att | \nNone | \n
out4_att | \nNone | \n
out5_att | \nNone | \n
in0_att | \nNone | \n
in1_att | \nNone | \n
setting | \nvalue | \n
---|---|
config_type | \nquantify_scheduler.backends.qblox_backend.Qblo... | \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
---|---|
lo_freq | \n7.500000e+09 | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQCM | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQRM_RF | \n
setting | \nvalue | \n
---|---|
num_bins | \n300 | \n
index | \n0 | \n
setting | \nvalue | \n
---|---|
repetitions | \n1 | \n
setting | \nvalue | \n
---|---|
graph | \n[[cluster0.module6.complex_output_0, q0:mw], [... | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQCM_RF | \n