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.

get_time_gradient(times)

Compute a signal envelopes time derivative.

Parameters:

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

Returns:

Returns a vector signals time derivative.

Return type:

Array

get_value(times)

Compute the constant signal envelope at different times.

Parameters:

times (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.

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

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 …]

get_value(t)

Compute the CRAB signal.

Parameters:

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

Returns:

Returns a vector CRAB signal.

Return type:

Array

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

get_parameters()

Get a list of parameters of the envelope.

Returns:

List of parameters of the envelope.

Return type:

List[Quantity]

abstract get_value(times)

Compute the output.

Parameters:

times (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.

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_up: Quantity

The start time of constant section of the envelope.

_t_down: Quantity

The end time of constant section of the envelope.

_ramp_time: Quantity

The rate of ramp up and ramp down of the envelope.

_t_final: Quantity

The length in time of the envelope. Used only if any of t_up, t_down, and ramp_time are none.

_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_up=None, t_down=None, ramp_time=None, t_final=None)
Parameters:
get_parameters()

Get all parameters of the system.

get_time_gradient(times)

Compute a signal envelopes time derivative.

Parameters:

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

Returns:

Returns a vector signals time derivative.

Return type:

Array

get_value(times)

Get the output of the device on time stamps.

Parameters:

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

Returns:

Returns the output of the device.

Return type:

Array

get_value_and_gradient(times)

Return the gradient wrt dimensionless parameters.

Parameters:

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

Returns:

Returns the gradient wrt dimensionless parameters.

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.

get_time_gradient(times)

Compute a Gaussian signals time derivative.

Parameters:

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

Returns:

Returns a vector gaussian signals time derivative.

Return type:

Array

get_value(times)

Compute a Gaussian signal.

Parameters:

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

Returns:

Returns a vector gaussian signal.

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: Optimizable, Differentiable

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 get_gradient_at_timestep(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

abstract get_value(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

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.

  • frequency (Quantity | None) – Frequency of local oscillator.

  • phase (Quantity | None) – Phase of local oscillator.

__init__(envelopes, frequency=None, phase=None)
Parameters:
get_gradient_at_timestep(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 optimizable 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]

get_value(times)

Generate a signal for time(s).

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

  • times (Array | float)

Returns:

Returns the signal vector.

Return type:

Array

get_value_and_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 optimizable 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

set_optimizable_parameters(params)

Set specified parameters to be optimized.

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

Left time points for discretization. These can be used for propagation and optimization.

_time_grid: Array

Time grid used to discretize the pulse. These are shifted from tlist by dt, and doesn’t include zero time.

_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

_optimizable_paramters: list[Quantity]

List of own parameters that would be optimized by the optimizer.

_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]

get_gradient_at_timestep(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]

get_value(times)

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

Parameters:

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

Returns:

Returns the signal vector.

Return type:

Array

get_value_and_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:

times (Array) – Array of time steps.

Returns:

PWC signal gradients.

Return type:

Array

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_optimizable_parameters(params)

Set specified parameters to be optimized.

Optimizable 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)
Parameters:
Return type:

None

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]

get_value(times)

Evaluate a carrier signal from an input time vector.

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

  • times (Array | float)

Returns:

Returns a vector carrier signal.

Return type:

Array

get_value_and_gradient(times)

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:

times (Array) – An array of time points.

Returns:

Array of gradients wrt each parameter for each time point.

Return type:

Array

set_optimizable_parameters(params)

Set specified parameters to be optimized.

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.

Note - Use filters before the generators. Else Automatic differentiation does not work.

This is similar to PWCGenerator.multiply_flat_top = True.

__init__(envelopes, t_final)
Parameters:
get_envelopes()

Return envelopes from the FlatTopGaussianFilter.

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]

get_value(times)

Evaluate a carrier signal from an input time vector.

Parameters:

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

Returns:

Returns a vector carrier signal.

Return type:

Array

get_value_and_gradient(times)

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:

times (Array) – An array of time points.

Returns:

Array of gradients wrt each parameter for each time point.

Return type:

Array

set_optimizable_parameters(params)

Set specified parameters to be optimized.

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

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]

get_time_gradient(times)

Compute a signals time derivative.

Parameters:

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

Returns:

Returns a vector signals time derivative.

Return type:

Array or JitWrapped

get_value(times)

Evaluate a carrier signal from an input time vector.

Parameters:

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

Returns:

Returns a vector carrier signal.

Return type:

Array

get_value_and_gradient(times)

Return the gradient wrt to frequency of carrier signal.

Parameters:

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

Returns:

Gradient of tone wrt to frequency.

Return type:

Array

class paraqeet.signal.waveform.Waveform

Bases: Optimizable, Differentiable

Classical electronics.

get_time_and_parameter_gradient(times)

Compute the double derivative with respect to parameter and time.

This function computes $\frac{\partial^2 \Omega}{\partial t \partial alpha}$ for a pulse $\Omega(t)$ and parameter $\alpha$.

Parameters:

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

Returns:

Returns a vector signals time derivative.

Return type:

Array

get_time_gradient(times)

Compute a signal envelopes time derivative.

Parameters:

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

Returns:

Returns a vector signals time derivative.

Return type:

Array

abstract get_value(times)

Compute the output.

Parameters:

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

Returns:

Output of the computation.

Return type:

Array

get_value_and_gradient(times)

Compute the gradient of the _evaluate method.

Uses Automatic differentiation as a fallback. The _evaluate method should be a pure function (should take the optimizable 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:

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

Returns:

Returns the gradient array of the _evaluate method.

Return type:

Array

set_optimizable_parameters(params)

Set optimizable parameters for optimization.

Parameters:

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

Return type:

None

Module contents

Signal generation model module.