See also

A Jupyter notebook version of this tutorial can be downloaded here.

Qubit Flux Spectroscopy#

For flux tunable qubits, the resonance frequency of the qubit depends on the flux. This can be used to find the sweetspot.

[1]:
import json

import numpy as np
import rich  # noqa:F401
from qcodes.parameters import ManualParameter

import quantify_core.data.handling as dh
from quantify_scheduler import Schedule
from quantify_scheduler.device_under_test.quantum_device import QuantumDevice
from quantify_scheduler.gettables import ScheduleGettable
from quantify_scheduler.operations.gate_library import Measure, Reset, X

from utils import initialize_hardware, run  # noqa:F401
[2]:
hw_config_path = "configs/tuning_transmon_coupled_pair_hardware_config.json"
device_path = "devices/transmon_device_2q.json"
[3]:
with open(hw_config_path) as hw_cfg_json_file:
    hardware_cfg = json.load(hw_cfg_json_file)

# Enter your own dataset directory here!
dh.set_datadir(dh.default_datadir())
Data will be saved in:
/root/quantify-data
[4]:
quantum_device = QuantumDevice.from_json_file(device_path)
qubit = quantum_device.get_element("q0")
quantum_device.hardware_config(hardware_cfg)
meas_ctrl, _, cluster = initialize_hardware(quantum_device, ip=None)
/builds/qblox/packages/software/qblox_instruments_docs/.venv/lib/python3.9/site-packages/quantify_scheduler/backends/types/qblox.py:1220: ValidationWarning: Setting `auto_lo_cal=on_lo_interm_freq_change` will overwrite settings `dc_offset_i=0.0` and `dc_offset_q=0.0`. To suppress this warning, do not set either `dc_offset_i` or `dc_offset_q` for this port-clock.
  warnings.warn(
/builds/qblox/packages/software/qblox_instruments_docs/.venv/lib/python3.9/site-packages/quantify_scheduler/backends/types/qblox.py:1235: ValidationWarning: Setting `auto_sideband_cal=on_interm_freq_change` will overwrite settings `amp_ratio=1.0` and `phase_error=0.0`. To suppress this warning, do not set either `amp_ratio` or `phase_error` for this port-clock.
  warnings.warn(
[5]:
flux_settable: callable = cluster.module2.out0_offset
flux_settable.inter_delay = 100e-9  # Delay time in seconds between consecutive set operations.
flux_settable.step = 0.3e-3  # Stepsize in V that this Parameter uses during set operation.
flux_settable()  # Get before setting to avoid jumps.
flux_settable(0.0)

Setup#

In this section we configure the hardware configuration which specifies the connectivity of our system.

The experiments of this tutorial are meant to be executed with a Qblox Cluster controlling a transmon system. 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. When using a dummy device, the analysis will not work because the experiments will return np.nan values.

Configuration file#

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.

The hardware connectivity is as follows, by cluster slot:

  • QCM (Slot 2)

    • \(\text{O}^{1}\): Flux line for q0.

    • \(\text{O}^{2}\): Flux line for q1.

  • QCM-RF (Slot 6)

    • \(\text{O}^{1}\): Drive line for q0 using fixed 80 MHz IF.

    • \(\text{O}^{2}\): Drive line for q1 using fixed 80 MHz IF.

  • QRM-RF (Slot 8)

    • \(\text{O}^{1}\) and \(\text{I}^{1}\): Shared readout line for q0/q1 using a fixed LO set at 7.5 GHz.

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.

Quantum device settings#

Here we initialize our QuantumDevice and our qubit parameters, checkout this tutorial for further details.

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.

Configure external flux control#

In the case of flux-tunable transmon qubits, we need to have some way of controlling the external flux. This can be done by setting an output bias on a module of the cluster which is then connected to the flux line. If your system is not using flux-tunable transmons, then you can skip to the next section.

Qubit Flux Spectroscopy#

[6]:
def two_tone_spec_sched_nco(
    qubit,  # noqa: ANN001
    spec_pulse_frequencies: np.array,
    repetitions: int = 1,
) -> Schedule:
    """
    Generate a batched schedule for performing fast two-tone spectroscopy.

    Using the X gate to perform the frequency sweep on the qubit.

    Parameters
    ----------
    qubit
        qubit that should be used.
    spec_pulse_frequencies
        Sample frequencies for the spectroscopy pulse in Hertz.
    repetitions
        The amount of times the Schedule will be repeated.

    """
    sched = Schedule("two-tone", repetitions)

    for acq_idx, spec_pulse_freq in enumerate(spec_pulse_frequencies):
        sched.add(Reset(qubit.name))
        sched.add(X(qubit.name, freq=spec_pulse_freq))
        sched.add(Measure(qubit.name, acq_index=acq_idx), rel_time=200e-9)
    return sched


freqs = ManualParameter(name="freq", unit="Hz", label="Frequency")
freqs.batched = True

qubit_spec_sched_kwargs = dict(
    qubit=qubit,
    spec_pulse_frequencies=freqs,
)

gettable = ScheduleGettable(
    quantum_device,
    schedule_function=two_tone_spec_sched_nco,
    schedule_kwargs=qubit_spec_sched_kwargs,
    real_imag=False,
    batched=True,
)

meas_ctrl.gettables(gettable)
[7]:
quantum_device.cfg_sched_repetitions(400)
center = qubit.clock_freqs.f01()
frequency_setpoints = np.linspace(center - 20e6, center + 20e6, 300)
flux_setpoints = np.linspace(0, 1, 3)
meas_ctrl.settables([freqs, flux_settable])
meas_ctrl.setpoints_grid((frequency_setpoints, flux_setpoints))

qfs_ds = meas_ctrl.run("flux two-tone")
qfs_ds
Starting batched measurement...
Iterative settable(s) [outer loop(s)]:
         out0_offset
Batched settable(s):
         freq
Batch size limit: 900

/builds/qblox/packages/software/qblox_instruments_docs/.venv/lib/python3.9/site-packages/quantify_scheduler/backends/types/qblox.py:1235: ValidationWarning: Setting `auto_sideband_cal=on_interm_freq_change` will overwrite settings `amp_ratio=1.0` and `phase_error=0.0`. To suppress this warning, do not set either `amp_ratio` or `phase_error` for this port-clock.
  warnings.warn(
/builds/qblox/packages/software/qblox_instruments_docs/.venv/lib/python3.9/site-packages/quantify_scheduler/backends/types/qblox.py:1235: ValidationWarning: Setting `auto_sideband_cal=on_interm_freq_change` will overwrite settings `amp_ratio=1.0` and `phase_error=0.0`. To suppress this warning, do not set either `amp_ratio` or `phase_error` for this port-clock.
  warnings.warn(
[7]:
<xarray.Dataset> Size: 29kB
Dimensions:  (dim_0: 900)
Coordinates:
    x0       (dim_0) float64 7kB 5.08e+09 5.08e+09 ... 5.12e+09 5.12e+09
    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
Dimensions without coordinates: dim_0
Data variables:
    y0       (dim_0) float64 7kB nan nan nan nan nan nan ... nan nan nan nan nan
    y1       (dim_0) float64 7kB nan nan nan nan nan nan ... nan nan nan nan nan
Attributes:
    tuid:                             20241113-023518-520-d14c1a
    name:                             flux two-tone
    grid_2d:                          True
    grid_2d_uniformly_spaced:         True
    1d_2_settables_uniformly_spaced:  False
    xlen:                             300
    ylen:                             3
[8]:
rich.print(quantum_device.hardware_config())
{
    'config_type': 'quantify_scheduler.backends.qblox_backend.QbloxHardwareCompilationConfig',
    'hardware_description': {
        'cluster0': {
            'instrument_type': 'Cluster',
            'modules': {
                '6': {'instrument_type': 'QCM_RF'},
                '2': {'instrument_type': 'QCM'},
                '8': {'instrument_type': 'QRM_RF'}
            },
            'sequence_to_file': False,
            'ref': 'internal'
        }
    },
    'hardware_options': {
        'output_att': {'q0:mw-q0.01': 10, 'q1:mw-q1.01': 10, 'q0:res-q0.ro': 60, 'q1:res-q1.ro': 60},
        'mixer_corrections': {
            'q0:mw-q0.01': {
                'auto_lo_cal': 'on_lo_interm_freq_change',
                'auto_sideband_cal': 'on_interm_freq_change',
                'dc_offset_i': None,
                'dc_offset_q': None,
                'amp_ratio': 1.0,
                'phase_error': 0.0
            },
            'q1:mw-q1.01': {
                'auto_lo_cal': 'on_lo_interm_freq_change',
                'auto_sideband_cal': 'on_interm_freq_change',
                'dc_offset_i': None,
                'dc_offset_q': None,
                'amp_ratio': 1.0,
                'phase_error': 0.0
            },
            'q0:res-q0.ro': {
                'auto_lo_cal': 'on_lo_interm_freq_change',
                'auto_sideband_cal': 'on_interm_freq_change',
                'dc_offset_i': None,
                'dc_offset_q': None,
                'amp_ratio': 1.0,
                'phase_error': 0.0
            },
            'q1:res-q1.ro': {
                'auto_lo_cal': 'on_lo_interm_freq_change',
                'auto_sideband_cal': 'on_interm_freq_change',
                'dc_offset_i': None,
                'dc_offset_q': None,
                'amp_ratio': 1.0,
                'phase_error': 0.0
            }
        },
        'modulation_frequencies': {
            'q0:mw-q0.01': {'interm_freq': 80000000.0},
            'q1:mw-q1.01': {'interm_freq': 80000000.0},
            'q0:res-q0.ro': {'lo_freq': 7500000000.0},
            'q1:res-q1.ro': {'lo_freq': 7500000000.0}
        }
    },
    'connectivity': {
        'graph': [
            ['cluster0.module6.complex_output_0', 'q0:mw'],
            ['cluster0.module6.complex_output_1', 'q1:mw'],
            ['cluster0.module2.real_output_0', 'q0:fl'],
            ['cluster0.module2.real_output_1', 'q1:fl'],
            ['cluster0.module8.complex_output_0', 'q0:res'],
            ['cluster0.module8.complex_output_0', 'q1:res']
        ]
    }
}
[9]:
quantum_device.to_json_file("devices/")
[9]:
'devices/device_2q_2024-11-13_02-35-20_UTC.json'