{
"cells": [
{
"cell_type": "markdown",
"id": "38a8653e",
"metadata": {
"lines_to_next_cell": 0
},
"source": []
},
{
"cell_type": "markdown",
"id": "971a75c3",
"metadata": {
"tags": [
"header_banner"
]
},
"source": [
"\n",
" \n",
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "1305622d",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:08.552719Z",
"iopub.status.busy": "2025-03-12T18:00:08.552189Z",
"iopub.status.idle": "2025-03-12T18:00:12.905142Z",
"shell.execute_reply": "2025-03-12T18:00:12.903966Z"
},
"tags": [
"imports",
"header_0"
]
},
"outputs": [],
"source": [
"import rich # noqa:F401\n",
"\n",
"import quantify_core.data.handling as dh\n",
"from quantify_scheduler import QuantumDevice\n",
"\n",
"from utils import display_dict, initialize_hardware, run_schedule, show_connectivity # noqa:F401"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3f421ab3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:12.909185Z",
"iopub.status.busy": "2025-03-12T18:00:12.908431Z",
"iopub.status.idle": "2025-03-12T18:00:12.913020Z",
"shell.execute_reply": "2025-03-12T18:00:12.912182Z"
},
"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": "88e67d10",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:12.915265Z",
"iopub.status.busy": "2025-03-12T18:00:12.915044Z",
"iopub.status.idle": "2025-03-12T18:00:12.919925Z",
"shell.execute_reply": "2025-03-12T18:00:12.919067Z"
},
"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": "bdd77ea6",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:12.922072Z",
"iopub.status.busy": "2025-03-12T18:00:12.921859Z",
"iopub.status.idle": "2025-03-12T18:00:13.432803Z",
"shell.execute_reply": "2025-03-12T18:00:13.432073Z"
},
"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": "code",
"execution_count": 5,
"id": "0af7b253",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:13.435196Z",
"iopub.status.busy": "2025-03-12T18:00:13.434966Z",
"iopub.status.idle": "2025-03-12T18:00:13.439544Z",
"shell.execute_reply": "2025-03-12T18:00:13.438863Z"
},
"tags": [
"header_flux"
]
},
"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() # Get before setting to avoid jumps.\n",
"flux_settable(0.0)"
]
},
{
"cell_type": "markdown",
"id": "b90e6b98",
"metadata": {},
"source": [
"# Resonator Flux Spectroscopy\n",
"For flux tunable qubits, the resonance frequency of the readout resonator depends on the flux.\n",
"This can be used as a rough measure to find the sweetspot."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "06436112",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:13.441923Z",
"iopub.status.busy": "2025-03-12T18:00:13.441483Z",
"iopub.status.idle": "2025-03-12T18:00:13.445225Z",
"shell.execute_reply": "2025-03-12T18:00:13.444625Z"
},
"title": "HEADER"
},
"outputs": [],
"source": [
"import numpy as np\n",
"from qcodes.parameters import ManualParameter\n",
"\n",
"from quantify_scheduler import Schedule, ScheduleGettable\n",
"from quantify_scheduler.operations import IdlePulse, Measure"
]
},
{
"cell_type": "markdown",
"id": "dc8f9c8e",
"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": "10b9bdcd",
"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": "a93ec56e",
"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",
"This can be done by setting an output bias on a module of the cluster which is then connected to the flux line.\n",
"If your system is not using flux-tunable transmons, then you can skip to the next section."
]
},
{
"cell_type": "markdown",
"id": "e0494e93",
"metadata": {
"lines_to_next_cell": 2,
"title": "BODY"
},
"source": [
"## Resonator Flux Spectroscopy"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "46585e6e",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:13.447354Z",
"iopub.status.busy": "2025-03-12T18:00:13.447012Z",
"iopub.status.idle": "2025-03-12T18:00:13.455377Z",
"shell.execute_reply": "2025-03-12T18:00:13.454753Z"
},
"lines_to_next_cell": 0
},
"outputs": [],
"source": [
"def resonator_spectroscopy_schedule(\n",
" qubit, # noqa: ANN001\n",
" freqs: np.array,\n",
" repetitions: int = 1,\n",
") -> Schedule:\n",
" \"\"\"Schedule to sweep the resonator frequency.\"\"\"\n",
" sched = Schedule(\"schedule\", repetitions=repetitions)\n",
" for i, freq in enumerate(freqs):\n",
" sched.add(\n",
" Measure(\n",
" qubit.name,\n",
" acq_index=i,\n",
" freq=freq,\n",
" )\n",
" )\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",
"freqs.batch_size = 100\n",
"\n",
"spec_sched_kwargs = dict(\n",
" qubit=qubit,\n",
" freqs=freqs,\n",
")\n",
"gettable = ScheduleGettable(\n",
" quantum_device,\n",
" schedule_function=resonator_spectroscopy_schedule,\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": 8,
"id": "7113c666",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:13.457455Z",
"iopub.status.busy": "2025-03-12T18:00:13.456978Z",
"iopub.status.idle": "2025-03-12T18:00:16.023770Z",
"shell.execute_reply": "2025-03-12T18:00:16.022699Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Starting batched measurement...\n",
"Iterative settable(s) [outer loop(s)]:\n",
"\t out0_offset \n",
"Batched settable(s):\n",
"\t freq \n",
"Batch size limit: 100\n",
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4161cc381da5458e8fa0dbfbd978827e",
"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: 29kB\n", "Dimensions: (dim_0: 900)\n", "Coordinates:\n", " x0 (dim_0) float64 7kB 7.58e+09 7.58e+09 ... 7.62e+09 7.62e+09\n", " x1 (dim_0) float64 7kB 0.0 0.0 0.0 0.0 0.0 0.0 ... 1.0 1.0 1.0 1.0 1.0\n", "Dimensions without coordinates: dim_0\n", "Data variables:\n", " y0 (dim_0) float64 7kB nan nan nan nan nan nan ... nan nan nan nan nan\n", " y1 (dim_0) float64 7kB nan nan nan nan nan nan ... nan nan nan nan nan\n", "Attributes:\n", " tuid: 20250312-180013-462-0d1fa1\n", " name: resonator flux spectroscopy\n", " grid_2d: True\n", " grid_2d_uniformly_spaced: True\n", " 1d_2_settables_uniformly_spaced: False\n", " xlen: 300\n", " ylen: 3
setting | \nvalue | \n
---|---|
acq_protocol | \nSSBIntegrationComplex | \n
bin_mode | \naverage | \n
acq_return_type | \n<class 'complex'> | \n
repetitions | \n80 | \n
setting | \nvalue | \n
---|---|
interm_freq | \n80000000.0 | \n
setting | \nvalue | \n
---|---|
repetitions | \n80 | \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
---|---|
config_type | \nquantify_scheduler.backends.qblox_backend.Qblo... | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQRM_RF | \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 | \nQCM_RF | \n
setting | \nvalue | \n
---|---|
instrument_type | \nCluster | \n
sequence_to_file | \nFalse | \n
ref | \ninternal | \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
---|---|
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
---|---|
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
---|---|
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
---|---|
interm_freq | \n80000000.0 | \n
setting | \nvalue | \n
---|---|
num_bins | \n100 | \n
index | \n0 | \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
---|---|
reference_source | \ninternal | \n
sync_on_external_trigger | \nNone | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n