Skip to content

Spin Qubit Pulse Sequences with the HDAWG

This notebook shows you how to use pulse sequences with an HDAWG to realize various experiments. While the sequences are mostly general, they are adapted to those typically used for spin qubits by adding the gate pulsing to control between Coulomb and spin blockade.

List of experiemnts

  • Rabi - sweep length of burst
  • Ramsey variant 1 - sweep delay with constant burst duration
  • Ramsey variant 2 - sweep burst duration at constant delay
  • Ramsey variant 3 - sweep phase of second burst and delay between bursts

0. General Imports

import numpy as np
from laboneq.simple import *

DO_EMULATION = True  # run in emulation mode by default

1. Device Setup

1.1 Calibration

def calibrate_devices(device_setup):
    device_setup.logical_signal_groups["q0"].logical_signals[
        "drive_line"
    ].calibration = SignalCalibration(
        oscillator=Oscillator(
            uid="drive_q0_osc", frequency=1e8, modulation_type=ModulationType.HARDWARE
        ),
        mixer_calibration=MixerCalibration(
            voltage_offsets=[0.0, 0.0],
            correction_matrix=[
                [1.0, 0.0],
                [0.0, 1.0],
            ],
        ),
    )

1.2 Create device setup

descriptor = """\
instruments:
  HDAWG:
  - address: DEV8431
    uid: device_hdawg
    options: HDAWG8/MF/ME/SKW/PC
connections:
  device_hdawg:
    - iq_signal: q0/drive_line
      ports: [SIGOUTS/2, SIGOUTS/3]
    - rf_signal: q0/coulomb_line_1
      ports: [SIGOUTS/0]
    - rf_signal: q0/coulomb_line_2
      ports: [SIGOUTS/1]
"""

device_setup = DeviceSetup.from_descriptor(
    descriptor,
    server_host="your_ip_address",
    server_port=8004,
    setup_name="MySetup",
)
calibrate_devices(device_setup)

2. Rabi Experiment: sweep burst length

2.1 Define parameters for experiment

## constant definition
LEN_COULOMB_CYCLE = 200e-9
LEN_READOUT = 2 * LEN_COULOMB_CYCLE
X90_DURATION = 10e-9

START = 0
STOP = LEN_COULOMB_CYCLE / 2
STEPS = 5
NUM_REP = 2
## define length sweep parameter
length_sweep_parameter = LinearSweepParameter(
    uid="length_sweep", start=START, stop=STOP, count=STEPS
)

2.2 Experiment

# define pulse shapes
coulomb_pulse = pulse_library.const(
    uid="coulomb_pulse", length=LEN_COULOMB_CYCLE / 2, amplitude=0.5
)
coulomb_readout = pulse_library.const(
    uid="coulomb_readout", length=LEN_READOUT, amplitude=1
)
drive_pulse = pulse_library.const(
    uid="rabi_drive_pulse", length=X90_DURATION, amplitude=1
)
## Create Experiment
exp = Experiment(
    "Rabi with Coulomb pulse",
    signals=[
        ExperimentSignal("drive"),
        ExperimentSignal("coulomb_1"),
        ExperimentSignal("coulomb_2"),
    ],
)

# define experiment
with exp.acquire_loop_rt(
    uid=("shots"), count=NUM_REP, averaging_mode=AveragingMode.SEQUENTIAL
):
    with exp.sweep(parameter=length_sweep_parameter):
        with exp.section(uid="qubit_preparation"):
            exp.play(signal="coulomb_1", pulse=coulomb_pulse, amplitude=0.5)
            exp.play(signal="coulomb_2", pulse=coulomb_pulse, amplitude=0.5)
        with exp.section(
            uid="manipulation",
            alignment=SectionAlignment.RIGHT,
            length=LEN_COULOMB_CYCLE / 2,
        ):
            exp.play(signal="coulomb_1", pulse=coulomb_pulse, amplitude=0.75)
            exp.play(signal="coulomb_2", pulse=coulomb_pulse, amplitude=0.75)
            exp.play(signal="drive", pulse=drive_pulse, length=length_sweep_parameter)
        with exp.section(uid="qubit_readout", length=LEN_READOUT):
            exp.play(signal="coulomb_1", pulse=coulomb_readout, amplitude=0.3)
            exp.play(signal="coulomb_2", pulse=coulomb_readout, amplitude=0.3)
        with exp.section(
            uid="outer_trigger",
            length=LEN_READOUT,
            trigger={"drive": {"state": 1}},
            alignment=SectionAlignment.RIGHT,
        ):
            with exp.section(
                uid="inner_trigger",
                length=LEN_READOUT - 100e-9,
                trigger={"drive": {"state": 2}},
            ):
                exp.reserve(signal="drive")

