#***************************************************************** # pyGSTi 0.9: Copyright 2015 Sandia Corporation # This Software is released under the GPL license detailed # in the file "license.txt" in the top-level pyGSTi directory #***************************************************************** """ Variables for working with the a gate set containing X(pi/2) and Y(pi/2) gates. """ import gatestringconstruction as _strc import gatesetconstruction as _setc description = "X(pi/2) and Y(pi/2) gates" gates = ['Gx','Gy'] fiducials = _strc.gatestring_list( [ (), ('Gx',), ('Gy',), ('Gx','Gx'), ('Gx','Gx','Gx'), ('Gy','Gy','Gy') ] ) # for 1Q MUB germs = _strc.gatestring_list([('Gy',), ('Gy','Gy','Gy','Gx',), ('Gy','Gx','Gy','Gx','Gx','Gx',), ('Gy','Gx','Gy','Gy','Gx','Gx',), ('Gy','Gy','Gy','Gx','Gy','Gx',), ('Gx',), ('Gx','Gy',), ('Gx','Gx','Gy','Gx','Gy','Gy',)]) #Construct a target gateset: X(pi/2), Y(pi/2) gs_target = _setc.build_gateset([2],[('Q0',)], ['Gx','Gy'], [ "X(pi/2,Q0)", "Y(pi/2,Q0)"], prepLabels=["rho0"], prepExpressions=["0"], effectLabels=["E0"], effectExpressions=["1"],
# This Software is released under the GPL license detailed # in the file "license.txt" in the top-level pyGSTi directory #***************************************************************** """ Variables for working with the a gate set containing X(pi/2) and Z(pi/2) gates. """ import gatestringconstruction as _strc import gatesetconstruction as _setc description = "X(pi/2) and Z(pi/2) gates" gates = ['Gx','Gz'] prepFiducials = _strc.gatestring_list([(), ('Gx',), ('Gx','Gz'), ('Gx','Gx'), ('Gx','Gx','Gx'), ('Gx','Gz','Gx','Gx')]) # for 1Q MUB measFiducials = _strc.gatestring_list([(), ('Gx',), ('Gz','Gx'), ('Gx','Gx'), ('Gx','Gx','Gx'), ('Gx','Gx','Gz','Gx')]) germs = _strc.gatestring_list( [('Gx',), ('Gz',), ('Gz','Gx','Gx'), ('Gz','Gz','Gx')] ) #Construct a target gateset: X(pi/2), Z(pi/2) gs_target = _setc.build_gateset([2],[('Q0',)], ['Gx','Gz'], [ "X(pi/2,Q0)", "Z(pi/2,Q0)"],
def make_elgst_lists(gateLabels, germList, maxLengthList, truncScheme="whole germ powers", nest=True): """ Create a set of gate string lists for eLGST based on germs and max-lengths Constructs a series (a list) of gate string lists used by the extended LGST (eLGST) algorithm. If maxLengthList[0] == 0 then the starting list is the list of length-1 gate label strings, otherwise the starting list is empty. For each nonzero element of maxLengthList, call it L, a list of gate strings is created with the form: Case: truncScheme == 'whole germ powers': pygsti.construction.repeat_with_max_length(germ,L) Case: truncScheme == 'truncated germ powers': pygsti.construction.repeat_and_truncate(germ,L) Case: truncScheme == 'length as exponent': germ^L If nest == True, the above list is iteratively *added* (w/duplicates removed) to the current list of gate strings to form a final list for the given L. This results in successively larger lists, each of which contains all the elements of previous-L lists. If nest == False then the above list *is* the final list for the given L. Parameters ---------- gateLabels : list or tuple List of gate labels. Only relevant when maxLengthList[0] == 0. germList : list of GateStrings List of the germ gate strings. maxLengthList : list of ints List of the maximum lengths. If maxLengthList[0] == 0 this results in special behavior where the length-1 gate label strings are included as the first returned list. truncScheme : str, optional Truncation scheme used to interpret what the list of maximum lengths means. If unsure, leave as default. Allowed values are: - 'whole germ powers' -- germs are repeated an integer number of times such that the length is less than or equal to the max. - 'truncated germ powers' -- repeated germ string is truncated to be exactly equal to the max (partial germ at end is ok). - 'length as exponent' -- max. length is instead interpreted as the germ exponent (the number of germ repetitions). nest : boolean, optional If Frue, the returned gate string lists are "nested", meaning that each successive list of gate strings contains all the gate strings found in previous lists (and usually some additional new ones). If False, then the returned string list for maximum length == L contains *only* those gate strings specified in the description above, and *not* those for previous values of L. Returns ------- list of (lists of GateStrings) The i-th list corresponds to a gate string list containing repeated germs limited to length maxLengthList[i]. If nest == True, then repeated germs limited to previous max-lengths are also included. Note that a "0" maximum-length corresponds to the gate label strings. """ singleGates = _gsc.gatestring_list([(g,) for g in gateLabels]) elgst_list = _gsc.gatestring_list([ () ]) #running list of all strings so far if maxLengthList[0] == 0: elgst_listOfLists = [ singleGates ] maxLengthList = maxLengthList[1:] else: elgst_listOfLists = [ ] Rfn = _getTruncFunction(truncScheme) for maxLen in maxLengthList: lst = _gsc.create_gatestring_list("R(germ,N)", germ=germList, N=maxLen, R=Rfn) if nest: elgst_list += lst #add new strings to running list elgst_listOfLists.append( _lt.remove_duplicates(singleGates + elgst_list) ) else: elgst_listOfLists.append( _lt.remove_duplicates(lst) ) #print "%d eLGST sets w/lengths" % len(elgst_listOfLists),map(len,elgst_listOfLists) return elgst_listOfLists
# pyGSTi 0.9: Copyright 2015 Sandia Corporation # This Software is released under the GPL license detailed # in the file "license.txt" in the top-level pyGSTi directory #***************************************************************** """ Variables for working with the a gate set containing X(pi/2) and Z(pi/2) gates. """ import gatestringconstruction as _strc import gatesetconstruction as _setc description = "X(pi/2) and Z(pi/2) gates" gates = ['Gx', 'Gz'] prepFiducials = _strc.gatestring_list([(), ('Gx', ), ('Gx', 'Gz'), ('Gx', 'Gx'), ('Gx', 'Gx', 'Gx'), ('Gx', 'Gz', 'Gx', 'Gx')]) # for 1Q MUB measFiducials = _strc.gatestring_list([(), ('Gx', ), ('Gz', 'Gx'), ('Gx', 'Gx'), ('Gx', 'Gx', 'Gx'), ('Gx', 'Gx', 'Gz', 'Gx')]) germs = _strc.gatestring_list([('Gx', ), ('Gz', ), ('Gz', 'Gx', 'Gx'), ('Gz', 'Gz', 'Gx')]) #Construct a target gateset: X(pi/2), Z(pi/2) gs_target = _setc.build_gateset([2], [('Q0', )], ['Gx', 'Gz'], ["X(pi/2,Q0)", "Z(pi/2,Q0)"], prepLabels=["rho0"], prepExpressions=["0"], effectLabels=["E0"],
def make_lsgst_lists(gateLabels, prepStrs, effectStrs, germList, maxLengthList, fidPairs=None, truncScheme="whole germ powers", nest=True): """ Create a set of gate string lists for LSGST based on germs and max-lengths. Constructs a series (a list) of gate string lists used by long-sequence GST (LSGST) algorithms. If maxLengthList[0] == 0 then the starting list is the list of LGST strings, otherwise the starting list is empty. For each nonzero element of maxLengthList, call it L, a list of gate strings is created with the form: Case: truncScheme == 'whole germ powers': prepStr + pygsti.construction.repeat_with_max_length(germ,L) + effectStr Case: truncScheme == 'truncated germ powers': prepStr + pygsti.construction.repeat_and_truncate(germ,L) + effectStr Case: truncScheme == 'length as exponent': prepStr + germ^L + effectStr If nest == True, the above list is iteratively *added* (w/duplicates removed) to the current list of gate strings to form a final list for the given L. This results in successively larger lists, each of which contains all the elements of previous-L lists. If nest == False then the above list *is* the final list for the given L. Parameters ---------- gateLabels : list or tuple List of gate labels to determine needed LGST strings. Only relevant when maxLengthList[0] == 0. prepStrs : list of GateStrings List of the preparation fiducial gate strings, which follow state preparation. effectStrs : list of GateStrings List of the measurement fiducial gate strings, which precede measurement. germList : list of GateStrings List of the germ gate strings. maxLengthList : list of ints List of maximum lengths. If maxLengthList[0] == 0 this results in special behavior where LGST strings are included as the first returned list. fidPairs : list of 2-tuples, optional Specifies a subset of all fiducial string pairs (prepStr, effectStr) to be used in the gate string lists. Each element of fidPairs is a (iPrepStr, iEffectStr) 2-tuple of integers, each indexing a string within prepStrs and effectStrs, respectively, so that prepStr = prepStrs[iPrepStr] and effectStr = effectStrs[iEffectStr]. truncScheme : str, optional Truncation scheme used to interpret what the list of maximum lengths means. If unsure, leave as default. Allowed values are: - 'whole germ powers' -- germs are repeated an integer number of times such that the length is less than or equal to the max. - 'truncated germ powers' -- repeated germ string is truncated to be exactly equal to the max (partial germ at end is ok). - 'length as exponent' -- max. length is instead interpreted as the germ exponent (the number of germ repetitions). nest : boolean, optional If Frue, the returned gate string lists are "nested", meaning that each successive list of gate strings contains all the gate strings found in previous lists (and usually some additional new ones). If False, then the returned string list for maximum length == L contains *only* those gate strings specified in the description above, and *not* those for previous values of L. Returns ------- list of (lists of GateStrings) The i-th list corresponds to a gate string list containing repeated germs limited to length maxLengthList[i]. If nest == True, then repeated germs limited to previous max-lengths are also included. Note that a "0" maximum-length corresponds to the LGST strings. """ lgstStrings = _gsc.list_lgst_gatestrings( _ssc.build_spam_specs(prepStrs = prepStrs, effectStrs = effectStrs), gateLabels) lsgst_list = _gsc.gatestring_list([ () ]) #running list of all strings so far if fidPairs is not None: fiducialPairs = [ (prepStrs[i],effectStrs[j]) for (i,j) in fidPairs ] else: fiducialPairs = list(_itertools.product(prepStrs, effectStrs)) if maxLengthList[0] == 0: lsgst_listOfLists = [ lgstStrings ] maxLengthList = maxLengthList[1:] else: lsgst_listOfLists = [ ] Rfn = _getTruncFunction(truncScheme) for maxLen in maxLengthList: lst = _gsc.create_gatestring_list("f[0]+R(germ,N)+f[1]", f=fiducialPairs, germ=germList, N=maxLen, R=Rfn, order=('germ','f')) if nest: lsgst_list += lst #add new strings to running list lsgst_listOfLists.append( _lt.remove_duplicates(lgstStrings + lsgst_list) ) else: lsgst_listOfLists.append( _lt.remove_duplicates(lst) ) #print "%d LSGST sets w/lengths" % len(lsgst_listOfLists),map(len,lsgst_listOfLists) return lsgst_listOfLists
# pyGSTi 0.9: Copyright 2015 Sandia Corporation # This Software is released under the GPL license detailed # in the file "license.txt" in the top-level pyGSTi directory #***************************************************************** """ Variables for working with the a gate set containing Idle, X(pi/2) and Y(pi/2) gates. """ import gatestringconstruction as _strc import gatesetconstruction as _setc description = "Idle, X(pi/2), and Y(pi/2) gates" gates = ['Gi', 'Gx', 'Gy'] fiducials = _strc.gatestring_list([(), ('Gx', ), ('Gy', ), ('Gx', 'Gx'), ('Gx', 'Gx', 'Gx'), ('Gy', 'Gy', 'Gy')]) # for 1Q MUB germs = _strc.gatestring_list([('Gx', ), ('Gy', ), ('Gi', ), ('Gx', 'Gy'), ('Gx', 'Gy', 'Gi'), ('Gx', 'Gi', 'Gy'), ('Gx', 'Gi', 'Gi'), ('Gy', 'Gi', 'Gi'), ('Gx', 'Gx', 'Gi', 'Gy'), ('Gx', 'Gy', 'Gy', 'Gi'), ('Gx', 'Gx', 'Gy', 'Gx', 'Gy', 'Gy')]) #Construct a target gateset: Identity, X(pi/2), Y(pi/2) gs_target = _setc.build_gateset([2], [('Q0', )], ['Gi', 'Gx', 'Gy'], ["I(Q0)", "X(pi/2,Q0)", "Y(pi/2,Q0)"], prepLabels=["rho0"], prepExpressions=["0"], effectLabels=["E0"], effectExpressions=["1"],
def make_elgst_lists(gateLabels, germList, maxLengthList, truncScheme="whole germ powers", nest=True): """ Create a set of gate string lists for eLGST based on germs and max-lengths Constructs a series (a list) of gate string lists used by the extended LGST (eLGST) algorithm. If maxLengthList[0] == 0 then the starting list is the list of length-1 gate label strings, otherwise the starting list is empty. For each nonzero element of maxLengthList, call it L, a list of gate strings is created with the form: Case: truncScheme == 'whole germ powers': pygsti.construction.repeat_with_max_length(germ,L) Case: truncScheme == 'truncated germ powers': pygsti.construction.repeat_and_truncate(germ,L) Case: truncScheme == 'length as exponent': germ^L If nest == True, the above list is iteratively *added* (w/duplicates removed) to the current list of gate strings to form a final list for the given L. This results in successively larger lists, each of which contains all the elements of previous-L lists. If nest == False then the above list *is* the final list for the given L. Parameters ---------- gateLabels : list or tuple List of gate labels. Only relevant when maxLengthList[0] == 0. germList : list of GateStrings List of the germ gate strings. maxLengthList : list of ints List of the maximum lengths. If maxLengthList[0] == 0 this results in special behavior where the length-1 gate label strings are included as the first returned list. truncScheme : str, optional Truncation scheme used to interpret what the list of maximum lengths means. If unsure, leave as default. Allowed values are: - 'whole germ powers' -- germs are repeated an integer number of times such that the length is less than or equal to the max. - 'truncated germ powers' -- repeated germ string is truncated to be exactly equal to the max (partial germ at end is ok). - 'length as exponent' -- max. length is instead interpreted as the germ exponent (the number of germ repetitions). nest : boolean, optional If Frue, the returned gate string lists are "nested", meaning that each successive list of gate strings contains all the gate strings found in previous lists (and usually some additional new ones). If False, then the returned string list for maximum length == L contains *only* those gate strings specified in the description above, and *not* those for previous values of L. Returns ------- list of (lists of GateStrings) The i-th list corresponds to a gate string list containing repeated germs limited to length maxLengthList[i]. If nest == True, then repeated germs limited to previous max-lengths are also included. Note that a "0" maximum-length corresponds to the gate label strings. """ singleGates = _gsc.gatestring_list([(g, ) for g in gateLabels]) elgst_list = _gsc.gatestring_list([() ]) #running list of all strings so far if maxLengthList[0] == 0: elgst_listOfLists = [singleGates] maxLengthList = maxLengthList[1:] else: elgst_listOfLists = [] Rfn = _getTruncFunction(truncScheme) for maxLen in maxLengthList: lst = _gsc.create_gatestring_list("R(germ,N)", germ=germList, N=maxLen, R=Rfn) if nest: elgst_list += lst #add new strings to running list elgst_listOfLists.append( _lt.remove_duplicates(singleGates + elgst_list)) else: elgst_listOfLists.append(_lt.remove_duplicates(lst)) #print "%d eLGST sets w/lengths" % len(elgst_listOfLists),map(len,elgst_listOfLists) return elgst_listOfLists
def make_lsgst_lists(gateLabels, prepStrs, effectStrs, germList, maxLengthList, fidPairs=None, truncScheme="whole germ powers", nest=True): """ Create a set of gate string lists for LSGST based on germs and max-lengths. Constructs a series (a list) of gate string lists used by long-sequence GST (LSGST) algorithms. If maxLengthList[0] == 0 then the starting list is the list of LGST strings, otherwise the starting list is empty. For each nonzero element of maxLengthList, call it L, a list of gate strings is created with the form: Case: truncScheme == 'whole germ powers': prepStr + pygsti.construction.repeat_with_max_length(germ,L) + effectStr Case: truncScheme == 'truncated germ powers': prepStr + pygsti.construction.repeat_and_truncate(germ,L) + effectStr Case: truncScheme == 'length as exponent': prepStr + germ^L + effectStr If nest == True, the above list is iteratively *added* (w/duplicates removed) to the current list of gate strings to form a final list for the given L. This results in successively larger lists, each of which contains all the elements of previous-L lists. If nest == False then the above list *is* the final list for the given L. Parameters ---------- gateLabels : list or tuple List of gate labels to determine needed LGST strings. Only relevant when maxLengthList[0] == 0. prepStrs : list of GateStrings List of the preparation fiducial gate strings, which follow state preparation. effectStrs : list of GateStrings List of the measurement fiducial gate strings, which precede measurement. germList : list of GateStrings List of the germ gate strings. maxLengthList : list of ints List of maximum lengths. If maxLengthList[0] == 0 this results in special behavior where LGST strings are included as the first returned list. fidPairs : list of 2-tuples, optional Specifies a subset of all fiducial string pairs (prepStr, effectStr) to be used in the gate string lists. Each element of fidPairs is a (iPrepStr, iEffectStr) 2-tuple of integers, each indexing a string within prepStrs and effectStrs, respectively, so that prepStr = prepStrs[iPrepStr] and effectStr = effectStrs[iEffectStr]. truncScheme : str, optional Truncation scheme used to interpret what the list of maximum lengths means. If unsure, leave as default. Allowed values are: - 'whole germ powers' -- germs are repeated an integer number of times such that the length is less than or equal to the max. - 'truncated germ powers' -- repeated germ string is truncated to be exactly equal to the max (partial germ at end is ok). - 'length as exponent' -- max. length is instead interpreted as the germ exponent (the number of germ repetitions). nest : boolean, optional If Frue, the returned gate string lists are "nested", meaning that each successive list of gate strings contains all the gate strings found in previous lists (and usually some additional new ones). If False, then the returned string list for maximum length == L contains *only* those gate strings specified in the description above, and *not* those for previous values of L. Returns ------- list of (lists of GateStrings) The i-th list corresponds to a gate string list containing repeated germs limited to length maxLengthList[i]. If nest == True, then repeated germs limited to previous max-lengths are also included. Note that a "0" maximum-length corresponds to the LGST strings. """ lgstStrings = _gsc.list_lgst_gatestrings( _ssc.build_spam_specs(prepStrs=prepStrs, effectStrs=effectStrs), gateLabels) lsgst_list = _gsc.gatestring_list([() ]) #running list of all strings so far if fidPairs is not None: fiducialPairs = [(prepStrs[i], effectStrs[j]) for (i, j) in fidPairs] else: fiducialPairs = list(_itertools.product(prepStrs, effectStrs)) if maxLengthList[0] == 0: lsgst_listOfLists = [lgstStrings] maxLengthList = maxLengthList[1:] else: lsgst_listOfLists = [] Rfn = _getTruncFunction(truncScheme) for maxLen in maxLengthList: lst = _gsc.create_gatestring_list("f[0]+R(germ,N)+f[1]", f=fiducialPairs, germ=germList, N=maxLen, R=Rfn, order=('germ', 'f')) if nest: lsgst_list += lst #add new strings to running list lsgst_listOfLists.append( _lt.remove_duplicates(lgstStrings + lsgst_list)) else: lsgst_listOfLists.append(_lt.remove_duplicates(lst)) #print "%d LSGST sets w/lengths" % len(lsgst_listOfLists),map(len,lsgst_listOfLists) return lsgst_listOfLists
""" Variables for working with the 2-qubit gate set containing the gates I*X(pi/2), I*Y(pi/2), X(pi/2)*I, Y(pi/2)*I, and CNOT. """ import gatestringconstruction as _strc import gatesetconstruction as _setc import spamspecconstruction as _spamc description = "I*X(pi/2), I*Y(pi/2), X(pi/2)*I, Y(pi/2)*I, and CNOT gates" gates = ['Gix','Giy','Gxi','Gyi','Gcnot'] fiducials16 = _strc.gatestring_list( [ (), ('Gix',), ('Giy',), ('Gix','Gix'), ('Gxi',), ('Gxi','Gix'), ('Gxi','Giy'), ('Gxi','Gix','Gix'), ('Gyi',), ('Gyi','Gix'), ('Gyi','Giy'), ('Gyi','Gix','Gix'), ('Gxi','Gxi'), ('Gxi','Gxi','Gix'), ('Gxi','Gxi','Giy'), ('Gxi','Gxi','Gix','Gix') ] ) fiducials36 = _strc.gatestring_list( [ (), ('Gix',), ('Giy',), ('Gix','Gix'), ('Gix','Gix','Gix'), ('Giy','Giy','Giy'), ('Gxi',), ('Gxi','Gix'), ('Gxi','Giy'), ('Gxi','Gix','Gix'), ('Gxi','Gix','Gix','Gix'), ('Gxi','Giy','Giy','Giy'), ('Gyi',), ('Gyi','Gix'), ('Gyi','Giy'), ('Gyi','Gix','Gix'), ('Gyi','Gix','Gix','Gix'), ('Gyi','Giy','Giy','Giy'), ('Gxi','Gxi'), ('Gxi','Gxi','Gix'), ('Gxi','Gxi','Giy'), ('Gxi','Gxi','Gix','Gix'), ('Gxi','Gxi','Gix','Gix','Gix'), ('Gxi','Gxi','Giy','Giy','Giy'), ('Gxi','Gxi','Gxi'), ('Gxi','Gxi','Gxi','Gix'), ('Gxi','Gxi','Gxi','Giy'), ('Gxi','Gxi','Gxi','Gix','Gix'), ('Gxi','Gxi','Gxi','Gix','Gix','Gix'), ('Gxi','Gxi','Gxi','Giy','Giy','Giy'), ('Gyi','Gyi','Gyi'), ('Gyi','Gyi','Gyi','Gix'), ('Gyi','Gyi','Gyi','Giy'), ('Gyi','Gyi','Gyi','Gix','Gix'), ('Gyi','Gyi','Gyi','Gix','Gix','Gix'), ('Gyi','Gyi','Gyi','Giy','Giy','Giy') ] ) fiducials = fiducials16 prepStrs = fiducials16