pygsti.extras.rpe.rpetools

Utility functions for RPE

Module Contents

Functions

extract_rotation_hat(xhat, yhat, k, nx, ny, angle_name='epsilon', previous_angle=None, rpeconfig_inst=None)

For a single germ generation (k value), estimate the angle of rotation

estimate_angles(dataset, angle_sin_strs, angle_cos_strs, angle_name='epsilon', length_list=None, rpeconfig_inst=None)

For a dataset containing sin and cos strings to estimate either alpha,

_sin_phi2(theta, phi, epsilon, rpeconfig_inst=None)

Returns the function whose zero, for fixed phi and epsilon, occurs at the

estimate_thetas(dataset, angle_sin_strs, angle_cos_strs, epsilon_list, return_phi_fun_list=False, rpeconfig_inst=None)

For a dataset containing sin and cos strings to estimate theta,

extract_alpha(model, rpeconfig_inst)

For a given model, obtain the angle of rotation about the "fixed axis"

extract_epsilon(model, rpeconfig_inst)

For a given model, obtain the angle of rotation about the "loose axis"

extract_theta(model, rpeconfig_inst)

For a given model, obtain the angle between the estimated "loose axis" and

consistency_check(angle_k, angle_final, k)

Check internal consistency

analyze_rpe_data(input_dataset, true_or_target_model, string_list_d, rpeconfig_inst, do_consistency_check=False, k_list=None)

Compute angle estimates and compare to true or target values for alpha, epsilon,

pygsti.extras.rpe.rpetools.extract_rotation_hat(xhat, yhat, k, nx, ny, angle_name='epsilon', previous_angle=None, rpeconfig_inst=None)

For a single germ generation (k value), estimate the angle of rotation for either alpha, epsilon, or Phi. (Warning: Do not use for theta estimate without further processing!)

Parameters
  • xhat (float) – The number of 0 counts for the sin string being used.

  • yhat (float) – The number of 0 counts for the cos string being used.

  • k (float) – The generation of experiments that xhat and yhat come from.

  • nx (float) – The number of sin string clicks.

  • ny (float) – The number cos string clicks.

  • angle_name ({ "alpha", "epsilon", "Phi" }, optional) – The angle to be extracted

  • previous_angle (float, optional) – Angle estimate from previous generation; used to refine this generation’s estimate. Default is None (for estimation with no previous genereation’s data)

  • rpeconfig_inst (Declares which model configuration RPE should be trying to fit;) – determines particular functions and values to be used.

Returns

alpha_j (float) – The current angle estimate.

pygsti.extras.rpe.rpetools.estimate_angles(dataset, angle_sin_strs, angle_cos_strs, angle_name='epsilon', length_list=None, rpeconfig_inst=None)

For a dataset containing sin and cos strings to estimate either alpha, epsilon, or Phi return a list of alpha, epsilon, or Phi estimates (one for each generation). Note: this assumes the dataset contains ‘0’ and ‘1’ SPAM labels.

Parameters
  • dataset (DataSet) – The dataset from which the angle estimates will be extracted.

  • angle_sin_strs (list of Circuits) – The list of sin strs that the estimator will use.

  • angle_cos_strs (list of Circuits) – The list of cos strs that the estimator will use.

  • angle_name ({ "alpha", "epsilon", "Phi" }, optional) – The angle to be extracted

  • length_list (The list of sequence lengths. Default is None;) – If None is specified, then length_list becomes [1,2,4,…,2**(len(angle_sin_strs)-1)]

  • rpeconfig_inst (RPEconfig object) – Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

angleHatList (list of floats) – A list of angle estimates, ordered by generation (k).

pygsti.extras.rpe.rpetools._sin_phi2(theta, phi, epsilon, rpeconfig_inst=None)

Returns the function whose zero, for fixed phi and epsilon, occurs at the desired value of theta. (This function exists to be passed to a minimizer to obtain theta.)

Parameters
  • theta (float) – Angle between estimated “loose axis” and target “loose axis”.

  • phi (float) – The auxiliary angle phi; necessary to calculate theta.

  • epsilon (float) – Angle of rotation about “loose axis”.

Returns

