QProgram

class qililab.QProgram

Bases: StructuredProgram

QProgram is a hardware-agnostic pulse-level programming interface for describing quantum programs.

This class provides an interface for building quantum programs, including defining operations, managing variables, and handling blocks. It contains methods for creating, manipulating and controlling the execution flow of quantum operations within a program.

Examples

The following example illustrates how to define a Rabi sequence using QProgram.

from qililab import QProgram, Domain, IQWaveform, Square

qp = QProgram()

# Pulse used for changing the state of qubit
control_wf = IQDRAG(amplitude=1.0, duration=40, num_sigmas=4.0, drag_correction=-2.5)

# Pulse used for exciting the resonator for readout
readout_wf = IQWaveform(I=Square(amplitude=1.0, duration=400), Q=Square(amplitude=0.0, duration=400))

# Weights used during integration
weights = IQWaveform(I=Square(amplitude=1.0, duration=2000), Q=Square(amplitude=1.0, duration=2000))

# Declare a variable
gain = qp.variable(label="gain", domain=Domain.Voltage)

# Loop the variable's value over the range [0.0, 1.0]
with qp.for_loop(variable=gain, start=0.0, stop=1.0, step=0.01):
    # Change the gain output of the drive_bus
    qp.set_gain(bus="drive_bus", gain=gain)

    # Play the control pulse
    qp.play(bus="drive_bus", waveform=control_wf)

    # Sync the buses
    qp.sync()

    # Measure
    qp.measure(bus="readout_bus", waveform=readout_wf, weights=weights)

Attributes Summary

yaml_tag

Methods Summary

draw([time_window, averages_displayed, ...])

Draw the QProgram using QBlox Compiler

has_calibrated_waveforms_or_weights()

Checks if QProgram has named waveforms or weights.

measure(bus, waveform, weights[, save_adc])

Play a pulse and acquire results.

play(bus, waveform)

Play a waveform, IQWaveform, or calibrated operation on the specified bus.

reset_phase(bus)

Reset the absolute phase of the NCO associated with the bus.

set_frequency(bus, frequency)

Set the frequency of the NCO associated with bus.

set_gain(bus, gain)

Set the gain of the AWG associated with bus.

set_offset(bus, offset_path0[, offset_path1])

Set the gain of the AWG associated with bus.

set_phase(bus, phase)

Set the absolute phase of the NCO associated with the bus.

set_trigger(bus, duration[, outputs, position])

Set the trigger output for a given instrument.

sync([buses])

Synchronize operations between buses, so the operations following will start at the same time.

wait(bus, duration)

Adds a delay on the bus with a specified time.

wait_trigger(bus, duration[, port])

Adds a delay on the bus and wait for an trigger signal to arrive.

with_bus_mapping(bus_mapping)

Returns a copy of the QProgram with bus mappings applied.

with_calibration(calibration)

Apply calibration to the operations within the QProgram.

with_crosstalk_qblox(crosstalk)

Apply crosstalk compensation to the qprogram flux buses.

with_crosstalk_qdac(crosstalk, qdac_buses_offset)

Apply crosstalk compensation to the qprogram flux buses.

Attributes Documentation

yaml_tag = '!QProgram'

Methods Documentation

draw(time_window=None, averages_displayed=False, acquisition_showing=True, calibration=None)

Draw the QProgram using QBlox Compiler

Parameters:
  • time_window (int) – Allows the user to stop the plotting after the specified number of ns have been plotted. The plotting might not be the precise number of ns inputted. For example, if the timeout is 100 ns but there is a play operation of 150 ns, the plot will display the data until 150 ns. Defaults to None.

  • averages_displayed (bool) – False means that all loops on the sequencer starting with avg will only loop once, and True shows all iterations. Defaults to False.

  • acquisition_showing (bool) – Allows visualing the acquisition period on the plot. Defaults to True.

Returns:

plotly.graph_objs._figure.Figure

Return type:

plotly object

has_calibrated_waveforms_or_weights()

Checks if QProgram has named waveforms or weights. These need to be mapped before compiling to hardware-native code.

Returns:

