qat.ir.waveforms module
Contains elementary IR units for waveforms, including waveform types and pulses.
- class AbstractWaveform(**data)
Bases:
AllowExtraFieldsModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod name()
- Return type:
str
- class BlackmanWaveform(**data)
Bases:
WaveformA Blackman-window shaped pulse.
The envelope is:
\[f(t) = a_0 - a_1\cos\!\bigl(2\pi(t/w + 0.5)\bigr) + a_2\cos\!\bigl(4\pi(t/w + 0.5)\bigr)\]with \(a_0 = 7938/18608\), \(a_1 = 9240/18608\), \(a_2 = 1430/18608\), and \(w\) =
width. These are the exact Blackman coefficients that minimise the sidelobe level.The Blackman window offers excellent spectral leakage suppression. Only
width(inherited) controls the shape. See original paper Blackman & Tukey (1958).- Parameters:
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[BlackmanFunction]
- class CosWaveform(**data)
Bases:
WaveformA cosine-oscillating envelope.
\[f(t) = \cos(2\pi\,f\,t + \varphi)\]where \(f\) =
frequencyand \(\varphi\) =internal_phase.- Parameters:
frequency¶ – Oscillation frequency in Hz.
internal_phase¶ – Phase offset applied inside the cosine argument in radians. Shifts the cosine in phase without rotating the full IQ vector.
width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[Cos]
- class DragGaussianWaveform(**data)
Bases:
WaveformA complex Gaussian envelope with an in-built first-order DRAG correction.
The envelope is (when
zero_at_edgesisFalse):\[f(t) = \bigl(1 - i\,\beta\,t / \sigma^{2}\bigr) \;e^{-t^{2}/(8\sigma^{2})}\]When
zero_at_edgesisTruethe Gaussian is offset and rescaled so it approaches zero at the pulse boundaries. See https://arxiv.org/abs/0901.0534 for background on the DRAG technique.- Parameters:
std_dev¶ – Standard deviation controlling the width of the Gaussian in seconds.
beta¶ – DRAG in-pulse correction coefficient. Controls the magnitude of the quadrature (Q) component;
beta = 0gives a real-valued Gaussian.zero_at_edges¶ – If
True, subtracts a constant to make the envelope approach zero at the pulse edges.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Note
This class implements the DRAG correction inside the shape function itself (via the complex envelope). The top-level
dragparameter onWaveformapplies an additional derivative-based correction; normally only one of the two mechanisms is activated at a time.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[DragGaussianFunction]
- class ExtraSoftSquareWaveform(**data)
Bases:
WaveformA heavily softened normalised square pulse with a
2×riseinset.The raw envelope is:
\[g(t) = \tanh\!\bigl(\tfrac{t + \sigma/2 - 2r}{r}\bigr) - \tanh\!\bigl(\tfrac{t - \sigma/2 + 2r}{r}\bigr)\]which is then min/max normalised to \([0, 1]\). Identical to
SofterSquareWaveformbut with a2×riseinset instead of1×rise.- Parameters:
std_dev¶ – Width of the flat-top region in seconds. The
tanhtransitions are placed at±std_dev / 2.rise¶ – Edge rise/fall scale in seconds. A larger value relative to
std_devcauses the flat-top to shrink.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[ExtraSoftSquareFunction]
- class GaussianSquareWaveform(**data)
Bases:
WaveformA flat-top pulse with Gaussian-shaped rise and fall flanks.
The envelope is:
\[\begin{split}f(t) = \begin{cases} e^{-(t + s/2)^{2}/(2\sigma^{2})} & t < -s/2 \\ 1 & |t| \le s/2 \\ e^{-(t - s/2)^{2}/(2\sigma^{2})} & t > s/2 \end{cases}\end{split}\]where \(s\) =
square_widthand \(\sigma\) =std_dev. Whenzero_at_edgesisTruethe envelope is offset and rescaled to be zero at the outermost samples. See Sheldon et al. (2016) for use in cross-resonance gates.- Parameters:
square_width¶ – Duration of the central flat-top section in seconds.
std_dev¶ – Standard deviation of the Gaussian flanks in seconds.
zero_at_edges¶ – If
True, the envelope is offset and rescaled to be exactly zero at the outermost sample points.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[GaussianSquareFunction]
- class GaussianWaveform(**data)
Bases:
WaveformA standard Gaussian envelope pulse.
The envelope is:
\[f(t) = e^{-(t / k)^{2}}\]where \(k = \text{width} \times \text{rise}\).
- Parameters:
rise¶ – Dimensionless shape parameter. A larger
risespreads the Gaussian; a smallerrisenarrows it.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[GaussianFunction]
- class GaussianZeroEdgeWaveform(**data)
Bases:
WaveformA Gaussian pulse optionally normalised to be exactly zero at its edges.
The envelope is:
\[g(t) = e^{-t^{2} / (2\sigma^{2})}\]When
zero_at_edgesisTrue:\[f(t) = \frac{g(t) - g(w/2)}{1 - g(w/2)}\]ensuring \(f(\pm w/2) = 0\) and \(f(0) = 1\).
- Parameters:
std_dev¶ – Standard deviation of the Gaussian in seconds.
zero_at_edges¶ – When
True, the Gaussian is offset and rescaled so that it is exactly zero att = ±width/2and peaks at 1. WhenFalse, a standard Gaussian is returned.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[GaussianZeroEdgeFunction]
- class Pulse(**data)
Bases:
QuantumInstructionInstructs a pulse channel to send a waveform.
The intention of the waveform (e.g. a drive or measure pulse) can be specified using the type.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- ignore_channel_scale: bool
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'populate_by_name': True, 'use_enum_values': False, 'validate_assignment': True, 'validate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property pulse_channel
- property target
- update_duration(duration, sample_time=None)
- classmethod validate_duration(data)
- waveform: Waveform | SampledWaveform
- class RoundedSquareWaveform(**data)
Bases:
WaveformA square pulse with
erf-shaped (S-curve) rise and fall.The envelope uses a pair of error-function steps:
\[S(v) = \tfrac{1}{2}\bigl[\operatorname{erf}(v) + 1\bigr]\]\[f(t) = c\,\bigl[S\!\bigl(\tfrac{t - x_1}{r}\bigr) + S\!\bigl(\tfrac{-(t - x_2)}{r}\bigr) - 1\bigr]\]where \(x_1 = (w - \sigma)/2\), \(x_2 = (w + \sigma)/2\), \(r\) =
rise, \(w\) =width, and \(c\) is a normalisation constant.- Parameters:
rise¶ – Steepness of the
erftransition in seconds. Smaller values give a sharper step; larger values give a more gradual transition.std_dev¶ – Controls the flat-top width relative to the total
width, in seconds.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[RoundedSquareFunction]
- class SampledWaveform(**data)
Bases:
AbstractWaveformA waveform defined by an arbitrary complex array rather than an analytic function.
Use this class when the pulse envelope is provided as pre-computed samples, e.g. from an optimisation routine or when the compiler lowers an analytical
Waveforminto discrete samples for hardware that does not support analytic descriptions natively.- Parameters:
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- property duration
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sample_time: float | None
- samples: ComplexNDArray | FloatNDArray
- class SechWaveform(**data)
Bases:
WaveformA hyperbolic-secant (sech) pulse envelope.
The envelope is:
\[f(t) = \operatorname{sech}(t / \sigma) = \frac{1}{\cosh(t / \sigma)}\]The sech pulse has the desirable property of being its own Fourier transform (up to scaling), making it self-similar in time and frequency. See Rosen & Zener (1932).
- Parameters:
std_dev¶ – Width parameter \(\sigma\) of the sech pulse in seconds.
width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Note
The sech pulse does not reach zero at finite times; it decays exponentially.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[SechFunction]
- class SetupHoldWaveform(**data)
Bases:
WaveformA two-level rectangular pulse: a high-amplitude setup portion followed by a lower-amplitude hold portion.
The setup section occupies the first
riseseconds of the pulse; the hold section occupies the remainder (width - riseseconds).- Parameters:
rise¶ – Duration of the high-amplitude setup section in seconds.
amp_setup¶ – Amplitude of the setup section, dimensionless (same scale as
amp). The hold section usesampdirectly.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[SetupHoldFunction]
- class SinWaveform(**data)
Bases:
WaveformA sine-oscillating envelope.
\[f(t) = \sin(2\pi\,f\,t + \varphi)\]where \(f\) =
frequencyand \(\varphi\) =internal_phase.- Parameters:
frequency¶ – Oscillation frequency in Hz.
internal_phase¶ – Internal phase offset in radians.
width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Note
SinWaveformandCosWaveformare related by a 90° phase shift.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[Sin]
- class SoftSquareWaveform(**data)
Bases:
WaveformA square pulse with
tanh-shaped rise and fall edges.The envelope is:
\[f(t) = \tfrac{1}{2}\bigl[ \tanh\!\bigl(\tfrac{t + (w-r)/2}{r}\bigr) - \tanh\!\bigl(\tfrac{t - (w-r)/2}{r}\bigr) \bigr]\]where \(w\) =
widthand \(r\) =rise.Edge sharpness depends on
rise; very small values can introduce discontinuities at the truncation boundary.- Parameters:
rise¶ – Scale of the
tanhtransition in seconds. Larger values produce a more gradual edge; smaller values approach a sharp step.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[SoftSquareFunction]
- class SofterGaussianWaveform(**data)
Bases:
WaveformA Gaussian envelope normalised so the minimum is zero and peak is one.
Uses the same underlying
GaussianFunctionasGaussianWaveform(with \(k = \text{width} \times \text{rise}\)) but subtracts the edge value and rescales, ensuring the pulse is exactly zero at the edges and peaks at 1.- Parameters:
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[SofterGaussianFunction]
- class SofterSquareWaveform(**data)
Bases:
WaveformA normalised double-
tanhsquare pulse with extra edge softening.The raw envelope is:
\[g(t) = \tanh\!\bigl(\tfrac{t + \sigma/2 - r}{r}\bigr) - \tanh\!\bigl(\tfrac{t - \sigma/2 + r}{r}\bigr)\]which is then min/max normalised to \([0, 1]\). Here \(\sigma\) =
std_devand \(r\) =rise.- Parameters:
std_dev¶ – Width of the flat-top region in seconds. The
tanhtransitions are placed at±std_dev / 2.rise¶ – Edge rise/fall scale in seconds. The
tanhtransitions are shifted inward by onerisestep on each side.width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz.
phase¶ – Phase rotation in radians.
drag¶ – DRAG derivative scaling coefficient.
scale_factor¶ – Additional multiplicative scaling, defaults to
1.0.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[SofterSquareFunction]
- class SquareWaveform(**data)
Bases:
WaveformA flat (rectangular) pulse.
The envelope is uniform across the entire
width.- Parameters:
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shape_function_type: type[SquareFunction]
- class Waveform(**data)
Bases:
AbstractWaveformA time-dependent complex signal with a specific shape.
The envelope shape of the waveform will be calibrated to implement desired operations on the qubit such as gates or readout. The
Waveformclass stores the attributes which define the envelope shape. Callingsample()(or the convenience wrappersample_waveform()) converts the waveform into discrete in-phase (I) and quadrature (Q) samples — seesample()for the mathematical formula.- Parameters:
width¶ – Duration of the waveform in seconds.
amp¶ – Amplitude pre-factor to the envelope in Hz. When the hardware channel is correctly calibrated (via
PulseChannel.scale), constantampdrives Rabi oscillations atampHz.phase¶ – Phase rotation applied to the waveform in radians. Combined with the external
phase_offsetto rotate the IQ vector in the complex plane.drag¶ –
A coefficient which scales a quadrature component to the waveform envelope consisting of the time derivative of the in-phase component of the waveform envelope, see for example https://arxiv.org/abs/0901.0534.
scale_factor¶ – Additional multiplicative scaling applied independently of
amp, defaults to1.0.
See
sample()for the full mathematical formula.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- amp: float | complex
- amp_setup: float
- beta: float
- drag: float
- property duration
- frequency: float
- internal_phase: float
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- phase: float | complex
- rise: float
- sample(t, phase_offset=0.0)
Evaluate the waveform at discrete times t and return a
SampledWaveform.The output samples are computed as:
\[s(t) = \text{scale\_factor} \cdot \text{amp} \cdot e^{\,i\,(\text{phase} + \text{phase\_offset})} \cdot \bigl[\,f(t) + i \cdot \text{drag} \cdot f'(t)\,\bigr]\]where \(f(t)\) is the shape function determined by the subclass (via
shape_function_type).Correct calibration of the hardware channel (
PulseChannel.scale) means that using constant amplitudeampwill drive the qubit in Rabi oscillations ofampHz. For example setting onlyamp=10e6andPulseChannel.scale=1e-8means10e6 * 1e-8 = 0.1peak amplitude of the waveform sent to the control hardware.- Parameters:
- Return type:
- Returns:
A
SampledWaveformcontaining one complex sample per element of t.- Raises:
AttributeError – If
shape_function_typeisNone.
- scale_factor: float | complex
- shape_function_type: type[ComplexFunction] | None
- square_width: float
- std_dev: float
- width: float
- zero_at_edges: bool
- sample_waveform(waveform, sample_time)
Utility function to sample a waveform at a given time per sample (sample rate).
- Parameters:
- Return type:
- Returns:
A SampledWaveform containing the sampled values.