pygsti.extras.rpe.rpetools

Utility functions for RPE

Module Contents

Functions

extract_rotation_hat(xhat, yhat, k, nx, ny[, ...])

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

estimate_angles(dataset, angle_sin_strs, angle_cos_strs)

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

estimate_thetas(dataset, angle_sin_strs, ...[, ...])

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, ...)

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

xhatfloat

The number of 0 counts for the sin string being used.

yhatfloat

The number of 0 counts for the cos string being used.

kfloat

The generation of experiments that xhat and yhat come from.

nxfloat

The number of sin string clicks.

nyfloat

The number cos string clicks.

angle_name{ “alpha”, “epsilon”, “Phi” }, optional

The angle to be extracted

previous_anglefloat, 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_instDeclares which model configuration RPE should be trying to fit;

determines particular functions and values to be used.

Returns

alpha_jfloat

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

datasetDataSet

The dataset from which the angle estimates will be extracted.

angle_sin_strslist of Circuits

The list of sin strs that the estimator will use.

angle_cos_strslist of Circuits

The list of cos strs that the estimator will use.

angle_name{ “alpha”, “epsilon”, “Phi” }, optional

The angle to be extracted

length_listThe 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_instRPEconfig object

Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

angleHatListlist of floats

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

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

datasetDataSet

The dataset from which the theta estimates will be extracted.

angle_sin_strslist of Circuits

The list of sin strs that the estimator will use.

angle_cos_strslist of Circuits

The list of cos strs that the estimator will use.

epsilon_listlist of floats

List of epsilon estimates.

return_phi_fun_listbool, optional

Set to True to obtain measure of how well Eq. III.7 is satisfied. Default is False.

rpeconfig_instRPEconfig object

Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

thetaHatListlist of floats

A list of theta estimates, ordered by generation (k).

PhiFunListlist 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

modelModel

The model whose angle of rotation about the fixed axis is to be calculated.

rpeconfig_instRPEconfig object

Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

alphaValfloat

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

modelModel

The model whose angle of rotation about the “loose axis” is to be calculated.

rpeconfig_instRPEconfig object

Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

epsilonValfloat

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

modelModel

The model whose loose axis misalignment is to be calculated.

rpeconfig_instRPEconfig object

Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

thetaValfloat

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_datasetDataSet

The dataset containing the RPE experiments.

true_or_target_modelModel

The model used to generate the RPE data OR the target model.

string_list_ddict

The dictionary of operation sequence lists used for the RPE experiments. This should be generated via make_rpe_string_list_d.

rpeconfig_instRPEconfig object

Declares which model configuration RPE should be trying to fit; determines particular functions and values to be used.

Returns

resultsDdict

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.