qfabric

class qfabric.ExperimentManager(config_path)

Bases: object

Experiment sequence manager.

This is the public interface to control AWG devices.

If controlling individual AWGs is needed, use programmer.

Parameters:

config_path (str) – Path to the config file.

planner

Sequence scheduling object.

Type:

Planner

programmer

AWG programming interface.

Type:

Programmer

schedule(sequences, repeats=1)

Schedules sequences with repeats.

Parameters:
  • sequences (Sequence | list[Sequence]) – A single sequence or a list of sequences.

  • repeats (int) – Number of repeats for sequences. Default 1.

Returns:

List of sequence indices scheduled.

Return type:

list[int]

setup(program_single_sequence_only=False)

Prepares execution of the sequences.

This must be called before calling program_next_sequence. It sends steps in all scheduled sequences to segmenters to produce AWG segments.

Parameters:

program_single_sequence_only (bool) – Whether to only program the next sequence. If True, attempts to program as many sequences as possible to fit in the AWG memory.

property scheduled_sequence_indices: list[int]

Returns: list[int]: List of indices of scheduled sequences.

program_next_sequence()

Programs the AWG memory and segment orders and repeats for the next scheduled sequence.

Returns:

next scheduled sequence object.

Return type:

Sequence

run(wait_for_finish=True)

Runs the next sequence.

Parameters:

wait_for_finish (bool) – Whether to wait for sequence to finish.

wait_until_complete()

Waits for the sequence to finish.

stop()

Stops the sequence.

set_principal_device_trigger(external)

Sets the principal AWG device trigger mode.

Parameters:

external (bool) – If False, software trigger is used.

class qfabric.Sequence

Bases: object

Pulse sequence for an experiment.

property nominal_duration: float

Nominal duration of the entire pulse sequence in seconds.

AWG may introduce a small duration change, due to segment length requirements or time to switch between segments.

add_step(step, repeats=1, delay_time_after_previous=0)

Appends a step in the sequence.

Parameters:
  • step (Step) – Step to append.

  • repeats (int) – Number of repeats for this step. Default 1.

  • delay_time_after_previous (float) – Optional delay time after the previous step. Default 0. This delay time, as well as duration of each step, may not be exact due to AWG limitations.

get_steps()

Gets all steps.

The executed steps also include a start step and a stop step, which are not included in the return value of this function. The start and stop steps are added in the experiment manager before programming the AWG devices.

Returns:

Steps of this sequence.

Return type:

list[Step]

get_repeats()

Gets number of repeats of each step.

Returns:

Number of repeats of each step of this sequence.

Return type:

list[int]

to_dict()

Dict representation of the sequence, without function details.

This can be serialized to JSON for saving.

Returns:

Dict representation of the sequence.

Return type:

dict[str, Any]

classmethod from_dict(dict_value)

Uses SequenceVisualizeOnly to build a visualization only sequence.

Parameters:

dict_value (dict[str, Any]) – Dict representation of the sequence.

class qfabric.Step(name)

Bases: object

Step in a pulse sequence.

Step is the building block for a sequence, often consists one (or a few) logically-related pulses in a sequence. It is designed so that each step is replayed on the AWG exactly as defined with phase coherence. Due to AWG segment size limits, the actual duration of a step is often slightly longer than the defined duration. Therefore pulses spanning different steps may not have exact phase relations as defined.

Parameters:

name (str) – Step name.

property duration: float

Nominal duration of this step.

If duration is not set, uses the longest function defined on all channels.

add_analog_function(channel, function)

Adds an analog function to a channel.

Parameters:
  • channel (int) – Index of the analog channel.

  • function (AnalogFunction) – Analog function to use for this channel.

add_digital_function(channel, function)

Adds a digital function to a channel.

Parameters:
  • channel (int) – Index of the digital channel.

  • function (DigitalFunction) – Digital function to use for this channel.

get_functions_on_device(analog_channels, digital_channels)

