Source code for qblox_scheduler.operations.hardware_operations.pulse_library

# SPDX-FileCopyrightText: Copyright 2020-2025, Quantify Consortium
# SPDX-FileCopyrightText: © 2023 Qblox <https://qblox.com>
# SPDX-License-Identifier: BSD-3-Clause

"""Standard pulse-level operations for use with the qblox_scheduler."""

from __future__ import annotations

from typing import TYPE_CHECKING
from typing_extensions import Unpack

import numpy as np

from qblox_scheduler.backends.qblox import constants
from qblox_scheduler.operations.pulse_library import (
    NumericalPulse,
    PulseSignalArgs,
    _PulseOperationBase,
)
from qblox_scheduler.resources import BasebandClockResource

if TYPE_CHECKING:
    from collections.abc import Sequence

    from qblox_scheduler.operations.expressions import Expression


[docs] class LatchReset(_PulseOperationBase): """ Operation that resets the feedback trigger addresses from the hardware. Currently only implemented for Qblox backend, refer to :class:`~qblox_scheduler.backends.qblox.operation_handling.virtual.ResetFeedbackTriggersStrategy` for more details. Parameters ---------- portclock Tuple containing the port that the pulse should be played on, and the clock used to (de)modulate the pulse (by default the baseband clock). duration The pulse duration in seconds. """ def __init__( self, portclock: tuple[str, str], duration: float = 4e-9, ) -> None: super().__init__( duration=duration, port=portclock[0], clock=portclock[1], ) self.data["pulse_info"] |= { "name": self.__class__.__name__, # This is necessary for some reason }
[docs] class SimpleNumericalPulse(NumericalPulse): """ Wrapper on top of NumericalPulse to provide a simple interface for creating a pulse where the samples correspond 1:1 to the produced waveform, without needing to specify the time samples. Parameters ---------- samples An array of (possibly complex) values specifying the shape of the pulse. port The port that the pulse should be played on. clock Clock used to (de)modulate the pulse. By default the baseband clock. gain Gain factor between -1 and 1 that multiplies with the samples, by default 1. **signal_args Additional signal parameters defined in :class:`~qblox_scheduler.operations.pulse_library.PulseSignalArgs`. Example ------- .. jupyter-execute:: from qblox_scheduler import ( SimpleNumericalPulse ) from qblox_scheduler.schedules.schedule import TimeableSchedule waveform = [0.1,0.2,0.2,0.3,0.5,0.4] schedule = TimeableSchedule("") schedule.add(SimpleNumericalPulse(waveform, port="q0:out")) """ def __init__( self, samples: np.ndarray | list, port: str, clock: str = BasebandClockResource.IDENTITY, amplitude: complex | float | Expression | Sequence[complex | float | Expression] = 1.0, **signal_args: Unpack[PulseSignalArgs], ) -> None: # Append samples with one value which will be truncated away by the interpolation. samples = np.append(samples, 0) t_samples = np.arange(len(samples)) / constants.SAMPLING_RATE super().__init__( samples=samples, t_samples=t_samples, port=port, clock=clock, amplitude=amplitude, interpolation="linear", **signal_args, )
class RFSwitchToggle(_PulseOperationBase): """ Turn the RF complex output on for the given duration. The RF ports are on by default, make sure to set :attr:`~.qblox_scheduler.backends.types.qblox.RFDescription.rf_output_on` to `False` to turn them off. Parameters ---------- duration Duration to turn the RF output on. port Name of the associated port. clock Name of the associated clock. For now the given port-clock combination must have a LO frequency defined in the hardware configuration. Examples -------- Partial hardware configuration to turn the RF complex output off by default to be able to use this operation. .. code-block:: python hardware_compilation_config = { "config_type": QbloxHardwareCompilationConfig, "hardware_description": { "cluster0": { "instrument_type": "Cluster", "modules": { "0": {"instrument_type": "QCM_RF", "rf_output_on": False}, "1": {"instrument_type": "QRM_RF", "rf_output_on": False}, }, }, }, } """ def __init__( self, duration: float, port: str, clock: str, ) -> None: super().__init__( duration=duration, port=port, clock=clock, ) self.data["pulse_info"] |= { "marker_pulse": True, # This distinguishes MarkerPulse from other operations }