paraqeet.measurement package

Submodules

paraqeet.measurement.goat_over_grape module

Class definition of the Weighted Sum Goal model.

class paraqeet.measurement.goat_over_grape.GOATOverGRAPE

Bases: Measurement

Combine GRAPE propagation with analytic gradients of GOAT via chain rule.

Note - currently only works with one PWCGenerator per subsystem.

Parameters:
  • measurement (StateTransferFidelityGRAPE) – A StateTransferFidelityGRAPE measurement.

  • generators (PWCGenerator | list[PWCGenerator]) – A PWCGenerator or a list of PWCGenerators that are used for propagation.

  • generators_order (list[int]) – Specify the subsystem number (starting with 0) the corresponding generator is associated with. This is required to correctly order the gradients obtained from GRAPE.

__init__(measurement, generators, generators_order)
Parameters:
get_parameters()

Return measurement specific parameters. This class does not contain any optimisable parameters.

measure()

Sum of plain weighted measurements.

Returns:

Returns the plain weighted sum.

Return type:

Array

measure_normalised_scalar()

Passthrough the measurement.

Returns:

Returns the normalized weighted sum.

Return type:

Array

measure_with_gradient()

Compute gradients with GRAPE and use the chain rule to provide the gradients for the optimiser.

Returns:

  • Array – Function value.

  • Array – Gradients.

Return type:

tuple[float, Array]

pad_with_zeros(grad, subsys_num)

Pad gradient with zeros depending on the subsystem number and number of PWC pixels in the pulses.

Parameters:
  • grad (Array) – _description_

  • subsys_num (int) – _description_

Returns:

_description_

Return type:

Array

paraqeet.measurement.makhlin_functional module

Class definition of the Makhlin functional.

class paraqeet.measurement.makhlin_functional.MakhlinFunctional

Bases: Measurement

Class definition of the Makhlin Functional invariants.

Measures the distance of a propagator to a perfect entangler using Makhlin invariants. If a list of ideal Makhlin invariants is given, the distance is measured as the Euclidean distance between the actual and ideal invariants. Else, the Makhlin distance is used.

Parameters:
  • propagation (Propagation) – Abstract base class for any implementation that can solve the equation of motion.

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

  • ideal_invariants (Array optional) – One-dimensional vector of ideal Makhlin invariants.

__init__(propagation, times, ideal_invariants=None)
Parameters:
  • propagation (Propagation)

  • times (Array)

  • ideal_invariants (Array | None)

get_parameters()

Get the parameters of the system.

Returns:

Returns the list of parameters of the system.

Return type:

list[Quantity]

measure()

Measure distance of the propagator to a perfect entangler.

Returns:

Distance of propagator.

Return type:

Array

Raises:

IncompatibleLayersException – Raises an exception if a quadratic unitary 4x4 operator is not received.

paraqeet.measurement.measurement module

Class definition of the Measurement model.

class paraqeet.measurement.measurement.Measurement

Bases: Optimisable

Represents any observable and the process of measurement itself.

The observable is measured after the propagation class has solved the equation of motion.

Parameters:

times (Array | None, optional) – One-dimensional vector of timestamps.

__init__(times)
Parameters:

times (Array)

measure()

Measure the observable and returns the value.

Abstract Method. This function must be implemented by subclasses.

Returns:

This abstract method must return an Array or a float when implemented by subclasses. Might return multiple values.

Return type:

Array or float

Raises:

NotImplementedError – If a subclass does not implement the measure method, raise an error.

measure_normalised_scalar()

Measure the normalised observable.

Returns a single scalar value between 0 and 1, 1 representing the perfect result, required for use with most optimisations. This function must be implemented by subclasses.

Returns:

Returns an Array if implemented by a subclass.

Return type:

Array

measure_scalar()

Measure the observable.

Returns a scalar value. This function must be implemented by subclasses, unless identical to self.measure_normalised_scalar().

Return type:

float

measure_with_gradient()

Measure with gradient.

Compute the measurement value as in measureNormalised() but with the gradient wrt to parameters.

Returns:

Tuple of function value as bare float and gradient of shape (n_parameters,)

Return type:

Tuple[float, Array]

Raises:

NotImplementedError – If a subclass does not implement the measureWithGradient method, raise an error.

restrict_subsystems(input_dimensions, output_dimensions=None)

Restrict subsystem by projecting to a subspace.

Notifies the measurement class that the computed propagator should be projected to a subspace before doing the measurement. Dimensions of the subspaces are specified per subsystem.

Parameters:
  • input_dimensions (List[int]) – Actual dimensions of all subsystems.

  • output_dimensions (List[int] | None, optional) – Desired dimensions of all subsystems. Individual values can be 0 to fully remove subsystems from the propagator. The list can be None to disable projection.

