pygsti.algorithms.core
¶
Core GST algorithms
Module Contents¶
Functions¶

Performs Linearinversion Gate Set Tomography on the dataset. 













Returns the rank and singular values of the Gram matrix for a dataset. 

Performs core Gate Set Tomography function of model optimization. 

Performs core Gate Set Tomography function of model optimization. 

Performs Iterative Gate Set Tomography on the dataset. 

Runs the core modeloptimization step within a GST routine by optimizing 

Runs the core modeloptimization step for models using the 

Find the closest (in fidelity) unitary superoperator to operation_mx. 
Attributes¶
 pygsti.algorithms.core._dummy_profiler¶
 pygsti.algorithms.core.CUSTOMLM = True¶
 pygsti.algorithms.core.FLOATSIZE = 8¶
 pygsti.algorithms.core.run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels=None, op_label_aliases=None, guess_model_for_gauge=None, svd_truncate_to=None, verbosity=0)¶
Performs Linearinversion Gate Set Tomography on the dataset.
 Parameters
dataset (DataSet) – The data used to generate the LGST estimates
prep_fiducials (list of Circuits) – Fiducial Circuits used to construct a informationally complete effective preparation.
effect_fiducials (list of Circuits) – Fiducial Circuits used to construct a informationally complete effective measurement.
target_model (Model) – A model used to specify which operation labels should be estimated, a guess for which gauge these estimates should be returned in.
op_labels (list, optional) – A list of which operation labels (or aliases) should be estimated. Overrides the operation labels in target_model. e.g. [‘Gi’,’Gx’,’Gy’,’Gx2’]
op_label_aliases (dictionary, optional) – Dictionary whose keys are operation label “aliases” and whose values are circuits corresponding to what that operation label should be expanded into before querying the dataset. Defaults to the empty dictionary (no aliases defined) e.g. op_label_aliases[‘Gx^3’] = pygsti.obj.Circuit([‘Gx’,’Gx’,’Gx’])
guess_model_for_gauge (Model, optional) – A model used to compute a gauge transformation that is applied to the LGST estimates before they are returned. This gauge transformation is computed such that if the estimated gates matched the model given, then the operation matrices would match, i.e. the gauge would be the same as the model supplied. Defaults to target_model.
svd_truncate_to (int, optional) – The Hilbert space dimension to truncate the operation matrices to using a SVD to keep only the largest svdToTruncateTo singular values of the I_tildle LGST matrix. Zero means no truncation. Defaults to dimension of target_model.
verbosity (int, optional) – How much detail to send to stdout.
 Returns
Model – A model containing all of the estimated labels (or aliases)
 pygsti.algorithms.core._lgst_matrix_dims(model, prep_fiducials, effect_fiducials)¶
 pygsti.algorithms.core._construct_ab(prep_fiducials, effect_fiducials, model, dataset, op_label_aliases=None)¶
 pygsti.algorithms.core._construct_x_matrix(prep_fiducials, effect_fiducials, model, op_label_tuple, dataset, op_label_aliases=None)¶
 pygsti.algorithms.core._construct_a(effect_fiducials, model)¶
 pygsti.algorithms.core._construct_b(prep_fiducials, model)¶
 pygsti.algorithms.core._construct_target_ab(prep_fiducials, effect_fiducials, target_model)¶
 pygsti.algorithms.core.gram_rank_and_eigenvalues(dataset, prep_fiducials, effect_fiducials, target_model)¶
Returns the rank and singular values of the Gram matrix for a dataset.
 Parameters
dataset (DataSet) – The data used to populate the Gram matrix
prep_fiducials (list of Circuits) – Fiducial Circuits used to construct a informationally complete effective preparation.
effect_fiducials (list of Circuits) – Fiducial Circuits used to construct a informationally complete effective measurement.
target_model (Model) – A model used to make sense of circuit elements, and to compute the theoretical gram matrix eigenvalues (returned as svalues_target).
 Returns
rank (int) – the rank of the Gram matrix
svalues (numpy array) – the singular values of the Gram matrix
svalues_target (numpy array) – the corresponding singular values of the Gram matrix generated by target_model.
 pygsti.algorithms.core.run_gst_fit_simple(dataset, start_model, circuits, optimizer, objective_function_builder, resource_alloc, verbosity=0)¶
Performs core Gate Set Tomography function of model optimization.
Optimizes the parameters of start_model by minimizing the objective function built by objective_function_builder. Probabilities are computed by the model, and outcome counts are supplied by dataset.
 Parameters
dataset (DataSet) – The dataset to obtain counts from.
start_model (Model) – The Model used as a starting point for the leastsquares optimization.
circuits (list of (tuples or Circuits)) – Each tuple contains operation labels and specifies a circuit whose probabilities are considered when trying to leastsquaresfit the probabilities given in the dataset. e.g. [ (), (‘Gx’,), (‘Gx’,’Gy’) ]
optimizer (Optimizer or dict) – The optimizer to use, or a dictionary of optimizer parameters from which a default optimizer can be built.
objective_function_builder (ObjectiveFunctionBuilder) – Defines the objective function that is optimized. Can also be anything readily converted to an objective function builder, e.g. “logl”.
resource_alloc (ResourceAllocation) – A resource allocation object containing information about how to divide computation amongst multiple processors and any memory limits that should be imposed.
verbosity (int, optional) – How much detail to send to stdout.
 Returns
