Waveforms

class braket.pulse.waveforms.Waveform[source]

Bases: ABC

A waveform is a time-dependent envelope that can be used to emit signals on an output port or receive signals from an input port. As such, when transmitting signals to the qubit, a frame determines time at which the waveform envelope is emitted, its carrier frequency, and it’s phase offset. When capturing signals from a qubit, at minimum a frame determines the time at which the signal is captured. See https://openqasm.com/language/openpulse.html#waveforms for more details.

abstractmethod sample(dt)[source]

Generates a sample of amplitudes for this Waveform based on the given time resolution.

Parameters:

dt (float) – The time resolution.

Return type:

ndarray

Returns:

np.ndarray – The sample amplitudes for this waveform.

class braket.pulse.waveforms.ArbitraryWaveform(amplitudes, id=None)[source]

Bases: Waveform

An arbitrary waveform with amplitudes at each timestep explicitly specified using an array.

Parameters:
  • amplitudes (list[complex])

  • id (str | None)

Initializes an ArbitraryWaveform.

Parameters:
  • amplitudes (list[complex]) – Array of complex values specifying the waveform amplitude at each timestep. The timestep is determined by the sampling rate of the frame to which waveform is applied to.

  • id (str | None) – The identifier used for declaring this waveform. A random string of ascii characters is assigned by default.

sample(dt)[source]

Generates a sample of amplitudes for this Waveform based on the given time resolution.

Parameters:

dt (float) – The time resolution.

Raises:

NotImplementedError – This class does not implement sample.

Return type:

ndarray

Returns:

np.ndarray – The sample amplitudes for this waveform.

class braket.pulse.waveforms.ConstantWaveform(length, iq, id=None)[source]

Bases: Waveform, Parameterizable

A constant waveform which holds the supplied iq value as its amplitude for the specified length.

Parameters:

Initializes a ConstantWaveform.

Parameters:
  • length (float | FreeParameterExpression) – Value (in seconds) specifying the duration of the waveform.

  • iq (complex) – complex value specifying the amplitude of the waveform.

  • id (str | None) – The identifier used for declaring this waveform. A random string of ascii characters is assigned by default.

property parameters: list[float | FreeParameterExpression]

Returns the parameters associated with the object, either unbound free parameter expressions or bound values.

Returns:

list[float | FreeParameterExpression] – a list of parameters.

bind_values(**kwargs)[source]

Takes in parameters and returns an object with specified parameters replaced with their values.

Parameters:

**kwargs (FreeParameter | str) – Arbitrary keyword arguments.

Return type:

ConstantWaveform

Returns:

ConstantWaveform – A copy of this waveform with the requested parameters bound.

sample(dt)[source]

Generates a sample of amplitudes for this Waveform based on the given time resolution.

Parameters:

dt (float) – The time resolution.

Return type:

ndarray

Returns:

np.ndarray – The sample amplitudes for this waveform.

class braket.pulse.waveforms.DragGaussianWaveform(length, sigma, beta, amplitude=1, zero_at_edges=False, id=None)[source]

Bases: Waveform, Parameterizable

A gaussian waveform with an additional gaussian derivative component and lifting applied.

Parameters:

Initializes a DragGaussianWaveform.

Parameters:
  • length (float | FreeParameterExpression) – Value (in seconds) specifying the duration of the waveform.

  • sigma (float | FreeParameterExpression) – A measure (in seconds) of how wide or narrow the Gaussian peak is.

  • beta (float | FreeParameterExpression) – The correction amplitude.

  • amplitude (float | FreeParameterExpression) – The amplitude of the waveform envelope. Defaults to 1.

  • zero_at_edges (bool) – bool specifying whether the waveform amplitude is clipped to zero at the edges. Defaults to False.

  • id (str | None) – The identifier used for declaring this waveform. A random string of ascii characters is assigned by default.

property parameters: list[FreeParameterExpression | FreeParameter | float]

Returns the parameters associated with the object, either unbound free parameter expressions or bound values.

bind_values(**kwargs)[source]

Takes in parameters and returns an object with specified parameters replaced with their values.

Parameters:

