{
"cells": [
{
"cell_type": "markdown",
"id": "5421891a",
"metadata": {
"lines_to_next_cell": 0
},
"source": []
},
{
"cell_type": "markdown",
"id": "6bbf57af",
"metadata": {
"tags": [
"header_banner"
]
},
"source": [
"\n",
" \n",
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "42f01c16",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:26.263103Z",
"iopub.status.busy": "2025-03-12T18:00:26.262939Z",
"iopub.status.idle": "2025-03-12T18:00:28.208982Z",
"shell.execute_reply": "2025-03-12T18:00:28.207938Z"
},
"tags": [
"imports",
"header_0"
]
},
"outputs": [],
"source": [
"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_scheduler import QuantumDevice, Schedule, ScheduleGettable\n",
"from quantify_scheduler.operations import Measure, Reset\n",
"from quantify_scheduler.operations.control_flow_library import LoopOperation\n",
"from quantify_scheduler.operations.pulse_library import IdlePulse, SetClockFrequency, VoltageOffset\n",
"\n",
"from utils import display_dict, initialize_hardware, run_schedule, show_connectivity # noqa:F401"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "25f13667",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:28.213134Z",
"iopub.status.busy": "2025-03-12T18:00:28.211566Z",
"iopub.status.idle": "2025-03-12T18:00:28.216029Z",
"shell.execute_reply": "2025-03-12T18:00:28.215392Z"
},
"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": "b10a38ce",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:28.217693Z",
"iopub.status.busy": "2025-03-12T18:00:28.217520Z",
"iopub.status.idle": "2025-03-12T18:00:28.221190Z",
"shell.execute_reply": "2025-03-12T18:00:28.220582Z"
},
"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": "935dc327",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:28.222817Z",
"iopub.status.busy": "2025-03-12T18:00:28.222526Z",
"iopub.status.idle": "2025-03-12T18:00:28.906753Z",
"shell.execute_reply": "2025-03-12T18:00:28.906212Z"
},
"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": "6af8b54c",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:28.909255Z",
"iopub.status.busy": "2025-03-12T18:00:28.909069Z",
"iopub.status.idle": "2025-03-12T18:00:28.912951Z",
"shell.execute_reply": "2025-03-12T18:00:28.912500Z"
},
"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": "395a5854",
"metadata": {},
"source": [
"# Qubit Flux Spectroscopy\n",
"For flux tunable qubits, the resonance frequency of the qubit depends on the flux.\n",
"This can be used to find the sweetspot."
]
},
{
"cell_type": "markdown",
"id": "186e7f3c",
"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": "1b2e232e",
"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": "e2a266c7",
"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": "87cdc13c",
"metadata": {
"lines_to_next_cell": 2,
"title": "BODY"
},
"source": [
"## Qubit Flux Spectroscopy"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "f9bdd5f5",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:28.914544Z",
"iopub.status.busy": "2025-03-12T18:00:28.914396Z",
"iopub.status.idle": "2025-03-12T18:00:28.921224Z",
"shell.execute_reply": "2025-03-12T18:00:28.920795Z"
},
"lines_to_next_cell": 2
},
"outputs": [],
"source": [
"def two_tone_spec(\n",
" qubit, # noqa: ANN001\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",
"\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",
" sched.add(SetClockFrequency(clock=f\"{qubit.name}.01\", clock_freq_new=spec_pulse_freq))\n",
" subsched = Schedule(\"meas\")\n",
" subsched.add(Measure(qubit.name, acq_index=acq_idx))\n",
" subsched.add(IdlePulse(8e-9))\n",
" # measure `repetitions` times at every frequency point\n",
" sched.add(LoopOperation(subsched, repetitions=repetitions))\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",
" 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": 7,
"id": "e548fb0e",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-12T18:00:28.922603Z",
"iopub.status.busy": "2025-03-12T18:00:28.922457Z",
"iopub.status.idle": "2025-03-12T18:00:34.814392Z",
"shell.execute_reply": "2025-03-12T18:00:34.813772Z"
}
},
"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: 900\n",
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ec49d363dc47439ca3231766b4b19bf7",
"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 5.08e+09 5.08e+09 ... 5.12e+09 5.12e+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-180028-925-900444\n", " name: flux two-tone\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
---|---|
interm_freq | \n80000000.0 | \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 | \n5020000000.0 | \n
lo1_freq | \nNone | \n
out0_att | \n10 | \n
out1_att | \nNone | \n
in0_att | \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
---|---|
acq_protocol | \nSSBIntegrationComplex | \n
bin_mode | \naverage | \n
acq_return_type | \n<class 'complex'> | \n
repetitions | \n1 | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \n
setting | \nvalue | \n
---|---|
lo_freq | \n7.500000e+09 | \n
setting | \nvalue | \n
---|---|
repetitions | \n1 | \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 | \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
---|---|
repetitions | \n1 | \n
setting | \nvalue | \n
---|---|
auto_lo_cal | \non_lo_interm_freq_change | \n
auto_sideband_cal | \non_interm_freq_change | \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
---|---|
num_bins | \n300 | \n
index | \n0 | \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
---|---|
interm_freq | \n80000000.0 | \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
---|---|
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
---|---|
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
---|---|
reference_source | \ninternal | \n
sync_on_external_trigger | \nNone | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQCM | \n
setting | \nvalue | \n
---|---|
lo_freq | \n7.500000e+09 | \n
setting | \nvalue | \n
---|---|
instrument_type | \nQCM_RF | \n