-
Notifications
You must be signed in to change notification settings - Fork 55
/
fixtures.py
71 lines (51 loc) · 1.84 KB
/
fixtures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Shared test fixtures for pygsti.tools unit tests"""
from ..util import Namespace
import pygsti
from pygsti.modelpacks.legacy import std1Q_XYI as std
ns = Namespace()
ns.model = std.target_model()
ns.opLabels = list(ns.model.operations.keys())
ns.fiducials = std.fiducials
ns.germs = std.germs
ns.maxLengthList = [0, 1, 2, 4, 8]
ns.CM = pygsti.objects.profiler._get_mem_usage()
@ns.memo
def datagen_gateset(self):
return self.model.depolarize(op_noise=0.05, spam_noise=0.1)
@ns.memo
def expList(self):
return pygsti.construction.make_lsgst_experiment_list(
self.opLabels, self.fiducials, self.fiducials, self.germs, self.maxLengthList)
@ns.memo
def dataset(self):
# Was previously written to disk as 'analysis.dataset'
return pygsti.construction.generate_fake_data(
self.datagen_gateset, self.expList, nSamples=10000,
sampleError='binomial', seed=100
)
@ns.memo
def mdl_lgst(self):
return pygsti.do_lgst(self.dataset, self.fiducials, self.fiducials, self.model, svdTruncateTo=4, verbosity=0)
@ns.memo
def mdl_lgst_go(self):
return pygsti.gaugeopt_to_target(self.mdl_lgst, self.model, {'spam': 1.0, 'gates': 1.0}, checkJac=True)
@ns.memo
def mdl_clgst(self):
return pygsti.contract(self.mdl_lgst_go, "CPTP")
@ns.memo
def lsgstStrings(self):
return pygsti.construction.make_lsgst_lists(
self.opLabels, self.fiducials, self.fiducials, self.germs,
self.maxLengthList
)
@ns.memo
def mdl_lsgst(self):
return pygsti.do_iterative_mc2gst(
self.dataset, self.mdl_clgst, self.lsgstStrings, verbosity=0,
minProbClipForWeighting=1e-6, probClipInterval=(-1e6, 1e6),
memLimit=self.CM + 10*1024**3
)
@ns.memo
def mdl_lsgst_go(self):
# Was previously written to disk as 'analysis.model'
return pygsti.gaugeopt_to_target(self.mdl_lsgst, self.model, {'spam': 1.0})