auto_rf_switch#
Module containing the auto RF switch dressing compilation pass.
Module Contents#
Classes#
Event from a VoltageOffset operation for RF switch scheduling. |
|
Information about a microwave pulse for RF switch grouping. |
Functions#
Automatically insert RFSwitchToggle operations around microwave pulses. |
|
Recursively collect microwave pulses and VoltageOffset events from a schedule tree. |
|
Convert VoltageOffset events into MicrowavePulseInfo windows. |
|
Recursively collect all microwave pulses from a schedule tree (no VoltageOffset). |
|
|
Collect all microwave pulses from a single schedule level (non-recursive). |
|
Merge adjacent pulses into RF switch windows. |
|
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.
- 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 insertsRFSwitchToggleoperations to control RF switches. Adjacent microwave pulses within2 * ramp_bufferof each other are merged into a single RF switch window to minimize switching.Stitched pulses composed of
VoltageOffsetoperations 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_timemust be set for all schedulables). The RF switch operations are inserted with theirabs_timeset 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-
Nonewf_func, positive duration) are returned asMicrowavePulseInfoobjects.VoltageOffsetoperations (wf_func=None,duration=0) on:mwports are collected asVoltageOffsetEventobjects 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
:mwand a non-Nonewaveform 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_bufferof 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_bufferbeforestart_timeand remains on untilramp_bufferafterend_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.