pygsti.algorithms.core
Core GST algorithms
Module Contents
Functions
|
Performs Linear-inversion 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. |
|
Performs Iterative Gate Set Tomography on the dataset. |
|
Find the closest (in fidelity) unitary superoperator to operation_mx. |
Attributes
- 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, check=True)
Performs Linear-inversion Gate Set Tomography on the dataset.
Parameters
- datasetDataSet
The data used to generate the LGST estimates
- prep_fiducialslist of Circuits
Fiducial Circuits used to construct a informationally complete effective preparation.
- effect_fiducialslist of Circuits
Fiducial Circuits used to construct a informationally complete effective measurement.
- target_modelModel
A model used to specify which operation labels should be estimated, a guess for which gauge these estimates should be returned in.
- op_labelslist, 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_aliasesdictionary, 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.baseobjs.Circuit([‘Gx’,’Gx’,’Gx’])
- guess_model_for_gaugeModel, 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_toint, 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.
- verbosityint, optional
How much detail to send to stdout.
- checkbool, optional
Specifies whether we perform computationally expensive assertion checks. Computationally cheap assertions will always be checked.
Returns
- Model
A model containing all of the estimated labels (or aliases)
- 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
- datasetDataSet
The data used to populate the Gram matrix
- prep_fiducialslist of Circuits
Fiducial Circuits used to construct a informationally complete effective preparation.
- effect_fiducialslist of Circuits
Fiducial Circuits used to construct a informationally complete effective measurement.
- target_modelModel
A model used to make sense of circuit elements, and to compute the theoretical gram matrix eigenvalues (returned as svalues_target).
Returns
- rankint
the rank of the Gram matrix
- svaluesnumpy array
the singular values of the Gram matrix
- svalues_targetnumpy 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
- datasetDataSet
The dataset to obtain counts from.
- start_modelModel
The Model used as a starting point for the least-squares optimization.
- circuitslist of (tuples or Circuits)
Each tuple contains operation labels and specifies a circuit whose probabilities are considered when trying to least-squares-fit the probabilities given in the dataset. e.g. [ (), (‘Gx’,), (‘Gx’,’Gy’) ]
- optimizerOptimizer or dict
The optimizer to use, or a dictionary of optimizer parameters from which a default optimizer can be built.
- objective_function_builderObjectiveFunctionBuilder
Defines the objective function that is optimized. Can also be anything readily converted to an objective function builder, e.g. “logl”.
- resource_allocResourceAllocation
A resource allocation object containing information about how to divide computation amongst multiple processors and any memory limits that should be imposed.
- verbosityint, optional
How much detail to send to stdout.
Returns
- resultOptimizerResult
the result of the optimization
- modelModel
the best-fit 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_storeModelDatasetCircuitsStore
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.
- optimizerOptimizer or dict
The optimizer to use, or a dictionary of optimizer parameters from which a default optimizer can be built.
- objective_function_builderObjectiveFunctionBuilder
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 already-built objective function.
- verbosityint, optional
How much detail to send to stdout.
Returns
- resultOptimizerResult
the result of the optimization
- objfn_storeMDCObjectiveFunction
the objective function and store containing the best-fit model evaluated at the best-fit 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
- datasetDataSet
The data used to generate MLGST gate estimates
- start_modelModel
The Model used as a starting point for the least-squares optimization.
- circuit_listslist of lists of (tuples or Circuits)
The i-th element is a list of the circuits to be used in the i-th 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’) ] ]
- optimizerOptimizer or dict
The optimizer to use, or a dictionary of optimizer parameters from which a default optimizer can be built.
- iteration_objfn_builderslist
List of ObjectiveFunctionBuilder objects defining which objective functions should be optimizized (successively) on each iteration.
- final_objfn_builderslist
List of ObjectiveFunctionBuilder objects defining which objective functions should be optimizized (successively) on the final iteration.
- resource_allocResourceAllocation
A resource allocation object containing information about how to divide computation amongst multiple processors and any memory limits that should be imposed.
- verbosityint, optional
How much detail to send to stdout.
Returns
- modelslist of Models
list whose i-th element is the model corresponding to the results of the i-th iteration.
- optimumslist of OptimizerResults
list whose i-th element is the final optimizer result from that iteration.
- final_objfnMDSObjectiveFunction
The final iteration’s objective function / store, which encapsulated the final objective function evaluated at the best-fit point (an “evaluated” model-dataSet-circuits store).
- pygsti.algorithms.core.iterative_gst_generator(dataset, start_model, circuit_lists, optimizer, iteration_objfn_builders, final_objfn_builders, resource_alloc, starting_index=0, verbosity=0)
Performs Iterative Gate Set Tomography on the dataset. Same as run_iterative_gst, except this function produces a generator for producing the output for each iteration instead of returning the lists of outputs all at once.
Parameters
- datasetDataSet
The data used to generate MLGST gate estimates
- start_modelModel
The Model used as a starting point for the least-squares optimization.
- circuit_listslist of lists of (tuples or Circuits)
The i-th element is a list of the circuits to be used in the i-th 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’) ] ]
- optimizerOptimizer or dict
The optimizer to use, or a dictionary of optimizer parameters from which a default optimizer can be built.
- iteration_objfn_builderslist
List of ObjectiveFunctionBuilder objects defining which objective functions should be optimizized (successively) on each iteration.
- final_objfn_builderslist
List of ObjectiveFunctionBuilder objects defining which objective functions should be optimizized (successively) on the final iteration.
- resource_allocResourceAllocation
A resource allocation object containing information about how to divide computation amongst multiple processors and any memory limits that should be imposed.
- starting_indexint, optional (default 0)
Index of the iteration to start the optimization at. Primarily used when warmstarting the iterative optimization from a checkpoint.
- verbosityint, optional
How much detail to send to stdout.
Returns
- generator
Returns a generator which when queried the i-th time returns a tuple containing:
model: the model corresponding to the results of the i-th iteration.
optimums : the final OptimizerResults from the i-th iteration.
final_objfn : If the final iteration the MDSObjectiveFunction function / store, which encapsulated the final objective function evaluated at the best-fit point (an “evaluated” model-dataset-circuits store).
- 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_mxnumpy array
The operation matrix to act on.
Returns
- numpy array
The resulting closest unitary operation matrix.