# define signal map
map_q0 = {
    "drive": "/logical_signal_groups/q0/drive_line",
    "coulomb_1": "/logical_signal_groups/q0/coulomb_line_1",
    "coulomb_2": "/logical_signal_groups/q0/coulomb_line_2",
}

2.3 Session

# create and connect to session
session = Session(device_setup=device_setup)
session.connect(do_emulation=DO_EMULATION)

# set signal map
exp.set_signal_map(map_q0)
if not session.connection_state.emulated:
    instrument_serial = device_setup.instrument_by_uid("device_hdawg").address
    device = session.devices[instrument_serial]
    device.triggers.out[2].delay(23.9e-9)

2.5 Run

_ = session.run(exp)

2.6 View experiment in pulse sheet viewer

# use pulse sheet viewer to display the pulse sequence - only recommended for small number of averages and sweep steps to avoid performance issues
compiled_exp = session.compiled_experiment
show_pulse_sheet("Spin qubit length Rabi", compiled_exp)

3. Ramsey Experiment I: sweep wait time at constant burst length

3.1 Define parameters for experiment

START = 0
STOP = LEN_COULOMB_CYCLE / 2 - 2 * X90_DURATION
STEPS = 3
NUM_REP = 20
## Define sweep parameter
sweep_delay = LinearSweepParameter(
    uid="Ramsey_delay", start=START, stop=STOP, count=STEPS
)

3.2 Experiment

## Create Experiment
exp = Experiment(
    "Ramsey variant I",
    signals=[
        ExperimentSignal("drive"),
        ExperimentSignal("coulomb_1"),
        ExperimentSignal("coulomb_2"),
    ],
)

# define experiment
with exp.acquire_loop_rt(
    uid="shots", count=NUM_REP, averaging_mode=AveragingMode.SEQUENTIAL
):
    with exp.sweep(uid="sweep", parameter=sweep_delay):
        with exp.section(uid="qubit_preparation"):
            exp.play(signal="coulomb_1", pulse=coulomb_pulse, amplitude=0.5)
            exp.play(signal="coulomb_2", pulse=coulomb_pulse, amplitude=0.5)
        with exp.section(
            uid="qubit_excitation",
            alignment=SectionAlignment.RIGHT,
            length=LEN_COULOMB_CYCLE / 2,
        ):
            exp.play(signal="coulomb_1", pulse=coulomb_pulse, amplitude=0.75)
            exp.play(signal="coulomb_2", pulse=coulomb_pulse, amplitude=0.75)

            exp.play(signal="drive", pulse=drive_pulse)
            exp.delay(signal="drive", time=sweep_delay)
            exp.play(signal="drive", pulse=drive_pulse)
        with exp.section(uid="qubit_readout", length=LEN_READOUT):
            with exp.section(uid="readout_pulses"):
                exp.play(signal="coulomb_1", pulse=coulomb_readout, amplitude=0.3)
                exp.play(signal="coulomb_2", pulse=coulomb_readout, amplitude=0.3)
            with exp.section(
                uid="outer_trigger",
                length=LEN_READOUT,
                trigger={"drive": {"state": 1}},
                alignment=SectionAlignment.RIGHT,
            ):
                with exp.section(
                    uid="inner_trigger",
                    length=LEN_READOUT - 100e-9,
                    trigger={"drive": {"state": 2}},
                ):
                    exp.reserve(signal="drive")