Splits functions on selected channels to form a device step.

Used to isolate functions used on each of the AWG device.

Parameters:
  • analog_channels (list[int]) – Analog channels of this device.

  • digital_channels (list[int]) – Digital channels of this device.

Returns:

Device step containing only functions defined on these channels.

Return type:

DeviceStep

to_dict()

Dict representation of the step, without function details.

This can be serialized to JSON for saving.

Returns:

dict representation of the step.

Return type:

dict[str, Any]

classmethod from_dict(dict_value)

Uses StepVisualizeOnly to build a visualization only step.

Parameters:

dict_value (dict[str, Any]) – Dict representation of the step.

class qfabric.AnalogFunction

Bases: Function

Base class for all analog functions.

All subclasses should override output().

classmethod from_dict(dict_value)

Uses AnalogFunctionVisualizeOnly to build a visualization only function.

Parameters:

dict_value (dict[str, Any]) – Dict representation of the function.

class qfabric.AnalogSequence

Bases: AnalogFunction

Sequence of analog functions.

This is useful to build longer steps containing multiple analog pulses on the same channel, with optional phase coherence between the pulses.

add_function(function, delay_time_after_previous=0, duration=None, coherent_phase=False)

Appends an analog function.

Parameters:
  • function (AnalogFunction) – Analog function to be appended.

  • delay_time_after_previous (float) – Delay time after the previous function. Default 0.

  • duration (float) – Duration of this function. If None, the minimum function duration is used.

  • coherent_phase (bool) – If True, the phase of the function is calculated relative to the start of this function sequence. Otherwise, the phase of the function is calculated relative to the start of this appended function.

to_dict()

Dict representation of the function without guarantee of reproduction.

This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.

Returns:

dict representation of the step.

Return type:

dict[str, Any]

class qfabric.AnalogProduct(function_1, *functions)

Bases: AnalogFunction

Product of multiple analog functions.

Parameters:
to_dict()

Dict representation of the function without guarantee of reproduction.

This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.

Returns:

dict representation of the step.

Return type:

dict[str, Any]

class qfabric.AnalogSum(function_1, *functions)

Bases: AnalogFunction

Sum of multiple analog functions.

Parameters:
to_dict()

Dict representation of the function without guarantee of reproduction.

This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.

Returns:

dict representation of the step.

Return type:

dict[str, Any]

class qfabric.ConstantAnalog(amplitude, start_time=None, stop_time=None)

Bases: AnalogFunction

Constant analog function.

Parameters:
  • amplitude (float) – Amplitude.

  • start_time (float) – Start time. If None, it starts from the beginning of the step. Default None.

  • stop_time (float) – Stop time. If None, it stops at the end of the step. Default None.

class qfabric.HammingWindow(amplitude=1, start_time=None, stop_time=None)

Bases: AnalogFunction

Hamming Window function.

This is usually used with another AnalogFunction in AnalogProduct to produce an analog pulse without sinc-square lumps.

Parameters:
  • amplitude (float) – Maximum amplitude of the window. Default 1.

  • start_time (float) – Start time. If None, it starts from the beginning of the step. Default None.

  • stop_time (float) – Stop time. If None, it stops at the end of the step. Default None.

class qfabric.LinearRamp(start_amplitude, stop_amplitude, start_time, stop_time)

Bases: AnalogFunction

Linear ramp function.

Parameters:
  • start_amplitude (float) – Start amplitude.

  • stop_amplitude (float) – Stop amplitude.

  • start_time (float) – Start time.

  • stop_time (float) – Stop time.

class qfabric.SineSweep(start_frequency, stop_frequency, start_amplitude, stop_amplitude, start_time, stop_time, phase=0)

Bases: AnalogFunction

Sine frequency and/or amplitude sweep.

Parameters:
  • start_frequency (float) – Cyclic frequency at start.

  • stop_frequency (float) – Cyclic frequency at stop.

  • start_amplitude (float) – Amplitude at start.

  • stop_amplitude (float) – Amplitude at stop.

  • start_time (float) – Start time.

  • stop_time (float) – Stop time.

  • phase (float) – Phase of the sine sweep. Default 0.