Raises:
  • RuntimeError – If the input and output dimensions don’t have the same number of subsystems.

  • RuntimeError – If the dimensions are negative.

  • RuntimeError – If the output dimensions are larger than the input dimensions.

  • RuntimeError – If all output dimensions are zero.

Return type:

None

paraqeet.measurement.mixed_state_transfer_fidelity module

Class definition for a mixed state transfer fidelity model.

class paraqeet.measurement.mixed_state_transfer_fidelity.MixedStateTransferFidelity

Bases: Measurement

Mixed state transfer fidelity measurement model.

Fidelity measure that compares the overlap of the initial and final state of density matrices. Note: this implementation is still very inaccurate.

Parameters:
  • propagation (Propagation) – Abstract base class for any implementation that can solve the equation of motion.

  • targetState (Array) – Final state of the density matrices.

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

__init__(propagation, targetState, times)
Parameters:
  • propagation (Propagation)

  • targetState (Array)

  • times (Array)

get_parameters()

Returns an empty list.

Return type:

list[Quantity]

measure()

Measure overlap between initial and final state of density matrices.

Returns:

Overlap between initial and final state of density matrices.

Return type:

Array

Raises:

IncompatibleLayersException – Raises an exception if required vector shape is not received.

paraqeet.measurement.rabi_experiment module

Class definition of a Rabi experiment model.

class paraqeet.measurement.rabi_experiment.RabiExperiment

Bases: Measurement

Analytic model of the general Rabi formula.

Parameters:

qubit_freq (Quantity) – Resonance of the single qubit.

__init__(qubit_freq)
Parameters:

qubit_freq (float)

Return type:

None

get_parameters()

Return a list of parameters accessible in this measurement.

Returns:

List of parameters accessible in this measurement.

Return type:

List[Quantity]

measure_normalised_scalar()

Carry out a measurement operation.

Gives the result of a general Rabi oscillation, depending of drive frequency, amplitude and time.

Returns:

Result of a general Rabi oscillation.

Return type:

Array

paraqeet.measurement.smoothness module

Class definition of the pulse smoothness. It follows the definition in [Heeres2017], in particular Eqs. 21 of the supplementary material.

References [Heeres2017] R. Heeres et al., Nat. Comm. 8, 94 (2017)

class paraqeet.measurement.smoothness.Smoothness

Bases: Measurement

Smoothness of a pulse. It follows the definition in Heeres et al., https://arxiv.org/abs/1608.02430 (2017), in particular Eqs. 23 and 24 of the supplementary material.

Parameters:
  • pwc_generator (PWCGenerator) – The generator from which we extract the pulse.

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

__init__(pwc_generator)
Parameters:

pwc_generator (PWCGenerator)

get_parameters()

Returns an empty list.

Return type:

list[Quantity]

measure_normalised_scalar()

Returns the normalized sum of consecutive square differences of the pulse. As the maximums difference is twice the maximum amplitude, the normalization factor is the number of piecewise constants minus 1 time sthe maximum difference squared.

Returns:

The normalized sum of consecutive square differences in the pulse.

Return type:

float

measure_with_gradient()

Measure with gradient.

Compute the measurement value as in measure_normalised_scalar() and the gradient with respect to all parameters in the optimisation map. For parameters that are not in the passed PWCGenerator the partial derivative if simply zero.

Returns:

Tuple of function value as bare float and gradient of shape (n_parameters,)

Return type:

Tuple[float, Array]

paraqeet.measurement.state_transfer_fidelity module

The class definition of state transfer fidelity model.

class paraqeet.measurement.state_transfer_fidelity.StateTransferFidelity

Bases: Measurement

Fidelity measure that compares overlap of the initial and final state.

Parameters:
  • propagation (StatePropagation) – Abstract base class for any implementation that can solve the equation of motion.

  • initial_state (Array) – Initial state.

  • target_state (Array) – Target state.

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

__init__(propagation, initial_state, target_state, times)
Parameters:
  • propagation (StatePropagation)

  • initial_state (Array)

  • target_state (Array)

  • times (Array)

get_parameters()

Get the parameters of the system.

Returns:

List of parameters of the system.

Return type:

list[Quantity]

measure_normalised_scalar()

Measure overlap between initial and target state.

Returns:

Overlap between initial and target state in a JAX ArrayLike format.

Return type:

Array

measure_with_gradient()

Compute function value and corresponding gradient.

Returns:

Tuple of function value and gradient of shape (n_parameters,).

Return type:

Tuple[Array, Array]

class paraqeet.measurement.state_transfer_fidelity.StateTransferFidelityAD

Bases: StateTransferFidelity

Fidelity measure that compares overlap of the initial and final state.

