paraqeet.signal package

Submodules

paraqeet.signal.envelopes module

Class definition for the Evelopes.

class paraqeet.signal.envelopes.ConstantEnvelope

Bases: Envelope

A constant envelope tone with a fixed length.

_amplitude: Quantity

The amplitude of the envelope.

_t_final: Quantity

The length in time of the envelope.

_gradientFunction: Callable | None

The function to calculate the gradient with respect to a set of previously defined parameters.

_grad_arg_nums: tuple[int, …]

The identifying indices of which parameters to calculate the gradient with respect to.

compute_output(t)

Compute the constant signal envelope at different times.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Output of the computation.

Return type:

Array

Raises:

NotImplementedError – Subclasses derived from this class must implement this method.

compute_time_gradient(t)

Compute a signal envelopes time derivative.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector signals time derivative.

Return type:

Array

class paraqeet.signal.envelopes.DCRABEnvelope

Bases: Envelope

Create a dCRAB pulse envelope.

The dCRAB pulse is given as a sum of sinusoidal components as [Müller2022] $$f(t) = g(t)Big( 1 + sum_{i=1}^{N_c / 2} c_{2i} frac{cos(omega_{2i} t)}{Lambda(t)}

  • sum_{i = 1} ^ {N_c/2} c_{2i + 1} frac{sin(omega_{2i + 1} t)}{Lambda(t)} Big)$$

Here we consider $g(t) = Lambda(t) = 1$ for simplicity. Further, even components are for cosine and odd components are for sine. Note - The function is designed to work well for even total number of components. For odd total number it may not work as expected.

[Müller2022] Müller et al. “One decade of quantum optimal control in the chopped random basis”

_amplitude: Quantity

The amplitude of the envelope.

_t_final: Quantity

The length in time of the envelope.

_num_components: int

Number of components added each iteration to the dCRAB basis. Defaults to 2. Adviced to be an even number.

_total_num_components: int

Total number of components in the current dCRAB basis. This is the number of coefficients or the number of frequencies present. NOT the sum of them.

_real_coefficients: list[Quantity]

Vector quantity as a list of amplitudes of individual sinusoidal components.

_real_frequencies: list[Quantity]

Vector quantity as a list of frequencies of individual sinusoidal components.

_real_phases: list[Quantity]

Vector quantity as a list of phases of individual sinusoidal components.

_gradient_function: Callable | None

The function to calculate the gradient with respect to a set of previously defined parameters.

_grad_arg_nums: tuple[int, …]

The identifying indices of which parameters to calculate the gradient with respect to.

__init__(amplitude=None, t_final=None, num_components=2, min_frequency=0.0, max_frequency=31.41592653589793, seed=None)
Parameters:
  • amplitude (Quantity | None)

  • t_final (Quantity | None)

  • num_components (int)

  • min_frequency (float)

  • max_frequency (float)

  • seed (int | None)

add_new_components(seed=None)

Add self._num_components number of new randomized components to the optimization.

Parameters:

seed (int | None)

Return type:

None

compute_output(t)

Compute the CRAB signal.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector CRAB signal.

Return type:

Array

get_coefficients_frequencies_and_phases()

Return all the coefficients and frequencies used in the CRAB signal.

Return type:

list[Quantity]

get_parameters()

Return the parameters of the CRAB signal. The parameters are arranged as follows,

[amplitude, t_final, … total_num coefficients …, … total_num frequencies …]

remove_small_coefficients(tol=1e-07)

Remove coefficients (and corresponding frequencies) that are smaller than a tolerance.

Parameters:

tol (float)

Return type:

None

class paraqeet.signal.envelopes.Envelope

Bases: Waveform

Classical Signal Envelope class.

_amplitude: Quantity

The amplitude of the envelope.

_t_final: Quantity

The length in time of the envelope.

_gradient_function: Callable | None

The function to calculate the gradient with respect to a set of previously defined parameters.

_grad_arg_nums: tuple[int, …]

The identifying indices of which parameters to calculate the gradient with respect to.

__init__(amplitude=None, t_final=None)
Parameters:
property amplitude: Quantity

Get the amplitude of the system.

Returns:

Amplitude of the system.

Return type:

Quantity

abstract compute_output(t)

Compute the output.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Output of the computation.

Return type:

Array

Raises:

NotImplementedError – Subclasses derived from this class must implement this method.

get_parameters()

Get a list of parameters of the envelope.

Returns:

List of parameters of the envelope.

Return type:

List[Quantity]

property t_final: Quantity

Get the length of the tone.

Returns:

Length in time of the tone.

Return type:

Quantity

class paraqeet.signal.envelopes.FlatTopGaussianEnvelope

Bases: Envelope

A flat-top Gaussian envelope.