class qfabric.SineWave(frequency, amplitude, phase=0, start_time=None, stop_time=None)

Bases: AnalogFunction

Sine wave.

Parameters:
  • frequency (float) – Cyclic frequency of the sine wave.

  • amplitude (float) – Amplitude of the sine wave.

  • phase (float) – Phase of the sine wave. Default 0.

  • start_time (float) – Start time. If None, it starts from the beginning of the step. Default None.

  • stop_time (float) – Stop time. If None, it stops at the end of the step. Default None.

class qfabric.DigitalFunction

Bases: Function

Base class for all digital functions.

All subclasses should override output().

classmethod from_dict(dict_value)

Uses DigitalFunctionVisualizeOnly to build a visualization only function.

Parameters:

dict_value (dict[str, Any]) – Dict representation of the function.

class qfabric.DigitalSequence(default_on=False)

Bases: DigitalFunction

Sequence of digital functions.

This is useful to build longer steps containing multiple digital pulses on the same channel.

add_function(function, delay_time_after_previous=0, duration=None)

Appends a digital function.

Parameters:
  • function (DigitalFunction) – Digital function to be appended.

  • delay_time_after_previous (float) – Delay time after the previous function. Default 0.

  • duration (float) – Duration of this function. If None, the minimum function duration is used.

to_dict()

Dict representation of the function without guarantee of reproduction.

This can be serialized to JSON for saving. If the class definition is changed or removed, the output of this function may not be reproduced after saving and loading.

Returns:

dict representation of the step.

Return type:

dict[str, Any]

class qfabric.DigitalMultiPulses(start_times, stop_times, default_off=True)

Bases: DigitalFunction

Multiple digital pulses.

Parameters:
  • start_times (npt.NDArray[np.float64]) – Start times of the pulses.

  • stop_time (npt.NDArray[np.float64]) – Stop times of the pulses.

  • default_off (bool) – Whether to output false when the pulse is off. This switch flips the polarity of the output. Default True.

class qfabric.DigitalOff

Bases: DigitalFunction

Digital constant false.

class qfabric.DigitalOn

Bases: DigitalFunction

Digital constant true.

class qfabric.DigitalPulse(start_time, stop_time, default_off=True)

Bases: DigitalFunction

Digital pulse.

Parameters:
  • start_time (float) – Start time of the pulse.

  • stop_time (float) – Stop time of the pulse.

  • default_off (bool) – Whether to output false when the pulse is off. This switch flips the polarity of the output. Default True.

qfabric.logic_sequence(sequence, analog_map=None, digital_map=None, default_sample_rate_MHz=625)

Displays the sequence in the logic mode.

Each step is depicted as equal length. Click on each pulse to see details of the pulse.

If run in Jupyter notebook or other python processes with an event loop, clicking on functions in the sequence will not show the details.

Parameters:
  • sequence (Sequence) – Sequence to be displayed.

  • analog_map (dict[int, str]) – Optional names displayed for analog channels.

  • digital_map (dict[int, str]) – Optional names displayed for digital channels.

  • default_sample_rate_MHz (float) – Default sample rate used to visualize functions.

qfabric.timeline_sequence(sequence, analog_map=None, digital_map=None, default_sample_rate_MHz=625)

Displays the sequence in the timeline mode.

Each step is depicted with width proportional to duration. Click on each pulse to see details of the pulse.

If run in Jupyter notebook or other python processes with an event loop, clicking on functions in the sequence will not show the details.

Parameters:
  • sequence (Sequence) – Sequence to be displayed.

  • analog_map (dict[int, str]) – Optional names displayed for analog channels.

  • digital_map (dict[int, str]) – Optional names displayed for digital channels.

  • default_sample_rate_MHz (float) – Default sample rate used to visualize functions.