**kwargs (FreeParameter | str) – Arbitrary keyword arguments.

Return type:

DragGaussianWaveform

Returns:

DragGaussianWaveform – A copy of this waveform with the requested parameters bound.

sample(dt)[source]

Generates a sample of amplitudes for this Waveform based on the given time resolution.

Parameters:

dt (float) – The time resolution.

Return type:

ndarray

Returns:

np.ndarray – The sample amplitudes for this waveform.

class braket.pulse.waveforms.GaussianWaveform(length, sigma, amplitude=1, zero_at_edges=False, id=None)[source]

Bases: Waveform, Parameterizable

A waveform with amplitudes following a gaussian distribution for the specified parameters.

Parameters:

Initializes a GaussianWaveform.

Parameters:
  • length (float | FreeParameterExpression) – Value (in seconds) specifying the duration of the waveform.

  • sigma (float | FreeParameterExpression) – A measure (in seconds) of how wide or narrow the Gaussian peak is.

  • amplitude (float | FreeParameterExpression) – The amplitude of the waveform envelope. Defaults to 1.

  • zero_at_edges (bool) – bool specifying whether the waveform amplitude is clipped to zero at the edges. Defaults to False.

  • id (str | None) – The identifier used for declaring this waveform. A random string of ascii characters is assigned by default.

property parameters: list[FreeParameterExpression | FreeParameter | float]

Returns the parameters associated with the object, either unbound free parameter expressions or bound values.

bind_values(**kwargs)[source]

Takes in parameters and returns an object with specified parameters replaced with their values.

Parameters:

**kwargs (FreeParameter | str) – Arbitrary keyword arguments.

Return type:

GaussianWaveform

Returns:

GaussianWaveform – A copy of this waveform with the requested parameters bound.

sample(dt)[source]

Generates a sample of amplitudes for this Waveform based on the given time resolution.

Parameters:

dt (float) – The time resolution.

Return type:

ndarray

Returns:

np.ndarray – The sample amplitudes for this waveform.

class braket.pulse.waveforms.ErfSquareWaveform(length, width, sigma, off_center=0, amplitude=1, zero_at_edges=False, id=None)[source]

Bases: Waveform, Parameterizable

A square waveform with smoothed edges.

Parameters:

Initializes a ErfSquareWaveform.

\[(\text{step}((t-t_1)/sigma) + \text{step}(-(t-t_2)/sigma) - 1)\]

where \(\text{step}(t)\) is the rounded step function defined as \((erf(t)+1)/2\) and \(t_1\) and \(t_2\) are the timestamps at the half height. The waveform is scaled such that its maximum is equal to amplitude.

Parameters:
  • length (float | FreeParameterExpression) – Duration (in seconds) from the start to the end of the waveform.

  • width (float | FreeParameterExpression) – Duration (in seconds) between the half height of the two edges.

  • sigma (float | FreeParameterExpression) – A characteristic time of how quickly the edges rise and fall.

  • off_center (float | FreeParameterExpression) – Shift the smoothed square waveform earlier or later in time. When positive, the smoothed square is shifted later (to the right), otherwise earlier (to the left). Defaults to 0.

  • amplitude (float | FreeParameterExpression) – The amplitude of the waveform envelope. Defaults to 1.

  • zero_at_edges (bool) – Whether the waveform is scaled such that it has zero value at the edges. Defaults to False.

  • id (str | None) – The identifier used for declaring this waveform. A random string of ascii characters is assigned by default.

property parameters: list[FreeParameterExpression | FreeParameter | float]

Returns the parameters associated with the object, either unbound free parameter expressions or bound values.

bind_values(**kwargs)[source]

Takes in parameters and returns an object with specified parameters replaced with their values.

Parameters:

**kwargs (FreeParameter | str) – Arbitrary keyword arguments.

Return type:

ErfSquareWaveform

Returns:

ErfSquareWaveform – A copy of this waveform with the requested parameters bound.

sample(dt)[source]

Generates a sample of amplitudes for this Waveform based on the given time resolution.

Parameters:

dt (float) – The time resolution.

Return type:

ndarray

Returns:

np.ndarray – The sample amplitudes for this waveform.