sinPhi2FuncVal – The value of _sin_phi2 for given inputs. (Must be 0 to achieve “true” theta.)

pygsti.extras.rpe.rpetools.estimate_thetas(dataset, angle_sin_strs, angle_cos_strs, epsilon_list, return_phi_fun_list=False, rpeconfig_inst=None)

For a dataset containing sin and cos strings to estimate theta, along with already-made estimates of epsilon, return a list of theta (one for each generation).

Parameters
  • dataset (DataSet) – The dataset from which the theta estimates will be extracted.

  • angle_sin_strs (list of Circuits) – The list of sin strs that the estimator will use.

  • angle_cos_strs (list of Circuits) – The list of cos strs that the estimator will use.

  • epsilon_list (list of floats) – List of epsilon estimates.

  • return_phi_fun_list (bool, optional) – Set to True to obtain measure of how well Eq. III.7 is satisfied. Default is False.

  • rpeconfig_inst (RPEconfig object) – Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

  • thetaHatList (list of floats) – A list of theta estimates, ordered by generation (k).

  • PhiFunList (list of floats) – A list of _sin_phi2 vals at optimal theta values. If not close to 0, constraints unsatisfiable. Only returned if return_phi_fun_list is set to True.

pygsti.extras.rpe.rpetools.extract_alpha(model, rpeconfig_inst)

For a given model, obtain the angle of rotation about the “fixed axis”

WARNING: This is a gauge-covariant parameter! Gauge must be fixed prior to estimating.

Parameters
  • model (Model) – The model whose angle of rotation about the fixed axis is to be calculated.

  • rpeconfig_inst (RPEconfig object) – Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

alphaVal (float) – The value of alpha for the input model.

pygsti.extras.rpe.rpetools.extract_epsilon(model, rpeconfig_inst)

For a given model, obtain the angle of rotation about the “loose axis”

WARNING: This is a gauge-covariant parameter! Gauge must be fixed prior to estimating.

Parameters
  • model (Model) – The model whose angle of rotation about the “loose axis” is to be calculated.

  • rpeconfig_inst (RPEconfig object) – Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

epsilonVal (float) – The value of epsilon for the input model.

pygsti.extras.rpe.rpetools.extract_theta(model, rpeconfig_inst)

For a given model, obtain the angle between the estimated “loose axis” and the target “loose axis”.

WARNING: This is a gauge-covariant parameter! (I think!) Gauge must be fixed prior to estimating.

Parameters
  • model (Model) – The model whose loose axis misalignment is to be calculated.

  • rpeconfig_inst (RPEconfig object) – Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

thetaVal (float) – The value of theta for the input model.

pygsti.extras.rpe.rpetools.consistency_check(angle_k, angle_final, k)

Check internal consistency

pygsti.extras.rpe.rpetools.analyze_rpe_data(input_dataset, true_or_target_model, string_list_d, rpeconfig_inst, do_consistency_check=False, k_list=None)

Compute angle estimates and compare to true or target values for alpha, epsilon, and theta. (“True” will typically be used for simulated data, when the true angle values are known a priori; “target” will typically be used for experimental data, where we do not know the true angle values, and can only compare to our desired angles.)

Parameters
  • input_dataset (DataSet) – The dataset containing the RPE experiments.

  • true_or_target_model (Model) – The model used to generate the RPE data OR the target model.

  • string_list_d (dict) – The dictionary of operation sequence lists used for the RPE experiments. This should be generated via make_rpe_string_list_d.

  • rpeconfig_inst (RPEconfig object) – Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

resultsD (dict) – A dictionary of the results The keys of the dictionary are:

-‘alphaHatList’ : List (ordered by k) of alpha estimates. -‘epsilonHatList’ : List (ordered by k) of epsilon estimates. -‘thetaHatList’ : List (ordered by k) of theta estimates. -‘alphaErrorList’ : List (ordered by k) of difference between true

alpha and RPE estimate of alpha.

-‘epsilonErrorList’List (ordered by k) of difference between true

epsilon and RPE estimate of epsilon.

-‘thetaErrorList’List (ordered by k) of difference between true

theta and RPE estimate of theta.

-‘PhiFunErrorList’ : List (ordered by k) of _sin_phi2 values.