pygsti.algorithms.fiducialpairreduction
¶
Functions for reducing the number of required fiducial pairs for analysis.
Module Contents¶
Functions¶

Number of combinations of r items out of a set of n. Equals n!/(r!(nr)!) 

Random selection from itertools.combinations(indices_tuple, r) 

Finds a (global) set of fiducial pairs that are amplificationally complete. 

Finds a pergerm set of fiducial pairs that are amplificationally complete. 

Finds a pergerm set of fiducial pairs that are amplificationally complete. 

Tests a set of global or pergerm fiducial pairs. 

 pygsti.algorithms.fiducialpairreduction._nCr(n, r)¶
Number of combinations of r items out of a set of n. Equals n!/(r!(nr)!)
 pygsti.algorithms.fiducialpairreduction._random_combination(indices_tuple, r)¶
 Random selection from itertools.combinations(indices_tuple, r)
from http://docs.python.org/2/library/itertools.html#recipes
 pygsti.algorithms.fiducialpairreduction.find_sufficient_fiducial_pairs(target_model, prep_fiducials, meas_fiducials, germs, test_lengths=(256, 2048), prep_povm_tuples='first', tol=0.75, search_mode='sequential', n_random=100, seed=None, verbosity=0, test_pair_list=None, mem_limit=None, minimum_pairs=1)¶
Finds a (global) set of fiducial pairs that are amplificationally complete.
A “standard” set of GST circuits consists of all circuits of the form:
statePrep + prepFiducial + germPower + measureFiducial + measurement
This set is typically overcomplete, and it is possible to restrict the (prepFiducial, measureFiducial) pairs to a subset of all the possible pairs given the separate prep_fiducials and meas_fiducials lists. This function attempts to find a set of fiducial pairs that still amplify all of the model’s parameters (i.e. is “amplificationally complete”). The test for amplification is performed using the two germpower lengths given by test_lengths, and tests whether the magnitudes of the Jacobian’s singular values scale linearly with the germpower length.
In the special case when test_pair_list is not None, the function tests the given set of fiducial pairs for amplificational completeness, and does not perform any search.
 Parameters
target_model (Model) – The target model used to determine amplificational completeness.
prep_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective preparation.
meas_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective measurement.
germs (list of Circuits) – The germ circuits that are repeated to amplify errors.
test_lengths ((L1,L2) tuple of ints, optional) – A tuple of integers specifying the germpower lengths to use when checking for amplificational completeness.
prep_povm_tuples (list or "first", optional) – A list of (prepLabel, povmLabel) tuples to consider when checking for completeness. Usually this should be left as the special (and default) value “first”, which considers the first prep and POVM contained in target_model.
tol (float, optional) – The tolerance for the fraction of the expected amplification that must be observed to call a parameter “amplified”.
search_mode ({"sequential","random"}, optional) – If “sequential”, then all potential fiducial pair sets of a given length are considered in sequence before moving to sets of a larger size. This can take a long time when there are many possible fiducial pairs. If “random”, then only n_random randomly chosen fiducial pair sets are considered for each set size before the set is enlarged.
n_random (int, optional) – The number of randompairsets to consider for a given set size.
seed (int, optional) – The seed to use for generating randompairsets.
verbosity (int, optional) – How much detail to print to stdout.
test_pair_list (list or None, optional) – If not None, a list of (prepfid_index,measfid_index) tuples of integers, specifying a list of fiducial pairs (indices are into prep_fiducials and meas_fiducials, respectively). These pairs are then tested for amplificational completeness and the number of amplified parameters is printed to stdout. (This is a special debugging functionality.)
mem_limit (int, optional) – A memory limit in bytes.
minimum_pairs (int, optional) – The minimium number of fiducial pairs to try (default == 1). Set this to integers larger than 1 to avoid trying pair sets that are known to be too small.
 Returns