_amplitude: Quantity

The amplitude of the envelope.

_t_final: Quantity

The length in time of the envelope.

_gradient_function: Callable | None

The function to calculate the gradient with respect to a set of previously defined parameters.

_grad_arg_nums: tuple[int, …]

The identifying indices of which parameters to calculate the gradient with respect to.

compute_gradient(t)

Return the gradient wrt dimensionless parameters.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns the gradient wrt dimensionless parameters.

Return type:

Array

compute_output(t)

Get the output of the device on time stamps.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns the output of the device.

Return type:

Array

compute_time_gradient(t)

Compute a signal envelopes time derivative.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector signals time derivative.

Return type:

Array

class paraqeet.signal.envelopes.GaussEnvelope

Bases: Envelope

Create a simple Gauss envelope.

_amplitude: Quantity

The amplitude of the envelope.

_t_final: Quantity

The length in time of the envelope.

_gradient_function: Callable | None

The function to calculate the gradient with respect to a set of previously defined parameters.

_grad_arg_nums: tuple[int, …]

The identifying indices of which parameters to calculate the gradient with respect to.

compute_output(t)

Compute a Gaussian signal.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector gaussian signal.

Return type:

Array

compute_time_gradient(t)

Compute a Gaussian signals time derivative.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector gaussian signals time derivative.

Return type:

Array

class paraqeet.signal.envelopes.ZeroEnvelope

Bases: ConstantEnvelope

Shorthand implentation of a zero signal envelope.

_amplitude: Quantity

The amplitude of the envelope.

_t_final: Quantity

The length in time of the envelope.

_gradientFunction: Callable | None

The function to calculate the gradient with respect to a set of previously defined parameters.

_grad_arg_nums: tuple[int, …]

The identifying indices of which parameters to calculate the gradient with respect to.

__init__()

paraqeet.signal.generator module

Class definition of the Generator model.

class paraqeet.signal.generator.Generator

Bases: Optimisable

Signal generation stack.

Contrary to most quantum simulators, paraqeet includes a detailed simulation of the control stack. Each component in the stack and its functions are simulated individually and combined here.

Example: A local oscillator and arbitrary waveform generator signal are put through via a mixer device to produce an effective modulated signal.

abstract generate_signal(times)

Return array with scalar signal value for each time step.

Parameters:

times (Array) – One-dimensional vector of timestamps.

Returns:

Returns the scalar signal vector.

Return type:

Array

Raises:

NotImplementedError – Subclasses derived from this class must implement this method.

abstract generate_signal_gradient(times)

Return array with gradient of signal value for each time step.

Abstract method. The result has the shape (t,p) where ‘t’ is the time and ‘p’ is the parameter index.

Parameters:

times (Array) – One-dimensional vector of timestamps.

Returns:

Returns the signal gradient vector.

Return type:

Array

Raises:

NotImplementedError – Subclasses derived from this class must implement this method.

abstract generate_signal_gradient_one_time(time)

Return array with the gradient of the signal value for one time step.

The result has the shape (p,) where ‘p’ is the parameter index.

Parameters:

time (Array) – One time stamp.

Return type:

Array

Raises:

NotImplementedError – Subclasses derived from this class must implement this method.

paraqeet.signal.iq_mixer module

Class definition for the Sinusoidal generator model.

class paraqeet.signal.iq_mixer.IQMixer

Bases: Generator

Control signal generation.

Waveforms of envelopes (low bandwith) are mixed with a local oscillator (high bandwidth) to apply a desired control field to the system.

Parameters:

envelopes (List[Waveform]) – List of input devices.

__init__(envelopes, frequency=None, phase=None)
Parameters:
generate_signal(times)

Generate a signal for time(s) ‘t’.

Parameters:
  • t (Array) – One-dimensional vector of timestamps.

  • times (Array)

Returns:

Returns the signal vector.

Return type:

Array

generate_signal_gradient(times)

Collect and returns the gradients from all devices.

Since the

