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

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

Parameters:
__init__(measurement, propagation, generators)
Parameters:
calculate_normalized_scalar(times)

Passthrough the measurement.

Returns:

Returns the normalized weighted sum.

Return type:

Array

Parameters:

times (Array | float)

get_value_and_gradient(times)

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

Returns:

  • Array – Function value.

  • Array – Gradients.

Parameters:

times (Array)

Return type:

tuple[Array, Array] | tuple[float, Array]

measure(times)

Sum of plain weighted measurements.

Returns:

Returns the plain weighted sum.

Return type:

Array

Parameters:

times (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, ideal_invariants=None)
Parameters:
  • propagation (Propagation)

  • ideal_invariants (Array | None)

measure(times)

Measure distance of the propagator to a perfect entangler.

Parameters:

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

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

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.

abstract measure(times)

Measure the observable and returns the value.

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

  • projector (Array | None) – The projector matrix to restrict the operator.

Returns:

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

Return type:

Array or float

class paraqeet.measurement.measurement.NormalizableMeasurement

Bases: Measurement

An abstract class for measurements providing normalized scalar value.

Subclasses must implement the calculate_normalized_scalar() method which would return a measured value between 0 and 1.

abstract calculate_normalized_scalar(times)

Measure the normalized observable.

Returns a single scalar value between 0 and 1. This function must be implemented by subclasses.

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

  • projection (Array | None) – The projector matrix to restrict the operator.

Returns:

Returns a float if implemented by a subclass.

Return type:

float

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)
Parameters:
measure(times)

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.

Parameters:

times (Array)

paraqeet.measurement.rabi_experiment module

Class definition of a Rabi experiment model.

class paraqeet.measurement.rabi_experiment.RabiExperiment

Bases: NormalizableMeasurement, Optimizable

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

calculate_normalized_scalar(times)

Carry out a measurement operation.

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

Note: Returns the measumement value at the last time point.

Returns:

Result of a general Rabi oscillation.

Return type:

Array

Parameters:

times (Array | float)

get_parameters()

Return a list of parameters accessible in this measurement.

Returns:

List of parameters accessible in this measurement.

Return type:

List[Quantity]

measure(times)

Return measurement in the range [0, 1].

Parameters:

times (Array)

Return type:

Array | float

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

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)

calculate_normalized_scalar(times)

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

Parameters:

times (Array | float)

get_value_and_gradient(times)

Measure with gradient.

Compute the measurement value as in measure_normalized_scalar() and the gradient with respect to all parameters in the optimization 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]

Parameters:

times (Array)

measure(times)

Return measurement in the range [0, 1].

Parameters:

times (Array)

Return type:

Array | float

paraqeet.measurement.state_transfer_fidelity module

The class definition of state transfer fidelity model.

class paraqeet.measurement.state_transfer_fidelity.StateTransferFidelity

Bases: NormalizableMeasurement, Differentiable

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

Parameters:
  • propagation (DifferentiablePropagation) – 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)
Parameters:
calculate_normalized_scalar(times)

Measure overlap between initial and target state. To be used with an optimizer.

Parameters:

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

Returns:

Overlap between initial and target state in a bare float.

Return type:

float

get_value_and_gradient(times)

Compute function value and corresponding gradient.

Returns:

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

Return type:

Tuple[Array, Array]

Parameters:

times (Array)

measure(times)

Return measurement in the range [0, 1].

Parameters:

times (Array)

Return type:

Array | float

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)
Parameters:
get_value_and_gradient(times)

Measure with gradient.

Overwrite inherited measure_with_gradient to calculate gradients using AD.

Returns:

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

Return type:

Tuple[float, Array]

Parameters:

times (Array)

class paraqeet.measurement.state_transfer_fidelity.StateTransferFidelityGRAPE

Bases: StateTransferFidelity

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

For GRAPE the optimizable parameters are vector quantities.

Parameters:
  • propagation (DifferentiablePropagation) – 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.

get_value_and_gradient(times)

Compute function value and corresponding gradient.

Returns:

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

Return type:

Tuple[Array, Array]

Parameters:

times (Array)

paraqeet.measurement.unitary_fidelity module

Class definition of the unitary fidelity model.

class paraqeet.measurement.unitary_fidelity.UnitaryFidelity

Bases: NormalizableMeasurement, Differentiable

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, basis_states=None)
Parameters:
calculate_normalized_scalar(times)

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

Parameters:

times (Array | float)

get_value_and_gradient(times)

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]

Parameters:

times (Array)

measure(times)

Return measurement in the range [0, 1].

Parameters:

times (Array)

Return type:

Array | float

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

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:
calculate_normalized_scalar(times)

Sum of weighted measurements from normalized measurements.

Returns:

Returns the normalized weighted sum.

Return type:

Array

Parameters:

times (Array | float)

get_value_and_gradient(times)

Sum of weighted measurements from gradient-ized measurements.

Returns:

  • Array – Returns the weighted sum wrt to gradients.

  • Array – Returns the sum of gradients.

Parameters:

times (Array)

Return type:

tuple[Array, Array] | tuple[float, Array]

measure(times)

Sum of plain weighted measurements.

Returns:

Returns the plain weighted sum.

Return type:

Array

Parameters:

times (Array)

property measurements: list[NormalizableMeasurement]

Returns the list of measurement

property measurements_in_sum_of_squares: list[NormalizableMeasurement]

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.