Parameters:
  • propagation (Propagation) – Abstract base class for any implementation that can solve the equation of motion.

  • initial_state (Array) – Initial state.

  • target_state (Array) – Target state.

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

__init__(propagation, initial_state, target_state, times)
Parameters:
  • propagation (StatePropagation)

  • initial_state (Array)

  • target_state (Array)

  • times (Array)

measure_with_gradient()

Measure with gradient.

Overwrite inherited measureWithGradient to calculate gradients using AD.

Returns:

Tuple of function value and gradient of shape (n_parameters,).

Return type:

Tuple[float, Array]

class paraqeet.measurement.state_transfer_fidelity.StateTransferFidelityGRAPE

Bases: StateTransferFidelity

Fidelity measure that compares overlap of the initial and final state.

For GRAPE the optimisable parameters are vector quantities.

Parameters:
  • propagation (StatePropagation) – Abstract base class for any implementation that can solve the equation of motion.

  • initial_state (Array) – Initial state.

  • target_state (Array) – Target state.

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

measure_with_gradient()

Compute function value and corresponding gradient.

Returns:

Tuple of function value and gradient of shape (n_parameters,).

Return type:

Tuple[Array, Array]

paraqeet.measurement.unitary_fidelity module

Class definition of the unitary fidelity model.

class paraqeet.measurement.unitary_fidelity.UnitaryFidelity

Bases: Measurement

Unitary fidelity measurement model.

Fidelity measure that compares the propagator with a desired gate by way of L2 norm.

Parameters:
  • propagation (Propagation) – Implementation of EOM solver.

  • gate (Array) – Matrix representation of target gate.

  • times (Array) – List of times to compare. Should have length 2. More is allowed, but only the first and last are used.

  • basis_states (Array optional) – List of basis states. If set the ideal and actual gate are applied to these states and their pairwise overlap computed, equivalent to the L2 trace norm. Defaults to [].

__init__(propagation, gate, times, basis_states=None)
Parameters:
  • propagation (Propagation)

  • gate (Array)

  • times (Array)

  • basis_states (Array | None)

get_parameters()

Get parameters of the system.

Returns:

Returns the parameters of the system.

Return type:

list[Quantity]

measure_normalised_scalar()

Return the L2 norm of the last time step compared to the ideal gate.

Returns:

L2 norm of the last time step compared to the ideal gate.

Return type:

Array

measure_with_gradient()

Get the L2 norm and the analytic expression for the gradient.

Returns:

Tuple of function value and gradient of shape (n_parameters,).

Return type:

Tuple[Array Array]

set_ideal_gate(gate)

Compute target states for the L2 norm.

Parameters:

gate (Array) – Target state computation via this gate.

paraqeet.measurement.weighted_sum_goal module

Class definition of the Weighted Sum Goal model.

class paraqeet.measurement.weighted_sum_goal.WeightedSumGoal

Bases: Measurement

Combine multiple measurements into a single goal function.

Parameters:
  • measurements (list[Measurement]) – List of measurements.

  • weights (Array) – List of weights.

  • sum_of_squares_options (dict | None) –

    A dictionary that contains information about how to include the sum of square differences in the cost function. If not None the it must contain the following keys: weight : float

    The weight of the sum of square differences

    meas_boollist[bool]

    A list of boolean of the same length as measurements. If an element is True then the corresponding measurement is included in the sum of square difference the goal function.

  • measurement_in_sum_of_squares (list[Measurement] | None) – The list of measurements included in the sum of square difference cost function. It is None if sum_of_squares_options is None

Raises:
  • ConfigurationException – If number of measurements and weights are incompatible.

  • UserWarning – If the given weights are not normalized.

__init__(measurements, weights, sum_of_squares_options=None)
Parameters:
  • measurements (list[Measurement])

  • weights (Array)

  • sum_of_squares_options (dict | None)

get_parameters()

Returns an empty list.

Return type:

list[Quantity]

measure()

Sum of plain weighted measurements.

Returns:

Returns the plain weighted sum.

Return type:

Array

measure_normalised_scalar()

Sum of weighted measurements from normalized measurements.

Returns:

Returns the normalized weighted sum.

Return type:

Array

measure_with_gradient()

Sum of weighted measurements from gradient-ized measurements.

Returns:

  • Array – Returns the weighted sum wrt to gradients.

  • Array – Returns the sum of gradients.

Return type:

tuple[float, Array]

property measurements: list[Measurement]

Returns the list of measurement

property measurements_in_sum_of_squares: list[Measurement]

Returns the list of measurement included in the sum of square difference cost function

property sum_of_square_options: dict | None

Returns the dictionary with the options about the sum of square differences goal function

property weights: Array

Returns the weights used in the weighted goal function

Module contents

Measurement model module.