Exemplo n.º 1
0
        def make_lsgst_lists(opLabels, fiducialList, germList, maxLengthList):
            singleOps = pc.circuit_list([(g, ) for g in opLabels])
            lgstStrings = pc.list_lgst_circuits(fiducialList, fiducialList,
                                                opLabels)
            lsgst_list = pc.circuit_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_circuit_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
Exemplo n.º 2
0
def create_fake_dataset(comm):
    fidPairList = None
    maxLengths = [0, 1, 2, 4, 8, 16]
    nSamples = 1000
    specs = pygsti.construction.build_spam_specs(
        std.fiducials,
        prep_labels=std.gs_target.get_prep_labels(),
        effect_labels=std.gs_target.get_effect_labels())

    rhoStrs, EStrs = pygsti.construction.get_spam_strs(specs)
    lgstStrings = pygsti.construction.list_lgst_gatestrings(
        specs, list(std.gs_target.gates.keys()))
    lsgstStrings = pygsti.construction.make_lsgst_lists(
        list(std.gs_target.gates.keys()), rhoStrs, EStrs, std.germs,
        maxLengths, fidPairList)

    lsgstStringsToUse = lsgstStrings
    allRequiredStrs = pygsti.remove_duplicates(lgstStrings + lsgstStrings[-1])

    if comm is None or comm.Get_rank() == 0:
        gs_dataGen = std.gs_target.depolarize(gate_noise=0.1)
        dsFake = pygsti.construction.generate_fake_data(
            gs_dataGen,
            allRequiredStrs,
            nSamples,
            sampleError="multinomial",
            seed=1234)
        dsFake = comm.bcast(dsFake, root=0)
    else:
        dsFake = comm.bcast(None, root=0)

    #for gs in dsFake:
    #    if abs(dsFake[gs]['plus']-dsFake_cmp[gs]['plus']) > 0.5:
    #        print("DS DIFF: ",gs, dsFake[gs]['plus'], "vs", dsFake_cmp[gs]['plus'] )
    return dsFake, lsgstStrings
Exemplo n.º 3
0
def runMC2GSTAnalysis(myspecs,
                      mygerms,
                      gsTarget,
                      seed,
                      maxLs=[1, 2, 4, 8],
                      nSamples=1000,
                      useFreqWeightedChiSq=False,
                      minProbClipForWeighting=1e-4,
                      fidPairList=None,
                      comm=None):
    rhoStrs, EStrs = pygsti.construction.get_spam_strs(myspecs)
    lgstStrings = pygsti.construction.list_lgst_gatestrings(
        myspecs, gsTarget.gates.keys())
    lsgstStrings = pygsti.construction.make_lsgst_lists(
        gsTarget.gates.keys(), rhoStrs, EStrs, mygerms, maxLs, fidPairList)

    print len(myspecs[0]), " rho specifiers"
    print len(myspecs[1]), " effect specifiers"
    print len(mygerms), " germs"
    print len(lgstStrings), " total LGST gate strings"
    print len(lsgstStrings[-1]), " LSGST strings before thinning"

    lsgstStringsToUse = lsgstStrings
    allRequiredStrs = pygsti.remove_duplicates(lgstStrings + lsgstStrings[-1])

    gs_dataGen = gsTarget.depolarize(gate_noise=0.1)
    dsFake = pygsti.construction.generate_fake_data(gs_dataGen,
                                                    allRequiredStrs,
                                                    nSamples,
                                                    sampleError="multinomial",
                                                    seed=seed)

    #Run LGST to get starting gate set
    gs_lgst = pygsti.do_lgst(dsFake,
                             myspecs,
                             gsTarget,
                             svdTruncateTo=gsTarget.dim,
                             verbosity=3)
    gs_lgst_go = pygsti.optimize_gauge(gs_lgst,
                                       "target",
                                       targetGateset=gs_dataGen)

    #Run full iterative LSGST
    tStart = time.time()
    all_gs_lsgst = pygsti.do_iterative_mc2gst(
        dsFake,
        gs_lgst_go,
        lsgstStringsToUse,
        minProbClipForWeighting=minProbClipForWeighting,
        probClipInterval=(-1e5, 1e5),
        verbosity=1,
        memLimit=3 * (1024)**3,
        returnAll=True,
        useFreqWeightedChiSq=useFreqWeightedChiSq,
        comm=comm)
    tEnd = time.time()
    print "Time = ", (tEnd - tStart) / 3600.0, "hours ( =", (tEnd -
                                                             tStart), " secs)"

    return all_gs_lsgst, gs_dataGen
Exemplo n.º 4
0
def create_fake_dataset(comm):
    fidPairList = None
    maxLengths = [0,1,2,4,8,16]
    nSamples = 1000
    specs = pygsti.construction.build_spam_specs(
        std.fiducials, prep_labels=std.gs_target.get_prep_labels(),
        effect_labels=std.gs_target.get_effect_labels())

    rhoStrs, EStrs = pygsti.construction.get_spam_strs(specs)
    lgstStrings = pygsti.construction.list_lgst_gatestrings(
        specs, list(std.gs_target.gates.keys()))
    lsgstStrings = pygsti.construction.make_lsgst_lists(
            list(std.gs_target.gates.keys()), rhoStrs, EStrs,
            std.germs, maxLengths, fidPairList )

    lsgstStringsToUse = lsgstStrings
    allRequiredStrs = pygsti.remove_duplicates(lgstStrings + lsgstStrings[-1])

    if comm is None or comm.Get_rank() == 0:
        gs_dataGen = std.gs_target.depolarize(gate_noise=0.1)
        dsFake = pygsti.construction.generate_fake_data(
            gs_dataGen, allRequiredStrs, nSamples, sampleError="multinomial",
            seed=1234)
        dsFake = comm.bcast(dsFake, root=0)
    else:
        dsFake = comm.bcast(None, root=0)

    #for gs in dsFake:
    #    if abs(dsFake[gs]['plus']-dsFake_cmp[gs]['plus']) > 0.5:
    #        print("DS DIFF: ",gs, dsFake[gs]['plus'], "vs", dsFake_cmp[gs]['plus'] )
    return dsFake, lsgstStrings