result (OptimizerResult) – the result of the optimization
model (Model) – the bestfit model.
 pygsti.algorithms.core.run_gst_fit(mdc_store, optimizer, objective_function_builder, verbosity=0)¶
Performs core Gate Set Tomography function of model optimization.
Optimizes the model to the data within mdc_store by minimizing the objective function built by objective_function_builder.
 Parameters
mdc_store (ModelDatasetCircuitsStore) – An object holding a model, data set, and set of circuits. This defines the model to be optimized, the data to fit to, and the circuits where predicted vs. observed comparisons should be made. This object also contains additional information specific to the given model, data set, and circuit list, doubling as a cache for increased performance. This information is also specific to a particular resource allocation, which affects how cached values stored.
optimizer (Optimizer or dict) – The optimizer to use, or a dictionary of optimizer parameters from which a default optimizer can be built.
objective_function_builder (ObjectiveFunctionBuilder) – Defines the objective function that is optimized. Can also be anything readily converted to an objective function builder, e.g. “logl”. If None, then mdc_store must itself be an alreadybuilt objective function.
verbosity (int, optional) – How much detail to send to stdout.
 Returns
result (OptimizerResult) – the result of the optimization
objfn_store (MDCObjectiveFunction) – the objective function and store containing the bestfit model evaluated at the bestfit point.
 pygsti.algorithms.core.run_iterative_gst(dataset, start_model, circuit_lists, optimizer, iteration_objfn_builders, final_objfn_builders, resource_alloc, verbosity=0)¶
Performs Iterative Gate Set Tomography on the dataset.
 Parameters
dataset (DataSet) – The data used to generate MLGST gate estimates
start_model (Model) – The Model used as a starting point for the leastsquares optimization.
circuit_lists (list of lists of (tuples or Circuits)) – The ith element is a list of the circuits to be used in the ith iteration of the optimization. Each element of these lists is a circuit, specifed as either a Circuit object or as a tuple of operation labels (but all must be specified using the same type). e.g. [ [ (), (‘Gx’,) ], [ (), (‘Gx’,), (‘Gy’,) ], [ (), (‘Gx’,), (‘Gy’,), (‘Gx’,’Gy’) ] ]
optimizer (Optimizer or dict) – The optimizer to use, or a dictionary of optimizer parameters from which a default optimizer can be built.
iteration_objfn_builders (list) – List of ObjectiveFunctionBuilder objects defining which objective functions should be optimizized (successively) on each iteration.
final_objfn_builders (list) – List of ObjectiveFunctionBuilder objects defining which objective functions should be optimizized (successively) on the final iteration.
resource_alloc (ResourceAllocation) – A resource allocation object containing information about how to divide computation amongst multiple processors and any memory limits that should be imposed.
verbosity (int, optional) – How much detail to send to stdout.
 Returns
models (list of Models) – list whose ith element is the model corresponding to the results of the ith iteration.
optimums (list of OptimizerResults) – list whose ith element is the final optimizer result from that iteration.
final_objfn (MDSObjectiveFunction) – The final iteration’s objective function / store, which encapsulated the final objective function evaluated at the bestfit point (an “evaluated” modeldataSetcircuits store).
 pygsti.algorithms.core._do_runopt(objective, optimizer, printer)¶
Runs the core modeloptimization step within a GST routine by optimizing objective using optimizer.
This is factored out as a separate function because of the differences when running Taylorterm simtype calculations, which utilize this as a subroutine (see :function:`_do_term_runopt`).
 Parameters
objective (MDSObjectiveFunction) – A “modeldataset” objective function to optimize.
optimizer (Optimizer) – The optimizer to use.
printer (VerbosityPrinter) – An object for printing output.
 Returns
OptimizerResult
 pygsti.algorithms.core._do_term_runopt(objective, optimizer, printer)¶
Runs the core modeloptimization step for models using the Taylorterm (path integral) method of computing probabilities.
This routine serves the same purpose as :function:`_do_runopt`, but is more complex because an appropriate “path set” must be found, requiring a loop of model optimizations with fixed path sets until a sufficient “good” path set is obtained.
 Parameters
objective (MDSObjectiveFunction) – A “modeldataset” objective function to optimize.
optimizer (Optimizer) – The optimizer to use.
printer (VerbosityPrinter) – An object for printing output.
 Returns
OptimizerResult
 pygsti.algorithms.core.find_closest_unitary_opmx(operation_mx)¶
Find the closest (in fidelity) unitary superoperator to operation_mx.
Finds the closest operation matrix (by maximizing fidelity) to operation_mx that describes a unitary quantum gate.
 Parameters
operation_mx (numpy array) – The operation matrix to act on.
 Returns
numpy array – The resulting closest unitary operation matrix.