import pygsti
import pickle
import time
#If we were using MPI
# from mpi4py import MPI
# comm = MPI.COMM_WORLD
comm = None
#Load the 2-qubit results (if you don't have this file, run the 2Q-GST example)
with open("example_files/easy_2q_results.pkl","rb") as f:
results = pickle.load(f)
#Set a memory limit
print("Memory limit was = ", results.estimates['default'].parameters.get('memLimit',"none given"))
results.estimates['default'].parameters['memLimit'] = 2.5*(1024.0)**3 # 2.5GB
print("Memory limit is now = ", results.estimates['default'].parameters['memLimit'])
Memory limit was = 3221225472 Memory limit is now = 2684354560.0
# error bars in reports require the presence of a fully-initialized
# "confidence region factory" within the relevant Estimate object.
# In most cases "fully-initialized" means that a Hessian has been
# computed and projected onto the non-gauge space.
start = time.time()
# initialize a factory for the 'go0' gauge optimization within the 'default' estimate
crfact = results.estimates['default'].add_confidence_region_factory('go0', 'final')
crfact.compute_hessian(comm=comm) #optionally use multiple processors
crfact.project_hessian('intrinsic error')
end = time.time()
print("Total time=%f hours" % ((end - start) / 3600.0))
Evaltree generation (deriv) w/mem limit = 2.48GB mem(1 subtrees, 1,1 param-grps, 1 proc-grps) in 0s = 6773.17GB (6773.17GB fc) Created evaluation tree with 1 subtrees. Will divide 1 procs into 1 (subtree-processing) groups of ~1 procs each, to distribute over (1616,1616) params (taken as 1616,4 param groups of ~1,404 params). Memory estimate = 2.08GB (cache=1317, wrtLen1=1, wrtLen2=404, subsPerProc=1). rank 0: 28.7456s: block 0/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 57.0849s: block 1/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 85.307s: block 2/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 114.001s: block 3/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 142.315s: block 4/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 170.56s: block 5/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 198.853s: block 6/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 227.573s: block 7/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 255.879s: block 8/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 284.05s: block 9/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 312.368s: block 10/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 340.616s: block 11/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 368.909s: block 12/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 397.244s: block 13/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 425.513s: block 14/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 453.775s: block 15/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 482.084s: block 16/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 510.291s: block 17/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 538.496s: block 18/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 566.854s: block 19/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 595.287s: block 20/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 623.537s: block 21/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 651.747s: block 22/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 679.983s: block 23/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 708.176s: block 24/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 736.482s: block 25/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 764.708s: block 26/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 792.868s: block 27/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 821.206s: block 28/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 849.412s: block 29/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 877.614s: block 30/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 905.894s: block 31/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 934.147s: block 32/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 962.373s: block 33/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 990.554s: block 34/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1018.69s: block 35/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1046.94s: block 36/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1075.31s: block 37/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1103.54s: block 38/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1131.84s: block 39/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1160.28s: block 40/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1188.52s: block 41/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1216.72s: block 42/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1244.92s: block 43/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1273.29s: block 44/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1301.41s: block 45/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1329.71s: block 46/4043, sub-tree 0/1, sub-tree-len = 1317 rank 0: 1358.43s: block 47/4043, sub-tree 0/1, sub-tree-len = 1317
--------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) <ipython-input-2-7208f561b6ac> in <module>() 7 # initialize a factory for the 'go0' gauge optimization within the 'default' estimate 8 crfact = results.estimates['default'].add_confidence_region_factory('go0', 'final') ----> 9 crfact.compute_hessian(comm=comm) #optionally use multiple processors 10 crfact.project_hessian('intrinsic error') 11 ~/research/pyGSTi/packages/pygsti/objects/confidenceregionfactory.py in compute_hessian(self, comm, memLimit, approximate) 239 minProbClip, probClipInterval, radius, 240 comm=comm, memLimit=memLimit, verbosity=vb, --> 241 gateLabelAliases=aliases) 242 243 nonMarkRadiusSq = max( 2*(_tools.logl_max(gateset, dataset) ~/research/pyGSTi/packages/pygsti/tools/likelihoodfns.py in logl_hessian(gateset, dataset, gatestring_list, minProbClip, probClipInterval, radius, poissonPicture, check, comm, memLimit, gateLabelAliases, smartc, verbosity) 733 k,kmax = 0,len(mySliceTupList) 734 for (slice1,slice2,hprobs,dprobs12) in gateset.bulk_hprobs_by_block( --> 735 evalSubTree, mySliceTupList, True, blkComm): 736 rank = comm.Get_rank() if (comm is not None) else 0 737 ~/research/pyGSTi/packages/pygsti/objects/gatematrixcalc.py in bulk_hprobs_by_block(self, evalTree, wrtSlicesList, bReturnDProbs12, comm) 2683 else: 2684 dProdCache2 =self._compute_dproduct_cache( -> 2685 evalTree, prodCache, scaleCache, comm, wrtSlice2) 2686 dGs2 = evalTree.final_view(dProdCache2, axis=0) 2687 ~/research/pyGSTi/packages/pygsti/objects/gatematrixcalc.py in _compute_dproduct_cache(self, evalTree, prodCache, scaleCache, comm, wrtSlice, profiler) 962 L,R = prodCache[iLeft], prodCache[iRight] 963 dL,dR = dProdCache[iLeft], dProdCache[iRight] --> 964 dProdCache[i] = _np.dot(dL, R) + \ 965 _np.swapaxes(_np.dot(L, dR),0,1) #dot(dS, T) + dot(S, dT) 966 profiler.add_time("compute_dproduct_cache: dots", tm) KeyboardInterrupt:
Note above cell was executed for demonstration purposes, and was keyboard-interrupted intentionally since it would have taken forever on a single processor.
#write results back to file
with open("example_files/easy_2q_results_withCI.pkl","wb") as f:
pickle.dump(results, f)