True, if QProgram has waveforms or weights that need to be mapped from calibration.

Return type:

bool

measure(bus, waveform, weights, save_adc=False)

Play a pulse and acquire results.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • waveform (IQWaveform) – Waveform played during measurement.

  • weights (IQWaveform) – Weights used during demodulation/integration.

  • save_adc (bool, optional) – If ADC data should be saved. Defaults to False.

play(bus, waveform)

Play a waveform, IQWaveform, or calibrated operation on the specified bus.

This method handles both playing a waveform or IQWaveform, and playing a calibrated operation based on the type of the argument provided.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • waveform (Waveform | IQWaveform | str) – The waveform, IQWaveform, or alias of named waveform to play.

reset_phase(bus)

Reset the absolute phase of the NCO associated with the bus.

Parameters:

bus (str) – Unique identifier of the bus.

set_frequency(bus, frequency)

Set the frequency of the NCO associated with bus.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • frequency (float) – The new frequency of the NCO.

set_gain(bus, gain)

Set the gain of the AWG associated with bus.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • gain (float) – The new gain of the AWG.

set_offset(bus, offset_path0, offset_path1=None)

Set the gain of the AWG associated with bus.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • offset_path0 (float) – The new offset of the AWG for path0.

  • offset_path1 (float) – The new offset of the AWG for path1.

set_phase(bus, phase)

Set the absolute phase of the NCO associated with the bus.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • phase (float) – The new absolute phase of the NCO.

set_trigger(bus, duration, outputs=None, position='start')

Set the trigger output for a given instrument. :param bus: Unique identifier of the bus. :type bus: str :param duration: Duration of the trigger pulse. Minimum of 4 ns. :type duration: int :param outputs: Port channel/s of the trigger output. Defaults to None. :type outputs: optional, list[int] | int | None :param outputs: Trigger position in respective to the pulse location, it can be either start or end. Defaults to start. :type outputs: *optional*, :py:class:`str

sync(buses=None)

Synchronize operations between buses, so the operations following will start at the same time.

If no buses are given, then the synchronization will involve all buses present in the QProgram.

Parameters:

buses (list[str], optional) – List of unique identifiers of the buses. Defaults to None.

wait(bus, duration)

Adds a delay on the bus with a specified time.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • time (int) – Duration of the delay.

wait_trigger(bus, duration, port=None)

Adds a delay on the bus and wait for an trigger signal to arrive.

Parameters:
  • bus (str) – Unique identifier of the bus.

  • duration (int) – Duration of the delay after the trigger is received. Minimum of 4 ns.

  • port (optional, int | None) – Port channel of the trigger input. Defaults to None.

with_bus_mapping(bus_mapping)

Returns a copy of the QProgram with bus mappings applied.

Parameters:

bus_mapping (dict[str, str]) – A dictionary mapping old bus names to new bus names.

Returns:

A new instance of QProgram with updated bus names.

Return type:

QProgram

with_calibration(calibration)

Apply calibration to the operations within the QProgram.

This method traverses the elements of the QProgram, replacing any named operations with the corresponding calibrated waveforms specified in the given Calibration instance.

Parameters:

calibration (Calibration) – The calibration data to apply to the operations.

Returns:

A new instance of QProgram with calibrated operations.

Return type:

QProgram

with_crosstalk_qblox(crosstalk)

Apply crosstalk compensation to the qprogram flux buses.

This method traverses the elements of the QProgram, replacing any Play or Offset instances by the compensated envelope or offset for all flux buses.

Parameters:

crosstalk (CrosstalkMatrix) – Crosstalk matrix class.

Returns:

A new instance of QProgram with calibrated crosstalk.

Return type:

QProgram

with_crosstalk_qdac(crosstalk, qdac_buses_offset)

Apply crosstalk compensation to the qprogram flux buses. This method traverses the elements of the QProgram, replacing any Play or Offset instances by the compensated envelope or offset for all flux buses. :param crosstalk: Crosstalk matrix class. :type crosstalk: CrosstalkMatrix

Returns:

A new instance of QProgram with calibrated crosstalk.

Return type:

QProgram