list – A list of (prepfid_index,measfid_index) tuples of integers, specifying a list of fiducial pairs (indices are into prep_fiducials and meas_fiducials).
 pygsti.algorithms.fiducialpairreduction.find_sufficient_fiducial_pairs_per_germ(target_model, prep_fiducials, meas_fiducials, germs, pre_povm_tuples='first', search_mode='sequential', constrain_to_tp=True, n_random=100, seed=None, verbosity=0, mem_limit=None)¶
Finds a pergerm set of fiducial pairs that are amplificationally complete.
A “standard” set of GST circuits consists of all circuits of the form:
statePrep + prepFiducial + germPower + measureFiducial + measurement
This set is typically overcomplete, and it is possible to restrict the (prepFiducial, measureFiducial) pairs to a subset of all the possible pairs given the separate prep_fiducials and meas_fiducials lists. This function attempts to find sets of fiducial pairs, one set per germ, that still amplify all of the model’s parameters (i.e. is “amplificationally complete”). For each germ, a fiducial pair set is found that amplifies all of the “parameters” (really linear combinations of them) that the particular germ amplifies.
To test whether a set of fiducial pairs satisfies this condition, the sum of projectors P_i = dot(J_i,J_i^T), where J_i is a matrix of the derivatives of each of the selected (prepFiducial+germ+effectFiducial) sequence probabilities with respect to the ith germ eigenvalue (or more generally, amplified parameter), is computed. If the fiducialpair set is sufficient, the rank of the resulting sum (an operator) will be equal to the total (maximal) number of parameters the germ can amplify.
 Parameters
target_model (Model) – The target model used to determine amplificational completeness.
prep_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective preparation.
meas_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective measurement.
germs (list of Circuits) – The germ circuits that are repeated to amplify errors.
pre_povm_tuples (list or "first", optional) – A list of (prepLabel, povmLabel) tuples to consider when checking for completeness. Usually this should be left as the special (and default) value “first”, which considers the first prep and POVM contained in target_model.
search_mode ({"sequential","random"}, optional) – If “sequential”, then all potential fiducial pair sets of a given length are considered in sequence (per germ) before moving to sets of a larger size. This can take a long time when there are many possible fiducial pairs. If “random”, then only n_random randomly chosen fiducial pair sets are considered for each set size before the set is enlarged.
constrain_to_tp (bool, optional) – Whether or not to consider nonTP parameters the the germs amplify. If the fiducal pairs will be used in a GST estimation where the model is constrained to being tracepreserving (TP), this should be set to True.
n_random (int, optional) – The number of randompairsets to consider for a given set size.
seed (int, optional) – The seed to use for generating randompairsets.
verbosity (int, optional) – How much detail to print to stdout.
mem_limit (int, optional) – A memory limit in bytes.
 Returns
dict – A dictionary whose keys are the germ circuits and whose values are lists of (iRhoFid,iMeasFid) tuples of integers, each specifying the list of fiducial pairs for a particular germ (indices are into prep_fiducials and meas_fiducials).
 pygsti.algorithms.fiducialpairreduction.find_sufficient_fiducial_pairs_per_germ_power(target_model, prep_fiducials, meas_fiducials, germs, max_lengths, pre_povm_tuples='first', search_mode='sequential', constrain_to_tp=True, n_random=100, seed=None, verbosity=0, mem_limit=None)¶
Finds a pergerm set of fiducial pairs that are amplificationally complete.
A “standard” set of GST circuits consists of all circuits of the form:
statePrep + prepFiducial + germPower + measureFiducial + measurement
This set is typically overcomplete, and it is possible to restrict the (prepFiducial, measureFiducial) pairs to a subset of all the possible pairs given the separate prep_fiducials and meas_fiducials lists. This function attempts to find sets of fiducial pairs, one set per germ, that still amplify all of the model’s parameters (i.e. is “amplificationally complete”). For each germ, a fiducial pair set is found that amplifies all of the “parameters” (really linear combinations of them) that the particular germ amplifies.
To test whether a set of fiducial pairs satisfies this condition, the sum of projectors P_i = dot(J_i,J_i^T), where J_i is a matrix of the derivatives of each of the selected (prepFiducial+germ+effectFiducial) sequence probabilities with respect to the ith germ eigenvalue (or more generally, amplified parameter), is computed. If the fiducialpair set is sufficient, the rank of the resulting sum (an operator) will be equal to the total (maximal) number of parameters the germ can amplify.
 Parameters