# define signal map
map_q0 = {
    "drive": "/logical_signal_groups/q0/drive_line",
    "coulomb_1": "/logical_signal_groups/q0/coulomb_line_1",
    "coulomb_2": "/logical_signal_groups/q0/coulomb_line_2",
}

3.3 Connect Session and Run

# create and connect to session
session = Session(device_setup=device_setup)
session.connect(do_emulation=DO_EMULATION)

# set signal map
exp.set_signal_map(map_q0)

_ = session.run(exp)

3.5 View experiment in pulse sheet viewer

# use pulse sheet viewer to display the pulse sequence - only recommended for small number of averages and sweep steps to avoid performance issues
compiled_exp = session.compiled_experiment
show_pulse_sheet("Ramsey variant I", compiled_exp)

4. Ramsey Experiment II: sweep burst length at constant wait time

4.1 Define parameters for experiment

# define constant delay
T_DELAY = 40e-9
## parameters for experiment
START = 0
STOP = (LEN_COULOMB_CYCLE / 2 - T_DELAY) / 2
STEPS = 5
NUM_REP = 2

4.2 Experiment

## Define sweep parameter
sweep_length = LinearSweepParameter(
    uid="pulse_length_sweep", start=START, stop=STOP, count=STEPS
)
## Create Experiment
exp = Experiment(
    "Ramsey variant II",
    signals=[
        ExperimentSignal("drive"),
        ExperimentSignal("coulomb_1"),
        ExperimentSignal("coulomb_2"),
    ],
)

# define experiment
with exp.acquire_loop_rt(
    uid="shots", count=NUM_REP, averaging_mode=AveragingMode.SEQUENTIAL
):
    with exp.sweep(uid="length_sweep", parameter=sweep_length):
        with exp.section(uid="qubit_preparation"):
            exp.play(signal="coulomb_1", pulse=coulomb_pulse, amplitude=0.5)
            exp.play(signal="coulomb_2", pulse=coulomb_pulse, amplitude=0.5)
        with exp.section(
            uid="qubit_excitation",
            alignment=SectionAlignment.RIGHT,
            length=LEN_COULOMB_CYCLE / 2,
        ):
            exp.play(signal="coulomb_1", pulse=coulomb_pulse, amplitude=0.75)
            exp.play(signal="coulomb_2", pulse=coulomb_pulse, amplitude=0.75)

            exp.play(signal="drive", pulse=drive_pulse, length=sweep_length)
            exp.delay(signal="drive", time=T_DELAY)
            exp.play(signal="drive", pulse=drive_pulse, length=sweep_length)
        with exp.section(
            uid="qubit_readout", alignment=SectionAlignment.RIGHT, length=LEN_READOUT
        ):
            with exp.section(uid="readout_pulses"):
                exp.play(signal="coulomb_1", pulse=coulomb_readout, amplitude=0.3)
                exp.play(signal="coulomb_2", pulse=coulomb_readout, amplitude=0.3)
            with exp.section(
                uid="outer_trigger",
                length=LEN_READOUT,
                trigger={"drive": {"state": 1}},
                alignment=SectionAlignment.RIGHT,
            ):
                with exp.section(
                    uid="inner_trigger",
                    length=LEN_READOUT - 100e-9,
                    trigger={"drive": {"state": 2}},
                ):
                    exp.reserve(signal="drive")

# define signal map
map_q0 = {
    "drive": "/logical_signal_groups/q0/drive_line",
    "coulomb_1": "/logical_signal_groups/q0/coulomb_line_1",
    "coulomb_2": "/logical_signal_groups/q0/coulomb_line_2",
}

4.4 Connect Session and Run

# create and connect to session
session = Session(device_setup=device_setup)
session.connect(do_emulation=DO_EMULATION)

# set signal map
exp.set_signal_map(map_q0)

_ = session.run(exp)

4.5 View experiment in pulse sheet viewer

# use pulse sheet viewer to display the pulse sequence - only recommended for small number of averages and sweep steps to avoid performance issues
compiled_exp = session.compiled_experiment
show_pulse_sheet("Ramsey variant II", compiled_exp)