\[\begin{split}signal = \\Re(\\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

Derivative of the signal wrt optimisable parameter of envelope would be

\[\begin{split}0.5 * \\Re(\\partial \\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

(TODO - Check the envelope derivatives)

And derivative of signal wrt parameter of LO would be

\[\begin{split}0.5 i t \\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

And derivative of signal wrt phase would be

\[\begin{split}-0.5 i \\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

The 0.5 are due to the Wirtinger derivatives due to Re part.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns the signal gradient vector.

Return type:

Array

generate_signal_gradient_one_time(time)

Return the gradients from all devices at the given time.

Since the

\[\begin{split}signal = \\Re(\\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

Derivative of the signal wrt optimisable parameter of envelope would be

\[\begin{split}0.5 * \\Re(\\partial \\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

(TODO - Check the envelope derivatives)

And derivative of signal wrt parameter of LO would be

\[\begin{split}0.5 i t \\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

And derivative of signal wrt phase would be

\[\begin{split}-0.5 i \\epsilon(t)^* \\exp(i \\omega t) \\exp(-i \\phi))\end{split}\]

The 0.5 are due to the Wirtinger derivatives due to Re part.

Parameters:

time (Array) – Single timestamp.

Returns:

Return the gradients from all devices at one time.

Return type:

Array

get_parameters()

Return a list of parameters.

Collects and returns a list of parameters from the tone, generator and the carrier signal.

Returns:

All Parameters describing the signal.

Return type:

list[Quantity]

set_optimisable_parameters(params)

Set specified parameters to be optimised.

Parameters:

params (list[Quantity])

Return type:

None

paraqeet.signal.pwc_generator module

class paraqeet.signal.pwc_generator.PWCGenerator

Bases: Generator

Convert a complex envelope to PWC pulse.

This sets the pulse parameters to the tlist points. The gradient of the pulse wrt the PWC bins is 1 at that time point and zero everywhere else.

This Generator doesn’t add the LO signal to the envelope pulse. Driving with a PWC pulse (without the LO) is usually done in the rotating frame of drive.

This Generator converts the input complex pulse to the ‘in-phase’ and ‘out-of-phase’ components. This naming convention is used by following [Krantz2019]. In the literature of signal processing these are also called ‘in-phase’ and ‘quadrature’ components (refer to https://en.wikipedia.org/wiki/In-phase_and_quadrature_components).

[Krantz2019] Krantz et al., “A Quantum Engineer’s Guide to Superconducting Qubits.” Applied Physics Reviews 6(2019).

__envs: list[Waveform]

List of Envelopes

__tlist: Array

Time grid discritization points

__max_amplitude: float

Maximum amplitude of the drive

__inphase: Quantity

The in-phase component of the pulse

__outofphase: Quantity

The out-of-phase component of the pulse

_optimisable_paramters: list[Quantity]

List of own parameters that would be optimised by the optimiser.

__multiply_flat_top: bool

Flag to multiply flat-top-Gaussain pulse to the signal to ensure it starts and ends at zero.

Parameters:

envelopes (List[Waveform]) – List of input devices.

__init__(envelopes, tlist, max_amplitude=None)
Parameters:
  • envelopes (list[Waveform] | None)

  • tlist (Array)

  • max_amplitude (float | None)

property envs: list[Waveform]

Gets the list of envelopes.

Returns:

The list of waveforms associated with the generator.

Return type:

list[Waveform]

generate_signal(times)

Generate the PWC signal for time(s) ‘t’.

Parameters:
  • t (Array) – One-dimensional vector of timestamps.

  • times (Array)

Returns:

Returns the signal vector.

Return type:

Array

generate_signal_gradient(times)

Return signal gradient wrt inphase and out-of-phase.

This returns a list of ones as the gradient of the envelope wrt a step is 1 for that time bin and 0 everywhere else.

Parameters:
  • t (Array) – Array of time steps.

  • times (Array)

Returns:

PWC signal gradients.

Return type:

Array

generate_signal_gradient_one_time(time)

Return signal gradient wrt inphase and out-of-phase.

This returns a list of ones as the gradient of the envelope wrt a step is 1 for that time bin and 0 everywhere else.

Parameters:

time (Array) – One time step.

Returns:

PWC signal gradients.

Return type:

Array

get_number_of_pwc_pixels()

Return number of PWC pixels generated by the PWC generator.

Return type:

int

get_parameters()

Return a list of parameters.

Return the inphase and out-of-phase as parameters.

Returns:

All Parameters describing the signal.

Return type:

list[Quantity]

property max_amplitude: float

Get the maximum drive amplitude.

Return type:

The value of the maximum drive amplitude.

property multiply_flat_top: bool

Flag to multiply the pulse with a FlatTop.

This can be used to make the start and end values zeros and force the PWC pulse to change smoothly.

Returns:

multiply_flat_top – Flag value for multiply_flat_top.

Return type:

bool

set_optimisable_parameters(params)

Set specified parameters to be optimised.

Optimisable paramters can be inphase and out-of-phase.

Parameters:

params (list[Quantity])

Return type:

None

property tlist: Array

Get time grid discritization for generating PWC pulse.

Returns:

Array of time points at which envelope is discritized.

Return type:

Array

paraqeet.signal.waveform module

Class definition for the Device model.

class paraqeet.signal.waveform.DRAGMixer

Bases: Waveform

A DRAG mixed waveform signal.

The DRAG component is calculated for a set of envelopes and added in orthogonal direction in the x-y plane.

__envs: list[Envelope]

The list of shape defining signal envelops.

__deltas: list[Quantity]

The delta parameter by which to shift the frequency of the DRAG component.

__init__(envelopes, deltas=None, t_final=None)
Parameters:
Return type:

None

compute_gradient(t)

Generate gradient of the signal for an array of time.

Collect and return the parameter gradients from the Tone and the carrier Tone. Compute the gradient of the generator parameters by AD. The order of the gradients should match the order of paramters in self.get_parameter() method

Parameters:

t (Array) – An array of time points.

Returns:

Array of gradients wrt each parameter for each time point.

Return type:

Array

compute_output(t)

Evaluate a carrier signal from an input time vector.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector carrier signal.

Return type:

Array

get_envelopes()

Return envelopes from the DRAGMixer.

Return type:

list[Waveform]

get_parameters()

Return a list of parameters.

Collects and returns a list of parameters from the tone, generator and the carrier signal.

Returns:

All Parameters describing the signal.

Return type:

list[Quantity]

property multiply_flat_top: bool

Flag to multiply the pulse with a FlatTop.

This can be used to make the start and end values zeros and force the pulse to change smoothly.

Returns:

multiply_flat_top – Flag value for multiply_flat_top.

Return type:

bool

set_optimisable_parameters(params)

Set specified parameters to be optimised.

Also add the indices to __grad_arg_nums to compute the gradients.

Parameters:

params (list[Quantity])

Return type:

None

class paraqeet.signal.waveform.FlatTopGaussianFilter

Bases: Waveform

A shape filter that forces the pulse to smoothly start and end at zero. This filter multiplies the input pulse with a flat-top Gaussian pulse.

This is similar to PWCGenerator.multiply_flat_top = True.

__init__(envelopes, t_final)
Parameters:
compute_gradient(t)

Generate gradient of the signal for an array of time.

Collect and return the parameter gradients from the Tone and the carrier Tone. Compute the gradient of the generator parameters by AD. The order of the gradients should match the order of paramters in self.get_parameter() method

Parameters:

t (Array) – An array of time points.

Returns:

Array of gradients wrt each parameter for each time point.

Return type:

Array

compute_output(t)

Evaluate a carrier signal from an input time vector.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector carrier signal.

Return type:

Array

get_envelopes()

Return envelopes from the DRAGMixer.

Return type:

list[Waveform]

get_parameters()

Return a list of parameters.

Collects and returns a list of parameters from the tone, generator and the carrier signal.

Returns:

All Parameters describing the signal.

Return type:

list[Quantity]

set_optimisable_parameters(params)

Set specified parameters to be optimised.

Also add the indices to __grad_arg_nums to compute the gradients.

Parameters:

params (list[Quantity])

Return type:

None

class paraqeet.signal.waveform.LocalOscillator

Bases: Waveform

A local oscillators carrier signal.

__lo_freqQuantity

The frequency of the carrier signal.

__init__(frequency=None)
Parameters:

frequency (Quantity | None)

Return type:

None

compute_gradient(t)

Return the gradient wrt to frequency of carrier signal.

Parameters:

t (Array) – Array of time points to evaluate gradients at.

Returns:

Gradient of tone wrt to frequency.

Return type:

Array

compute_output(t)

Evaluate a carrier signal from an input time vector.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector carrier signal.

Return type:

Array

compute_time_gradient(t)

Compute a signals time derivative.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector signals time derivative.

Return type:

Array or JitWrapped

property frequency: Quantity

Get The frequency of the constant oscillating tone.

Returns:

The frequency of the tone.

Return type:

Quantity

get_parameters()

Return device parameters.

Returns:

Returns the carrier signal frequency.

Return type:

list[Quantity]

class paraqeet.signal.waveform.Waveform

Bases: Optimisable

Classical electronics.

compute_gradient(t)

Compute the gradient of the _evaluate method.

Uses Automatic differentiation. The _evaluate method should be a pure function (should take the optimisable parameters as function arguments and doesn’t depend on global variables). Refer to https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html for functionally pure functions. To implement analytical gradients / other methods for gradient computation overwrite this method in the inherited class.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns the gradient array of the _evaluate method.

Return type:

Array

abstract compute_output(t)

Compute the output.

Parameters:

t (Array) – One-dimensional vector of timestamps or a single value.

Returns:

Output of the computation.

Return type:

Array

Raises:

NotImplementedError – Subclasses derived from this class must implement this method.

compute_time_gradient(t)

Compute a signal envelopes time derivative.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector signals time derivative.

Return type:

Array

set_optimisable_parameters(params)

Set optimisable parameters for optimisation.

Parameters:

params (list[Quantity]) – Input list of parameters to be set.

Return type:

None

Module contents

Signal generation model module.