auto_rf_switch#

Module containing the auto RF switch dressing compilation pass.

Module Contents#

Classes#

VoltageOffsetEvent

Event from a VoltageOffset operation for RF switch scheduling.

MicrowavePulseInfo

Information about a microwave pulse for RF switch grouping.

Functions#

auto_rf_switch_dressing(...)

Automatically insert RFSwitchToggle operations around microwave pulses.

_collect_all_mw_events_recursive(...)

Recursively collect microwave pulses and VoltageOffset events from a schedule tree.

_voltage_offset_events_to_pulses(...)

Convert VoltageOffset events into MicrowavePulseInfo windows.

_collect_all_mw_pulses_recursive(...)

Recursively collect all microwave pulses from a schedule tree (no VoltageOffset).

_collect_microwave_pulses(→ list[MicrowavePulseInfo])

Collect all microwave pulses from a single schedule level (non-recursive).

_merge_pulses_into_windows(→ list[tuple[float, float]])

Merge adjacent pulses into RF switch windows.

_insert_rf_switch_operation(→ None)

Insert an RFSwitchToggle operation into the schedule.

class VoltageOffsetEvent[source]#

Event from a VoltageOffset operation for RF switch scheduling.

A non-zero offset on a microwave port signals the start of a stitched pulse window; a zero offset signals the end of that window.

abs_time: float[source]#

Absolute time of the event.

port: str[source]#

Port of the event.

clock: str[source]#

Clock of the event.

is_nonzero: bool[source]#

True if the offset is non-zero (RF on), False if both paths are zero (RF off).

class MicrowavePulseInfo[source]#

Information about a microwave pulse for RF switch grouping.

schedulable_key: str[source]#

Key of the schedulable in the schedule.

abs_time: float[source]#

Absolute start time of the pulse.

duration: float[source]#

Duration of the pulse.

port: str[source]#

Port of the pulse.

clock: str[source]#

Clock of the pulse.

property end_time: float[source]#

Return the end time of the pulse.

auto_rf_switch_dressing(schedule: quantify_scheduler.schedules.schedule.Schedule, config: quantify_scheduler.backends.graph_compilation.CompilationConfig) quantify_scheduler.schedules.schedule.Schedule[source]#

Automatically insert RFSwitchToggle operations around microwave pulses.

This compilation pass identifies microwave operations (pulses on ports ending with :mw) and inserts RFSwitchToggle operations to control RF switches. Adjacent microwave pulses within 2 * ramp_buffer of each other are merged into a single RF switch window to minimize switching.

Stitched pulses composed of VoltageOffset operations are also handled: the RF switch is turned on at the first non-zero VoltageOffset on a port and turned off when a subsequent VoltageOffset sets both paths back to zero.

All microwave pulses are collected from the full schedule tree (including nested sub-schedules) using global absolute times. RF switch operations are inserted exclusively on the root schedule so that sub-schedule durations are not modified, preventing timing issues for small schedules. Pulse windows from consecutive sub-schedules are also merged correctly because the merging operates on the global timeline.

Parameters:
  • schedule – The schedule to process.

  • config – The compilation configuration containing hardware options.

Returns:

Schedule The schedule with RFSwitchToggle operations inserted.

Note

This pass expects the schedule to already have absolute timing determined (i.e., abs_time must be set for all schedulables). The RF switch operations are inserted with their abs_time set directly, so no timing recalculation is needed.

_collect_all_mw_events_recursive(schedule: quantify_scheduler.schedules.schedule.Schedule, time_offset: float) tuple[list[MicrowavePulseInfo], list[VoltageOffsetEvent]][source]#

Recursively collect microwave pulses and VoltageOffset events from a schedule tree.

Traverses the full schedule tree (including nested sub-schedules and control-flow bodies) and returns all events with global absolute times, i.e. times relative to the root schedule start.

Regular microwave pulses (non-None wf_func, positive duration) are returned as MicrowavePulseInfo objects. VoltageOffset operations (wf_func=None, duration=0) on :mw ports are collected as VoltageOffsetEvent objects so that stitched pulse windows can be derived by _voltage_offset_events_to_pulses().

Parameters:
  • schedule – The schedule to collect from.

  • time_offset – The global absolute time offset for this schedule’s schedulables. For the root schedule this is 0.0; for a nested schedule it is the global start time of the sub-schedule schedulable in the parent.

Returns:

tuple[list[MicrowavePulseInfo], list[VoltageOffsetEvent]] MW pulse info objects and VoltageOffset events, all with global absolute times.

_voltage_offset_events_to_pulses(events: list[VoltageOffsetEvent]) list[MicrowavePulseInfo][source]#

Convert VoltageOffset events into MicrowavePulseInfo windows.

For each port-clock combination, scans the sorted events to find on/off pairs: a non-zero VoltageOffset starts a window, the subsequent zero VoltageOffset ends it. If a window is opened but never closed (no zero event), it is silently ignored because the schedule is incomplete for RF switch purposes.

Parameters:

events – VoltageOffset events collected from the schedule tree.

Returns:

list[MicrowavePulseInfo] Pulse windows derived from VoltageOffset on/off pairs, suitable for merging with regular microwave pulses.

_collect_all_mw_pulses_recursive(schedule: quantify_scheduler.schedules.schedule.Schedule, time_offset: float) list[MicrowavePulseInfo][source]#

Recursively collect all microwave pulses from a schedule tree (no VoltageOffset).

This is a convenience wrapper around _collect_all_mw_events_recursive() that discards the VoltageOffset events and returns only regular pulse info objects.

Parameters:
  • schedule – The schedule to collect from.

  • time_offset – The global absolute time offset for this schedule’s schedulables.

Returns:

list[MicrowavePulseInfo] MW pulse info objects with global absolute times.

_collect_microwave_pulses(schedule: quantify_scheduler.schedules.schedule.Schedule) list[MicrowavePulseInfo][source]#

Collect all microwave pulses from a single schedule level (non-recursive).

Microwave pulses are identified by having a port ending with :mw and a non-None waveform function (wf_func). VoltageOffset operations (wf_func=None) and RF switch marker pulses are excluded.

Parameters:

schedule – The schedule to collect pulses from.

Returns:

list[MicrowavePulseInfo] List of microwave pulse information.

_merge_pulses_into_windows(pulses: list[MicrowavePulseInfo], ramp_buffer: float) list[tuple[float, float]][source]#

Merge adjacent pulses into RF switch windows.

Pulses within 2 * ramp_buffer of each other are merged into a single window.

Parameters:
  • pulses – List of microwave pulses, sorted by start time.

  • ramp_buffer – Buffer time for RF switch.

Returns:

list[tuple[float, float]] List of (start_time, end_time) tuples for each RF switch window. These times are the actual pulse times, not including the ramp buffer.

_insert_rf_switch_operation(schedule: quantify_scheduler.schedules.schedule.Schedule, port: str, clock: str, start_time: float, end_time: float, ramp_buffer: float) None[source]#

Insert an RFSwitchToggle operation into the schedule.

The RF switch is turned on ramp_buffer before start_time and remains on until ramp_buffer after end_time.

Parameters:
  • schedule – The schedule to insert the operation into.

  • port – The port for the RF switch.

  • clock – The clock for the RF switch.

  • start_time – Start time of the first pulse in the window.

  • end_time – End time of the last pulse in the window.

  • ramp_buffer – Buffer time before/after pulses.