target_model (Model) – The target model used to determine amplificational completeness.
prep_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective preparation.
meas_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective measurement.
germs (list of Circuits) – The germ circuits that are repeated to amplify errors.
max_lengths (list of int) – The germ powers (number of repetitions) to be used to amplify errors.
pre_povm_tuples (list or "first", optional) – A list of (prepLabel, povmLabel) tuples to consider when checking for completeness. Usually this should be left as the special (and default) value “first”, which considers the first prep and POVM contained in target_model.
search_mode ({"sequential","random"}, optional) – If “sequential”, then all potential fiducial pair sets of a given length are considered in sequence (per germ) before moving to sets of a larger size. This can take a long time when there are many possible fiducial pairs. If “random”, then only n_random randomly chosen fiducial pair sets are considered for each set size before the set is enlarged.
constrain_to_tp (bool, optional) – Whether or not to consider nonTP parameters the the germs amplify. If the fiducal pairs will be used in a GST estimation where the model is constrained to being tracepreserving (TP), this should be set to True.
n_random (int, optional) – The number of randompairsets to consider for a given set size.
seed (int, optional) – The seed to use for generating randompairsets.
verbosity (int, optional) – How much detail to print to stdout.
mem_limit (int, optional) – A memory limit in bytes.
 Returns
dict – A dictionary whose keys are the germ circuits and whose values are lists of (iRhoFid,iMeasFid) tuples of integers, each specifying the list of fiducial pairs for a particular germ (indices are into prep_fiducials and meas_fiducials).
 pygsti.algorithms.fiducialpairreduction.test_fiducial_pairs(fid_pairs, target_model, prep_fiducials, meas_fiducials, germs, test_lengths=(256, 2048), pre_povm_tuples='first', tol=0.75, verbosity=0, mem_limit=None)¶
Tests a set of global or pergerm fiducial pairs.
Determines how many model parameters (of target_model) are amplified by the fiducial pairs given by fid_pairs, which can be either a list of 2tuples (for globalFPR) or a dictionary (for pergerm FPR).
 Parameters
fid_pairs (list or dict) – Either a single list of fiducialindex pairs (2tuples) that is applied to every germ (global FPR) OR a pergerm dictionary of lists, each containing the fiducialindex pairs (2tuples) for that germ (for pergerm FPR).
target_model (Model) – The target model used to determine amplificational completeness.
prep_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective preparation.
meas_fiducials (list of Circuits) – Fiducial circuits used to construct an informationally complete effective measurement.
germs (list of Circuits) – The germ circuits that are repeated to amplify errors.
test_lengths ((L1,L2) tuple of ints, optional) – A tuple of integers specifying the germpower lengths to use when checking for amplificational completeness.
pre_povm_tuples (list or "first", optional) – A list of (prepLabel, povmLabel) tuples to consider when checking for completeness. Usually this should be left as the special (and default) value “first”, which considers the first prep and POVM contained in target_model.
tol (float, optional) – The tolerance for the fraction of the expected amplification that must be observed to call a parameter “amplified”.
verbosity (int, optional) – How much detail to print to stdout.
mem_limit (int, optional) – A memory limit in bytes.
 Returns
numAmplified (int)
 pygsti.algorithms.fiducialpairreduction._get_per_germ_fidpairs(prep_fiducials, meas_fiducials, pre_povm_tuples, gsGerm, mem_limit, printer, search_mode, seed, n_random)¶