{
"cells": [
{
"cell_type": "markdown",
"id": "be40871b",
"metadata": {
"lines_to_next_cell": 0
},
"source": []
},
{
"cell_type": "markdown",
"id": "e40ef596",
"metadata": {
"tags": [
"header_banner"
]
},
"source": [
"\n",
" \n",
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "544536c9",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:19.446471Z",
"iopub.status.busy": "2025-03-12T18:00:19.446291Z",
"iopub.status.idle": "2025-03-12T18:00:21.613902Z",
"shell.execute_reply": "2025-03-12T18:00:21.612895Z"
},
"tags": [
"imports",
"header_0"
]
},
"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_core.data.handling import load_dataset\n",
"from quantify_scheduler import QuantumDevice, Schedule, ScheduleGettable\n",
"from quantify_scheduler.operations import Measure, Reset, X\n",
"from quantify_scheduler.operations.pulse_library import SetClockFrequency\n",
"from quantify_scheduler.resources import ClockResource\n",
"\n",
"from utils import display_dict, initialize_hardware, run_schedule, show_connectivity # noqa:F401"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "69f592eb",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:21.617568Z",
"iopub.status.busy": "2025-03-12T18:00:21.616725Z",
"iopub.status.idle": "2025-03-12T18:00:21.620645Z",
"shell.execute_reply": "2025-03-12T18:00:21.619941Z"
},
"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": "0bb29b71",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:21.622753Z",
"iopub.status.busy": "2025-03-12T18:00:21.622109Z",
"iopub.status.idle": "2025-03-12T18:00:21.626496Z",
"shell.execute_reply": "2025-03-12T18:00:21.625749Z"
},
"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": "36dfe1fd",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:21.628123Z",
"iopub.status.busy": "2025-03-12T18:00:21.627958Z",
"iopub.status.idle": "2025-03-12T18:00:22.329056Z",
"shell.execute_reply": "2025-03-12T18:00:22.327232Z"
},
"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": "5ea20d40",
"metadata": {},
"source": [
"# 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": "markdown",
"id": "22b3b7f6",
"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": "c91c594e",
"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": "76716904",
"metadata": {
"lines_to_next_cell": 2,
"title": "BODY"
},
"source": [
"## Qubit spectroscopy"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5ae04f10",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:22.333184Z",
"iopub.status.busy": "2025-03-12T18:00:22.332663Z",
"iopub.status.idle": "2025-03-12T18:00:22.341180Z",
"shell.execute_reply": "2025-03-12T18:00:22.339994Z"
}
},
"outputs": [],
"source": [
"def two_tone_spec_sched_nco(\n",
" qubit, # noqa: ANN001\n",
" spec_pulse_frequencies: np.array,\n",
" repetitions: int = 1,\n",
") -> Schedule:\n",
" \"\"\"\n",
" Generate a batched schedule for performing fast two-tone spectroscopy.\n",
"\n",
" Using the X gate to perform the frequency sweep on the qubit.\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",
" repetitions\n",
" The amount of times the Schedule will be repeated.\n",
"\n",
" \"\"\"\n",
" sched = Schedule(\"two-tone\", repetitions)\n",
" sched.add_resource(ClockResource(name=qubit.name + \".01\", freq=spec_pulse_frequencies.flat[0]))\n",
"\n",
" for acq_idx, spec_pulse_freq in enumerate(spec_pulse_frequencies):\n",
" sched.add(Reset(qubit.name))\n",
" sched.add(SetClockFrequency(clock=qubit.name + \".01\", clock_freq_new=spec_pulse_freq))\n",
" sched.add(X(qubit.name, freq=spec_pulse_freq))\n",
" sched.add(Measure(qubit.name, acq_index=acq_idx), rel_time=200e-9)\n",
" return sched"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "44950944",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:22.343797Z",
"iopub.status.busy": "2025-03-12T18:00:22.343260Z",
"iopub.status.idle": "2025-03-12T18:00:22.351580Z",
"shell.execute_reply": "2025-03-12T18:00:22.350741Z"
},
"lines_to_next_cell": 0
},
"outputs": [],
"source": [
"freqs = ManualParameter(name=\"freq\", unit=\"Hz\", label=\"Frequency\")\n",
"freqs.batched = True\n",
"\n",
"qubit_spec_sched_kwargs = dict(\n",
" qubit=qubit,\n",
" spec_pulse_frequencies=freqs,\n",
")\n",
"\n",
"gettable = ScheduleGettable(\n",
" quantum_device,\n",
" schedule_function=two_tone_spec_sched_nco,\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": 7,
"id": "0b6bf205",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:22.354047Z",
"iopub.status.busy": "2025-03-12T18:00:22.353431Z",
"iopub.status.idle": "2025-03-12T18:00:23.219638Z",
"shell.execute_reply": "2025-03-12T18:00:23.218798Z"
}
},
"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:414: RuntimeWarning: Clock 'q0.01' has conflicting frequency definitions: 6080000000.0 Hz in the schedule and 5100000000.0 Hz in the device config. The clock is set to '6080000000.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": "61eee7db004149c49fcb7d8f3892f4d3",
"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 6.08e+09 6.08e+09 ... 6.12e+09 6.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: 20250312-180022-359-9784a8\n", " name: Two-tone\n", " grid_2d: False\n", " grid_2d_uniformly_spaced: False\n", " 1d_2_settables_uniformly_spaced: False
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
---|---|
instrument_type | \nCluster | \n
sequence_to_file | \nFalse | \n
ref | \ninternal | \n
setting | \nvalue | \n
---|---|
config_type | \nquantify_scheduler.backends.qblox_backend.Qblo... | \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 | \n6000000000.0 | \n
lo1_freq | \nNone | \n
out0_att | \n10 | \n
out1_att | \nNone | \n
in0_att | \nNone | \n
setting | \nvalue | \n
---|---|
num_bins | \n300 | \n
index | \n0 | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQRM_RF | \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
---|---|
interm_freq | \n80000000.0 | \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_RF | \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
---|---|
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
out0_att | \n60 | \n
out1_att | \nNone | \n
in0_att | \nNone | \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
---|---|
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
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
graph | \n[[cluster0.module6.complex_output_0, q0:mw], [... | \n
setting | \nvalue | \n
---|---|
lo_freq | \n7.500000e+09 | \n
setting | \nvalue | \n
---|---|
lo_freq | \n7.500000e+09 | \n
setting | \nvalue | \n
---|---|
repetitions | \n300 | \n
setting | \nvalue | \n
---|---|
interm_freq | \n80000000.0 | \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
---|---|
q0:mw-q0.01 | \n10 | \n
q1:mw-q1.01 | \n10 | \n
q0:res-q0.ro | \n60 | \n
q1:res-q1.ro | \n60 | \n