5. Ramsey Experiment III: sweep wait time and phase of second pulse together

5.1 Define parameters for experiment

## constant definition
X90_DURATION = 10e-9  # [s]

NUM_REP = 2

# phase sweep parameters
START_PHASE = 0
STOP_PHASE = 8 * np.pi

# qubit frequency to align phase and delay sweeps
TARGET_FREQUENCY = 1e6

START_DELAY = 0
STOP_DELAY = STOP_PHASE / TARGET_FREQUENCY / 2 / np.pi

SWEEP_STEPS = 25

LENGTH_RAMSEY = STOP_DELAY + 2 * X90_DURATION
## define phase sweep parameter
sweep_phase = LinearSweepParameter(
    uid="Ramsey_phase_sweep", start=START_PHASE, stop=STOP_PHASE, count=SWEEP_STEPS
)
sweep_delay = LinearSweepParameter(
    uid="Ramsey_delay_sweep", start=START_DELAY, stop=STOP_DELAY, count=SWEEP_STEPS
)

5.2 Experiment

## Create Experiment
exp = Experiment(
    "Ramsey variant I",
    signals=[
        ExperimentSignal("drive"),
        ExperimentSignal("coulomb_1"),
        ExperimentSignal("coulomb_2"),
    ],
)

# define experiment
with exp.acquire_loop_rt(
    uid="shots", count=NUM_REP, averaging_mode=AveragingMode.CYCLIC
):
    with exp.sweep(uid="sweep_delay", parameter=[sweep_delay, sweep_phase]):
        with exp.section(uid="qubit_preparation"):
            exp.play(signal="coulomb_1", pulse=coulomb_pulse, amplitude=0.5)
            exp.play(signal="coulomb_2", pulse=coulomb_pulse, amplitude=0.5)
        with exp.section(
            uid="qubit_excitation",
            alignment=SectionAlignment.RIGHT,
            length=LENGTH_RAMSEY,
        ):
            exp.play(
                signal="coulomb_1",
                pulse=coulomb_pulse,
                amplitude=0.75,
                length=LENGTH_RAMSEY,
            )
            exp.play(
                signal="coulomb_2",
                pulse=coulomb_pulse,
                amplitude=0.75,
                length=LENGTH_RAMSEY,
            )

            exp.play(signal="drive", pulse=drive_pulse)
            exp.delay(signal="drive", time=sweep_delay)
            exp.play(
                signal="drive",
                pulse=drive_pulse,
                increment_oscillator_phase=sweep_phase,
            )
        with exp.section(
            uid="qubit_readout",
            alignment=SectionAlignment.RIGHT,
            length=LEN_READOUT,
        ):
            exp.play(signal="coulomb_1", pulse=coulomb_readout, amplitude=0.3)
            exp.play(signal="coulomb_2", pulse=coulomb_readout, amplitude=0.3)
        with exp.section(
            uid="outer_trigger",
            length=LEN_READOUT,
            trigger={"drive": {"state": 1}},
            alignment=SectionAlignment.RIGHT,
        ):
            with exp.section(
                uid="inner_trigger",
                length=LEN_READOUT - 100e-9,
                trigger={"drive": {"state": 2}},
            ):
                exp.reserve(signal="drive")

# define signal map
map_q0 = {
    "drive": "/logical_signal_groups/q0/drive_line",
    "coulomb_1": "/logical_signal_groups/q0/coulomb_line_1",
    "coulomb_2": "/logical_signal_groups/q0/coulomb_line_2",
}

5.4 Connect Session and Run

# create and connect to session
session = Session(device_setup=device_setup)
session.connect(do_emulation=DO_EMULATION)

# set signal map
exp.set_signal_map(map_q0)

_ = session.run(exp)

5.5 View experiment in pulse sheet viewer

# use pulse sheet viewer to display the pulse sequence - only recommended for small number of averages and sweep steps to avoid performance issues
compiled_exp = session.compiled_experiment
show_pulse_sheet("Ramsey variant III", compiled_exp)