auto_rf_switch ============== .. py:module:: quantify_scheduler.backends.qblox.auto_rf_switch .. autoapi-nested-parse:: Module containing the auto RF switch dressing compilation pass. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: quantify_scheduler.backends.qblox.auto_rf_switch.VoltageOffsetEvent quantify_scheduler.backends.qblox.auto_rf_switch.MicrowavePulseInfo Functions ~~~~~~~~~ .. autoapisummary:: quantify_scheduler.backends.qblox.auto_rf_switch.auto_rf_switch_dressing quantify_scheduler.backends.qblox.auto_rf_switch._collect_all_mw_events_recursive quantify_scheduler.backends.qblox.auto_rf_switch._voltage_offset_events_to_pulses quantify_scheduler.backends.qblox.auto_rf_switch._collect_all_mw_pulses_recursive quantify_scheduler.backends.qblox.auto_rf_switch._collect_microwave_pulses quantify_scheduler.backends.qblox.auto_rf_switch._merge_pulses_into_windows quantify_scheduler.backends.qblox.auto_rf_switch._insert_rf_switch_operation .. py:class:: VoltageOffsetEvent 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. .. py:attribute:: abs_time :type: float Absolute time of the event. .. py:attribute:: port :type: str Port of the event. .. py:attribute:: clock :type: str Clock of the event. .. py:attribute:: is_nonzero :type: bool True if the offset is non-zero (RF on), False if both paths are zero (RF off). .. py:class:: MicrowavePulseInfo Information about a microwave pulse for RF switch grouping. .. py:attribute:: schedulable_key :type: str Key of the schedulable in the schedule. .. py:attribute:: abs_time :type: float Absolute start time of the pulse. .. py:attribute:: duration :type: float Duration of the pulse. .. py:attribute:: port :type: str Port of the pulse. .. py:attribute:: clock :type: str Clock of the pulse. .. py:property:: end_time :type: float Return the end time of the pulse. .. py:function:: auto_rf_switch_dressing(schedule: quantify_scheduler.schedules.schedule.Schedule, config: quantify_scheduler.backends.graph_compilation.CompilationConfig) -> quantify_scheduler.schedules.schedule.Schedule Automatically insert RFSwitchToggle operations around microwave pulses. This compilation pass identifies microwave operations (pulses on ports ending with ``:mw``) and inserts :class:`~.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 :class:`~.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. :param schedule: The schedule to process. :param 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. .. py:function:: _collect_all_mw_events_recursive(schedule: quantify_scheduler.schedules.schedule.Schedule, time_offset: float) -> tuple[list[MicrowavePulseInfo], list[VoltageOffsetEvent]] 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 :class:`MicrowavePulseInfo` objects. :class:`~.VoltageOffset` operations (``wf_func=None``, ``duration=0``) on ``:mw`` ports are collected as :class:`VoltageOffsetEvent` objects so that stitched pulse windows can be derived by :func:`_voltage_offset_events_to_pulses`. :param schedule: The schedule to collect from. :param 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. .. py:function:: _voltage_offset_events_to_pulses(events: list[VoltageOffsetEvent]) -> list[MicrowavePulseInfo] 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. :param 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. .. py:function:: _collect_all_mw_pulses_recursive(schedule: quantify_scheduler.schedules.schedule.Schedule, time_offset: float) -> list[MicrowavePulseInfo] Recursively collect all microwave pulses from a schedule tree (no VoltageOffset). This is a convenience wrapper around :func:`_collect_all_mw_events_recursive` that discards the VoltageOffset events and returns only regular pulse info objects. :param schedule: The schedule to collect from. :param time_offset: The global absolute time offset for this schedule's schedulables. :returns: list[MicrowavePulseInfo] MW pulse info objects with global absolute times. .. py:function:: _collect_microwave_pulses(schedule: quantify_scheduler.schedules.schedule.Schedule) -> list[MicrowavePulseInfo] 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. :param schedule: The schedule to collect pulses from. :returns: list[MicrowavePulseInfo] List of microwave pulse information. .. py:function:: _merge_pulses_into_windows(pulses: list[MicrowavePulseInfo], ramp_buffer: float) -> list[tuple[float, float]] Merge adjacent pulses into RF switch windows. Pulses within ``2 * ramp_buffer`` of each other are merged into a single window. :param pulses: List of microwave pulses, sorted by start time. :param 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. .. py:function:: _insert_rf_switch_operation(schedule: quantify_scheduler.schedules.schedule.Schedule, port: str, clock: str, start_time: float, end_time: float, ramp_buffer: float) -> None 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``. :param schedule: The schedule to insert the operation into. :param port: The port for the RF switch. :param clock: The clock for the RF switch. :param start_time: Start time of the first pulse in the window. :param end_time: End time of the last pulse in the window. :param ramp_buffer: Buffer time before/after pulses.