示例#1
0
        def make_lsgst_lists(gateLabels, fiducialList, germList,
                             maxLengthList):
            singleGates = pc.gatestring_list([(g, ) for g in gateLabels])
            lgstStrings = pc.list_lgst_gatestrings(fiducialList, fiducialList,
                                                   gateLabels)
            lsgst_list = pc.gatestring_list([
                ()
            ])  #running list of all strings so far

            if maxLengthList[0] == 0:
                lsgst_listOfLists = [lgstStrings]
                maxLengthList = maxLengthList[1:]
            else:
                lsgst_listOfLists = []

            for maxLen in maxLengthList:
                lsgst_list += pc.create_gatestring_list(
                    "f0+R(germ,N)+f1",
                    f0=fiducialList,
                    f1=fiducialList,
                    germ=germList,
                    N=maxLen,
                    R=pc.repeat_with_max_length,
                    order=('germ', 'f0', 'f1'))
                lsgst_listOfLists.append(
                    pygsti.remove_duplicates(lgstStrings + lsgst_list))

            print("%d LSGST sets w/lengths" % len(lsgst_listOfLists),
                  map(len, lsgst_listOfLists))
            return lsgst_listOfLists
示例#2
0
        def make_lsgst_lists(gateLabels, fiducialList, germList, maxLengthList):
            singleGates = pc.gatestring_list([(g,) for g in gateLabels])
            lgstStrings = pc.list_lgst_gatestrings(pc.build_spam_specs(fiducialList), gateLabels)
            lsgst_list  = pc.gatestring_list([ () ]) #running list of all strings so far

            if maxLengthList[0] == 0:
                lsgst_listOfLists = [ lgstStrings ]
                maxLengthList = maxLengthList[1:]
            else: lsgst_listOfLists = [ ]

            for maxLen in maxLengthList:
                lsgst_list += pc.create_gatestring_list("f0+R(germ,N)+f1", f0=fiducialList,
                f1=fiducialList, germ=germList, N=maxLen,
                R=pc.repeat_with_max_length,
                order=('germ','f0','f1'))
                lsgst_listOfLists.append( pygsti.remove_duplicates(lgstStrings + lsgst_list) )

            print("%d LSGST sets w/lengths" % len(lsgst_listOfLists), map(len,lsgst_listOfLists))
            return lsgst_listOfLists
    def setUp(self):
        super(DataSetConstructionTestCase, self).setUp()
        self.gateset = pc.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"],
                                         spamdefs={'plus': ('rho0','E0'), 'minus': ('rho0','remainder') })
        self.depolGateset = self.gateset.depolarize(gate_noise=0.1)

        def make_lsgst_lists(gateLabels, fiducialList, germList, maxLengthList):
            singleGates = pc.gatestring_list([(g,) for g in gateLabels])
            lgstStrings = pc.list_lgst_gatestrings(pc.build_spam_specs(fiducialList), gateLabels)
            lsgst_list  = pc.gatestring_list([ () ]) #running list of all strings so far

            if maxLengthList[0] == 0:
                lsgst_listOfLists = [ lgstStrings ]
                maxLengthList = maxLengthList[1:]
            else: lsgst_listOfLists = [ ]

            for maxLen in maxLengthList:
                lsgst_list += pc.create_gatestring_list("f0+R(germ,N)+f1", f0=fiducialList,
                f1=fiducialList, germ=germList, N=maxLen,
                R=pc.repeat_with_max_length,
                order=('germ','f0','f1'))
                lsgst_listOfLists.append( pygsti.remove_duplicates(lgstStrings + lsgst_list) )

            print("%d LSGST sets w/lengths" % len(lsgst_listOfLists), map(len,lsgst_listOfLists))
            return lsgst_listOfLists

        gates      = ['Gi','Gx','Gy']
        fiducials  = pc.gatestring_list([ (), ('Gx',), ('Gy',), ('Gx','Gx'), ('Gx','Gx','Gx'), ('Gy','Gy','Gy') ]) # fiducials for 1Q MUB
        germs      = pc.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',)] )
        maxLengths = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256]
        self.lsgst_lists     = make_lsgst_lists(gates, fiducials, germs, maxLengths)
        self.gatestring_list = self.lsgst_lists[-1]
        self.dataset = pc.generate_fake_data(self.depolGateset, self.gatestring_list, nSamples=1000,
                                             sampleError='binomial', seed=100)
示例#4
0
def main():
    gates = ['Gi', 'Gx', 'Gy']
    fiducials = pc.gatestring_list([(), ('Gx', ), ('Gy', ), ('Gx', 'Gx'),
                                    ('Gx', 'Gx', 'Gx'), ('Gy', 'Gy', 'Gy')
                                    ])  # fiducials for 1Q MUB
    germs = pc.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',
    )])
    maxLengths = [1, 2, 4, 8, 16, 32, 64, 128, 256]
    lsgst_lists = pc.create_lsgst_circuits(gates, fiducials, fiducials, germs,
                                           maxLengths)
    lsgst_tuple = tuple(lsgst_lists)
    iterations = 1000
    timeDict = dict()
    with timed_block('hash_gatestring_list', timeDict):
        for i in range(iterations):
            hash(lsgst_tuple)

    exampleUUID = uuid.uuid4()
    alt_hash = pygsti.tools.smartcache.digest
    with timed_block('digest_uuid', timeDict):
        for i in range(iterations):
            alt_hash(exampleUUID)

    print('Hashing gslist of length {} takes {} seconds on average'.format(
        len(lsgst_tuple), timeDict['hash_gatestring_list'] / iterations))
    print('UUID digest takes {} seconds on average'.format(
        timeDict['digest_uuid'] / iterations))