Exemplo n.º 5
0
def create_fake_dataset(comm):
    fidPairList = None
    maxLengths = [1,2,4,8,16]
    nSamples = 1000
    #specs = pygsti.construction.build_spam_specs(
    #    std.fiducials, prep_labels=std.target_model().get_prep_labels(),
    #    effect_labels=std.target_model().get_effect_labels())
    #rhoStrs, EStrs = pygsti.construction.get_spam_strs(specs)

    rhoStrs = EStrs = std.fiducials
    lgstStrings = pygsti.construction.list_lgst_circuits(
        rhoStrs, EStrs, list(std.target_model().operations.keys()))
    lsgstStrings = pygsti.construction.make_lsgst_lists(
            list(std.target_model().operations.keys()), rhoStrs, EStrs,
            std.germs, maxLengths, fidPairList )

    lsgstStringsToUse = lsgstStrings
    allRequiredStrs = pygsti.remove_duplicates(lgstStrings + lsgstStrings[-1])

    if comm is None or comm.Get_rank() == 0:
        mdl_dataGen = std.target_model().depolarize(op_noise=0.1)
        dsFake = pygsti.construction.generate_fake_data(
            mdl_dataGen, allRequiredStrs, nSamples, sampleError="multinomial",
            seed=1234)
        dsFake = comm.bcast(dsFake, root=0)
    else:
        dsFake = comm.bcast(None, root=0)

    #for mdl in dsFake:
    #    if abs(dsFake[mdl]['0']-dsFake_cmp[mdl]['0']) > 0.5:
    #        print("DS DIFF: ",mdl, dsFake[mdl]['0'], "vs", dsFake_cmp[mdl]['0'] )
    return dsFake, lsgstStrings
Exemplo n.º 6
0
def runAnalysis(obj, myspecs, mygerms, gsTarget, seed,
                maxLs = [1,2,4,8],
                nSamples=1000, useFreqWeightedChiSq=False,
                minProbClipForWeighting=1e-4, fidPairList=None,
                comm=None, distributeMethod="gatestrings"):
    rhoStrs, EStrs = pygsti.construction.get_spam_strs(myspecs)
    lgstStrings = pygsti.construction.list_lgst_gatestrings(
        myspecs, gsTarget.gates.keys())
    lsgstStrings = pygsti.construction.make_lsgst_lists(
            gsTarget.gates.keys(), rhoStrs, EStrs, mygerms, maxLs, fidPairList )

    print len(myspecs[0]), " rho specifiers"
    print len(myspecs[1]), " effect specifiers"
    print len(mygerms), " germs"
    print len(lgstStrings), " total LGST gate strings"
    print len(lsgstStrings[-1]), " LSGST strings before thinning"
    
    lsgstStringsToUse = lsgstStrings
    allRequiredStrs = pygsti.remove_duplicates(lgstStrings + lsgstStrings[-1])
     
    
    gs_dataGen = gsTarget.depolarize(gate_noise=0.1)
    dsFake = pygsti.construction.generate_fake_data(
        gs_dataGen, allRequiredStrs, nSamples, sampleError="multinomial",
        seed=seed)

    #Run LGST to get starting gate set
    gs_lgst = pygsti.do_lgst(dsFake, myspecs, gsTarget,
                             svdTruncateTo=gsTarget.dim, verbosity=3)
    gs_lgst_go = pygsti.optimize_gauge(gs_lgst,"target",
                                       targetGateset=gs_dataGen)
    
    #Run full iterative LSGST
    tStart = time.time()
    if obj == "chi2":
        all_gs_lsgst = pygsti.do_iterative_mc2gst(
            dsFake, gs_lgst_go, lsgstStringsToUse,
            minProbClipForWeighting=minProbClipForWeighting,
            probClipInterval=(-1e5,1e5),
            verbosity=1, memLimit=3*(1024)**3, returnAll=True, 
            useFreqWeightedChiSq=useFreqWeightedChiSq, comm=comm,
            distributeMethod=distributeMethod)
    elif obj == "logl":
        all_gs_lsgst = pygsti.do_iterative_mlgst(
            dsFake, gs_lgst_go, lsgstStringsToUse,
            minProbClip=minProbClipForWeighting,
            probClipInterval=(-1e5,1e5),
            verbosity=1, memLimit=3*(1024)**3, returnAll=True, 
            useFreqWeightedChiSq=useFreqWeightedChiSq, comm=comm,
            distributeMethod=distributeMethod)

    tEnd = time.time()
    print "Time = ",(tEnd-tStart)/3600.0,"hours"
    
    return all_gs_lsgst, gs_dataGen
Exemplo n.º 7
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