pyGSTi 0.9.12__cp39-cp39-win32.whl → 0.9.13__cp39-cp39-win32.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. pyGSTi-0.9.13.dist-info/METADATA +197 -0
  2. {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/RECORD +211 -220
  3. {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/WHEEL +1 -1
  4. pygsti/_version.py +2 -2
  5. pygsti/algorithms/contract.py +1 -1
  6. pygsti/algorithms/core.py +62 -35
  7. pygsti/algorithms/fiducialpairreduction.py +95 -110
  8. pygsti/algorithms/fiducialselection.py +17 -8
  9. pygsti/algorithms/gaugeopt.py +2 -2
  10. pygsti/algorithms/germselection.py +87 -77
  11. pygsti/algorithms/mirroring.py +0 -388
  12. pygsti/algorithms/randomcircuit.py +165 -1333
  13. pygsti/algorithms/rbfit.py +0 -234
  14. pygsti/baseobjs/basis.py +94 -396
  15. pygsti/baseobjs/errorgenbasis.py +0 -132
  16. pygsti/baseobjs/errorgenspace.py +0 -10
  17. pygsti/baseobjs/label.py +52 -168
  18. pygsti/baseobjs/opcalc/fastopcalc.cp39-win32.pyd +0 -0
  19. pygsti/baseobjs/opcalc/fastopcalc.pyx +2 -2
  20. pygsti/baseobjs/polynomial.py +13 -595
  21. pygsti/baseobjs/protectedarray.py +72 -132
  22. pygsti/baseobjs/statespace.py +1 -0
  23. pygsti/circuits/__init__.py +1 -1
  24. pygsti/circuits/circuit.py +753 -504
  25. pygsti/circuits/circuitconstruction.py +0 -4
  26. pygsti/circuits/circuitlist.py +47 -5
  27. pygsti/circuits/circuitparser/__init__.py +8 -8
  28. pygsti/circuits/circuitparser/fastcircuitparser.cp39-win32.pyd +0 -0
  29. pygsti/circuits/circuitstructure.py +3 -3
  30. pygsti/circuits/cloudcircuitconstruction.py +27 -14
  31. pygsti/data/datacomparator.py +4 -9
  32. pygsti/data/dataset.py +51 -46
  33. pygsti/data/hypothesistest.py +0 -7
  34. pygsti/drivers/bootstrap.py +0 -49
  35. pygsti/drivers/longsequence.py +46 -10
  36. pygsti/evotypes/basereps_cython.cp39-win32.pyd +0 -0
  37. pygsti/evotypes/chp/opreps.py +0 -61
  38. pygsti/evotypes/chp/statereps.py +0 -32
  39. pygsti/evotypes/densitymx/effectcreps.cpp +9 -10
  40. pygsti/evotypes/densitymx/effectreps.cp39-win32.pyd +0 -0
  41. pygsti/evotypes/densitymx/effectreps.pyx +1 -1
  42. pygsti/evotypes/densitymx/opreps.cp39-win32.pyd +0 -0
  43. pygsti/evotypes/densitymx/opreps.pyx +2 -2
  44. pygsti/evotypes/densitymx/statereps.cp39-win32.pyd +0 -0
  45. pygsti/evotypes/densitymx/statereps.pyx +1 -1
  46. pygsti/evotypes/densitymx_slow/effectreps.py +7 -23
  47. pygsti/evotypes/densitymx_slow/opreps.py +16 -23
  48. pygsti/evotypes/densitymx_slow/statereps.py +10 -3
  49. pygsti/evotypes/evotype.py +39 -2
  50. pygsti/evotypes/stabilizer/effectreps.cp39-win32.pyd +0 -0
  51. pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
  52. pygsti/evotypes/stabilizer/opreps.cp39-win32.pyd +0 -0
  53. pygsti/evotypes/stabilizer/opreps.pyx +0 -4
  54. pygsti/evotypes/stabilizer/statereps.cp39-win32.pyd +0 -0
  55. pygsti/evotypes/stabilizer/statereps.pyx +1 -5
  56. pygsti/evotypes/stabilizer/termreps.cp39-win32.pyd +0 -0
  57. pygsti/evotypes/stabilizer/termreps.pyx +0 -7
  58. pygsti/evotypes/stabilizer_slow/effectreps.py +0 -22
  59. pygsti/evotypes/stabilizer_slow/opreps.py +0 -4
  60. pygsti/evotypes/stabilizer_slow/statereps.py +0 -4
  61. pygsti/evotypes/statevec/effectreps.cp39-win32.pyd +0 -0
  62. pygsti/evotypes/statevec/effectreps.pyx +1 -1
  63. pygsti/evotypes/statevec/opreps.cp39-win32.pyd +0 -0
  64. pygsti/evotypes/statevec/opreps.pyx +2 -2
  65. pygsti/evotypes/statevec/statereps.cp39-win32.pyd +0 -0
  66. pygsti/evotypes/statevec/statereps.pyx +1 -1
  67. pygsti/evotypes/statevec/termreps.cp39-win32.pyd +0 -0
  68. pygsti/evotypes/statevec/termreps.pyx +0 -7
  69. pygsti/evotypes/statevec_slow/effectreps.py +0 -3
  70. pygsti/evotypes/statevec_slow/opreps.py +0 -5
  71. pygsti/extras/__init__.py +0 -1
  72. pygsti/extras/drift/signal.py +1 -1
  73. pygsti/extras/drift/stabilityanalyzer.py +3 -1
  74. pygsti/extras/interpygate/__init__.py +12 -0
  75. pygsti/extras/interpygate/core.py +0 -36
  76. pygsti/extras/interpygate/process_tomography.py +44 -10
  77. pygsti/extras/rpe/rpeconstruction.py +0 -2
  78. pygsti/forwardsims/__init__.py +1 -0
  79. pygsti/forwardsims/forwardsim.py +50 -93
  80. pygsti/forwardsims/mapforwardsim.py +78 -20
  81. pygsti/forwardsims/mapforwardsim_calc_densitymx.cp39-win32.pyd +0 -0
  82. pygsti/forwardsims/mapforwardsim_calc_densitymx.pyx +65 -66
  83. pygsti/forwardsims/mapforwardsim_calc_generic.py +91 -13
  84. pygsti/forwardsims/matrixforwardsim.py +72 -17
  85. pygsti/forwardsims/termforwardsim.py +9 -111
  86. pygsti/forwardsims/termforwardsim_calc_stabilizer.cp39-win32.pyd +0 -0
  87. pygsti/forwardsims/termforwardsim_calc_statevec.cp39-win32.pyd +0 -0
  88. pygsti/forwardsims/termforwardsim_calc_statevec.pyx +0 -651
  89. pygsti/forwardsims/torchfwdsim.py +265 -0
  90. pygsti/forwardsims/weakforwardsim.py +2 -2
  91. pygsti/io/__init__.py +1 -2
  92. pygsti/io/mongodb.py +0 -2
  93. pygsti/io/stdinput.py +6 -22
  94. pygsti/layouts/copalayout.py +10 -12
  95. pygsti/layouts/distlayout.py +0 -40
  96. pygsti/layouts/maplayout.py +103 -25
  97. pygsti/layouts/matrixlayout.py +99 -60
  98. pygsti/layouts/prefixtable.py +1534 -52
  99. pygsti/layouts/termlayout.py +1 -1
  100. pygsti/modelmembers/instruments/instrument.py +3 -3
  101. pygsti/modelmembers/instruments/tpinstrument.py +2 -2
  102. pygsti/modelmembers/modelmember.py +0 -17
  103. pygsti/modelmembers/operations/__init__.py +3 -4
  104. pygsti/modelmembers/operations/affineshiftop.py +206 -0
  105. pygsti/modelmembers/operations/composederrorgen.py +1 -1
  106. pygsti/modelmembers/operations/composedop.py +1 -24
  107. pygsti/modelmembers/operations/denseop.py +5 -5
  108. pygsti/modelmembers/operations/eigpdenseop.py +2 -2
  109. pygsti/modelmembers/operations/embeddederrorgen.py +1 -1
  110. pygsti/modelmembers/operations/embeddedop.py +0 -1
  111. pygsti/modelmembers/operations/experrorgenop.py +5 -2
  112. pygsti/modelmembers/operations/fullarbitraryop.py +1 -0
  113. pygsti/modelmembers/operations/fullcptpop.py +2 -2
  114. pygsti/modelmembers/operations/fulltpop.py +28 -6
  115. pygsti/modelmembers/operations/fullunitaryop.py +5 -4
  116. pygsti/modelmembers/operations/lindbladcoefficients.py +93 -78
  117. pygsti/modelmembers/operations/lindbladerrorgen.py +268 -441
  118. pygsti/modelmembers/operations/linearop.py +7 -27
  119. pygsti/modelmembers/operations/opfactory.py +1 -1
  120. pygsti/modelmembers/operations/repeatedop.py +1 -24
  121. pygsti/modelmembers/operations/staticstdop.py +1 -1
  122. pygsti/modelmembers/povms/__init__.py +3 -3
  123. pygsti/modelmembers/povms/basepovm.py +7 -36
  124. pygsti/modelmembers/povms/complementeffect.py +4 -9
  125. pygsti/modelmembers/povms/composedeffect.py +0 -320
  126. pygsti/modelmembers/povms/computationaleffect.py +1 -1
  127. pygsti/modelmembers/povms/computationalpovm.py +3 -1
  128. pygsti/modelmembers/povms/effect.py +3 -5
  129. pygsti/modelmembers/povms/marginalizedpovm.py +3 -81
  130. pygsti/modelmembers/povms/tppovm.py +74 -2
  131. pygsti/modelmembers/states/__init__.py +2 -5
  132. pygsti/modelmembers/states/composedstate.py +0 -317
  133. pygsti/modelmembers/states/computationalstate.py +3 -3
  134. pygsti/modelmembers/states/cptpstate.py +4 -4
  135. pygsti/modelmembers/states/densestate.py +10 -8
  136. pygsti/modelmembers/states/fullpurestate.py +0 -24
  137. pygsti/modelmembers/states/purestate.py +1 -1
  138. pygsti/modelmembers/states/state.py +5 -6
  139. pygsti/modelmembers/states/tpstate.py +28 -10
  140. pygsti/modelmembers/term.py +3 -6
  141. pygsti/modelmembers/torchable.py +50 -0
  142. pygsti/modelpacks/_modelpack.py +1 -1
  143. pygsti/modelpacks/smq1Q_ZN.py +3 -1
  144. pygsti/modelpacks/smq2Q_XXYYII.py +2 -1
  145. pygsti/modelpacks/smq2Q_XY.py +3 -3
  146. pygsti/modelpacks/smq2Q_XYI.py +2 -2
  147. pygsti/modelpacks/smq2Q_XYICNOT.py +3 -3
  148. pygsti/modelpacks/smq2Q_XYICPHASE.py +3 -3
  149. pygsti/modelpacks/smq2Q_XYXX.py +1 -1
  150. pygsti/modelpacks/smq2Q_XYZICNOT.py +3 -3
  151. pygsti/modelpacks/smq2Q_XYZZ.py +1 -1
  152. pygsti/modelpacks/stdtarget.py +0 -121
  153. pygsti/models/cloudnoisemodel.py +1 -2
  154. pygsti/models/explicitcalc.py +3 -3
  155. pygsti/models/explicitmodel.py +3 -13
  156. pygsti/models/fogistore.py +5 -3
  157. pygsti/models/localnoisemodel.py +1 -2
  158. pygsti/models/memberdict.py +0 -12
  159. pygsti/models/model.py +801 -68
  160. pygsti/models/modelconstruction.py +4 -4
  161. pygsti/models/modelnoise.py +2 -2
  162. pygsti/models/modelparaminterposer.py +1 -1
  163. pygsti/models/oplessmodel.py +1 -1
  164. pygsti/models/qutrit.py +15 -14
  165. pygsti/objectivefns/objectivefns.py +75 -140
  166. pygsti/objectivefns/wildcardbudget.py +2 -7
  167. pygsti/optimize/__init__.py +1 -0
  168. pygsti/optimize/arraysinterface.py +28 -0
  169. pygsti/optimize/customcg.py +0 -12
  170. pygsti/optimize/customlm.py +129 -323
  171. pygsti/optimize/customsolve.py +2 -2
  172. pygsti/optimize/optimize.py +0 -84
  173. pygsti/optimize/simplerlm.py +841 -0
  174. pygsti/optimize/wildcardopt.py +19 -598
  175. pygsti/protocols/confidenceregionfactory.py +28 -14
  176. pygsti/protocols/estimate.py +31 -14
  177. pygsti/protocols/gst.py +238 -142
  178. pygsti/protocols/modeltest.py +19 -12
  179. pygsti/protocols/protocol.py +9 -37
  180. pygsti/protocols/rb.py +450 -79
  181. pygsti/protocols/treenode.py +8 -2
  182. pygsti/protocols/vb.py +108 -206
  183. pygsti/protocols/vbdataframe.py +1 -1
  184. pygsti/report/factory.py +0 -15
  185. pygsti/report/fogidiagram.py +1 -17
  186. pygsti/report/modelfunction.py +12 -3
  187. pygsti/report/mpl_colormaps.py +1 -1
  188. pygsti/report/plothelpers.py +11 -3
  189. pygsti/report/report.py +16 -0
  190. pygsti/report/reportables.py +41 -37
  191. pygsti/report/templates/offline/pygsti_dashboard.css +6 -0
  192. pygsti/report/templates/offline/pygsti_dashboard.js +12 -0
  193. pygsti/report/workspace.py +2 -14
  194. pygsti/report/workspaceplots.py +328 -505
  195. pygsti/tools/basistools.py +9 -36
  196. pygsti/tools/edesigntools.py +124 -96
  197. pygsti/tools/fastcalc.cp39-win32.pyd +0 -0
  198. pygsti/tools/fastcalc.pyx +35 -81
  199. pygsti/tools/internalgates.py +151 -15
  200. pygsti/tools/jamiolkowski.py +5 -5
  201. pygsti/tools/lindbladtools.py +19 -11
  202. pygsti/tools/listtools.py +0 -114
  203. pygsti/tools/matrixmod2.py +1 -1
  204. pygsti/tools/matrixtools.py +173 -339
  205. pygsti/tools/nameddict.py +1 -1
  206. pygsti/tools/optools.py +154 -88
  207. pygsti/tools/pdftools.py +0 -25
  208. pygsti/tools/rbtheory.py +3 -320
  209. pygsti/tools/slicetools.py +64 -12
  210. pyGSTi-0.9.12.dist-info/METADATA +0 -157
  211. pygsti/algorithms/directx.py +0 -711
  212. pygsti/evotypes/qibo/__init__.py +0 -33
  213. pygsti/evotypes/qibo/effectreps.py +0 -78
  214. pygsti/evotypes/qibo/opreps.py +0 -376
  215. pygsti/evotypes/qibo/povmreps.py +0 -98
  216. pygsti/evotypes/qibo/statereps.py +0 -174
  217. pygsti/extras/rb/__init__.py +0 -13
  218. pygsti/extras/rb/benchmarker.py +0 -957
  219. pygsti/extras/rb/dataset.py +0 -378
  220. pygsti/extras/rb/io.py +0 -814
  221. pygsti/extras/rb/simulate.py +0 -1020
  222. pygsti/io/legacyio.py +0 -385
  223. pygsti/modelmembers/povms/denseeffect.py +0 -142
  224. {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/LICENSE +0 -0
  225. {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp39-cp39-win32
5
5
 
pygsti/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.9.12'
16
- __version_tuple__ = version_tuple = (0, 9, 12)
15
+ __version__ = version = '0.9.13'
16
+ __version_tuple__ = version_tuple = (0, 9, 13)
@@ -358,7 +358,7 @@ def _contract_to_valid_spam(model, verbosity=0):
358
358
 
359
359
  # ** assumption: only the first vector element of pauli vectors has nonzero trace
360
360
  dummyVec = _np.zeros((model.dim, 1), 'd'); dummyVec[0, 0] = 1.0
361
- firstElTrace = _np.real(_tools.trace(_tools.ppvec_to_stdmx(dummyVec))) # == sqrt(2)**nQubits
361
+ firstElTrace = _np.real(_np.trace(_tools.ppvec_to_stdmx(dummyVec))) # == sqrt(2)**nQubits
362
362
  diff = 0
363
363
 
364
364
  # rhoVec must be positive semidefinite and trace = 1
pygsti/algorithms/core.py CHANGED
@@ -31,8 +31,9 @@ from pygsti.modelmembers import instruments as _instrument
31
31
  from pygsti.modelmembers import states as _state
32
32
  from pygsti.circuits.circuitlist import CircuitList as _CircuitList
33
33
  from pygsti.baseobjs.resourceallocation import ResourceAllocation as _ResourceAllocation
34
- from pygsti.optimize.customlm import CustomLMOptimizer as _CustomLMOptimizer
35
- from pygsti.optimize.customlm import Optimizer as _Optimizer
34
+ from pygsti.optimize.simplerlm import Optimizer as _Optimizer, SimplerLMOptimizer as _SimplerLMOptimizer
35
+ from pygsti import forwardsims as _fwdsims
36
+ from pygsti import layouts as _layouts
36
37
 
37
38
  _dummy_profiler = _DummyProfiler()
38
39
 
@@ -53,7 +54,7 @@ FLOATSIZE = 8 # TODO: better way?
53
54
 
54
55
 
55
56
  def run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels=None, op_label_aliases=None,
56
- guess_model_for_gauge=None, svd_truncate_to=None, verbosity=0):
57
+ guess_model_for_gauge=None, svd_truncate_to=None, verbosity=0, check=True):
57
58
  """
58
59
  Performs Linear-inversion Gate Set Tomography on the dataset.
59
60
 
@@ -102,6 +103,10 @@ def run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels=
102
103
  verbosity : int, optional
103
104
  How much detail to send to stdout.
104
105
 
106
+ check : bool, optional
107
+ Specifies whether we perform computationally expensive assertion checks.
108
+ Computationally cheap assertions will always be checked.
109
+
105
110
  Returns
106
111
  -------
107
112
  Model
@@ -193,8 +198,8 @@ def run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels=
193
198
  "or decrease svd_truncate_to" % (rankAB, ABMat_p.shape[0]))
194
199
 
195
200
  invABMat_p = _np.dot(Pjt, _np.dot(_np.diag(1.0 / s), Pj)) # (trunc,trunc)
196
- # check inverse is correct (TODO: comment out later)
197
- assert(_np.linalg.norm(_np.linalg.inv(ABMat_p) - invABMat_p) < 1e-8)
201
+ if check:
202
+ assert(_np.linalg.norm(_np.linalg.inv(ABMat_p) - invABMat_p) < 1e-8)
198
203
  assert(len((_np.isnan(invABMat_p)).nonzero()[0]) == 0)
199
204
 
200
205
  if svd_truncate_to is None or svd_truncate_to == target_model.dim: # use target sslbls and basis
@@ -231,10 +236,6 @@ def run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels=
231
236
  assert(len(X_ps) == 1); X_p = X_ps[0] # shape (nESpecs, nRhoSpecs)
232
237
  lgstModel.operations[opLabel] = _op.FullArbitraryOp(_np.dot(invABMat_p, X_p)) # shape (trunc,trunc)
233
238
 
234
- #print "DEBUG: X(%s) = \n" % opLabel,X
235
- #print "DEBUG: Evals(X) = \n",_np.linalg.eigvals(X)
236
- #print "DEBUG: %s = \n" % opLabel,lgstModel[ opLabel ]
237
-
238
239
  #Form POVMs
239
240
  for povmLabel in povmLabelsToEstimate:
240
241
  povm_effects = []
@@ -247,7 +248,10 @@ def run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels=
247
248
  circuit = rhostr
248
249
  dsRow_fractions = dataset[circuit].fractions
249
250
  # outcome labels should just be effect labels (no instruments!)
250
- EVec[0, i] = dsRow_fractions[(effectLabel,)]
251
+ # when using a sparse data set format it might not be the case
252
+ # that all effect labels are present (only ones with non-zero counts are)
253
+ # so return 0 for the fraction in that case.
254
+ EVec[0, i] = dsRow_fractions.get((effectLabel,), 0)
251
255
  EVec_p = _np.dot(_np.dot(EVec, Vd), Pj) # truncate Evec => Evec', shape (1,trunc)
252
256
  povm_effects.append((effectLabel, _np.transpose(EVec_p)))
253
257
  lgstModel.povms[povmLabel] = _povm.UnconstrainedPOVM(povm_effects, evotype='default')
@@ -262,7 +266,10 @@ def run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels=
262
266
  # try without prepLabel since it will be the default
263
267
  circuit = estr
264
268
  dsRow_fractions = dataset[circuit].fractions
265
- rhoVec[eoff:eoff + povmLen, 0] = [dsRow_fractions[(ol,)] for ol in target_model.povms[povmLbl]]
269
+ # when using a sparse data set format it might not be the case
270
+ # that all effect labels are present (only ones with non-zero counts are)
271
+ # so return 0 for the fraction in that case.
272
+ rhoVec[eoff:eoff + povmLen, 0] = [dsRow_fractions.get((ol,),0) for ol in target_model.povms[povmLbl]]
266
273
  eoff += povmLen
267
274
  rhoVec_p = _np.dot(Pjt, _np.dot(Ud, rhoVec)) # truncate rhoVec => rhoVec', shape (trunc, 1)
268
275
  rhoVec_p = _np.dot(invABMat_p, rhoVec_p)
@@ -394,7 +401,7 @@ def _construct_ab(prep_fiducials, effect_fiducials, model, dataset, op_label_ali
394
401
  for j, rhostr in enumerate(prep_fiducials):
395
402
  opLabelString = rhostr + estr # LEXICOGRAPHICAL VS MATRIX ORDER
396
403
  dsStr = opLabelString.replace_layers_with_aliases(op_label_aliases)
397
- expd_circuit_outcomes = opLabelString.expand_instruments_and_separate_povm(model)
404
+ expd_circuit_outcomes = model.expand_instruments_and_separate_povm(opLabelString)
398
405
  assert(len(expd_circuit_outcomes) == 1), "No instruments are allowed in LGST fiducials!"
399
406
  unique_key = next(iter(expd_circuit_outcomes.keys()))
400
407
  outcomes = expd_circuit_outcomes[unique_key]
@@ -423,7 +430,7 @@ def _construct_x_matrix(prep_fiducials, effect_fiducials, model, op_label_tuple,
423
430
  for j, rhostr in enumerate(prep_fiducials):
424
431
  opLabelString = rhostr + _circuits.Circuit(op_label_tuple, line_labels=rhostr.line_labels) + estr
425
432
  dsStr = opLabelString.replace_layers_with_aliases(op_label_aliases)
426
- expd_circuit_outcomes = opLabelString.expand_instruments_and_separate_povm(model)
433
+ expd_circuit_outcomes = model.expand_instruments_and_separate_povm(opLabelString)
427
434
  dsRow_fractions = dataset[dsStr].fractions
428
435
  assert(len(expd_circuit_outcomes) == nVariants)
429
436
 
@@ -444,6 +451,10 @@ def _construct_a(effect_fiducials, model):
444
451
  dim = model.dim
445
452
  A = _np.empty((n, dim))
446
453
  # st = _np.empty(dim, 'd')
454
+
455
+ # Remove restrictions on state param types for computation
456
+ old_default_param = model.preps.default_param
457
+ model.preps.default_param = "full"
447
458
 
448
459
  basis_st = _np.zeros((dim, 1), 'd'); eoff = 0
449
460
  for k, (estr, povmLbl, povmLen) in enumerate(zip(effect_fiducials, povmLbls, povmLens)):
@@ -459,6 +470,9 @@ def _construct_a(effect_fiducials, model):
459
470
  basis_st[i] = 0.0
460
471
 
461
472
  eoff += povmLen
473
+
474
+ model.preps.default_param = old_default_param
475
+
462
476
  return A
463
477
 
464
478
 
@@ -468,6 +482,10 @@ def _construct_b(prep_fiducials, model):
468
482
  B = _np.empty((dim, n))
469
483
  # st = _np.empty(dim, 'd')
470
484
 
485
+ # Remove restrictions on POVM param types for computation
486
+ old_default_param = model.povms.default_param
487
+ model.povms.default_param = "full"
488
+
471
489
  #Create POVM of vector units
472
490
  basis_Es = []
473
491
  for i in range(dim): # propagate each basis initial state
@@ -484,6 +502,8 @@ def _construct_b(prep_fiducials, model):
484
502
  B[:, k] = [probs[("E%d" % i,)] for i in range(dim)] # CHECK will this work?
485
503
 
486
504
  del model.povms['M_LGST_tmp_povm']
505
+ model.povms.default_param = old_default_param
506
+
487
507
  return B
488
508
 
489
509
 
@@ -598,7 +618,7 @@ def run_gst_fit_simple(dataset, start_model, circuits, optimizer, objective_func
598
618
  model : Model
599
619
  the best-fit model.
600
620
  """
601
- optimizer = optimizer if isinstance(optimizer, _Optimizer) else _CustomLMOptimizer.cast(optimizer)
621
+ optimizer = optimizer if isinstance(optimizer, _Optimizer) else _SimplerLMOptimizer.cast(optimizer)
602
622
  objective_function_builder = _objfns.ObjectiveFunctionBuilder.cast(objective_function_builder)
603
623
  array_types = optimizer.array_types + \
604
624
  objective_function_builder.compute_array_types(optimizer.called_objective_methods, start_model.sim)
@@ -645,7 +665,7 @@ def run_gst_fit(mdc_store, optimizer, objective_function_builder, verbosity=0):
645
665
  objfn_store : MDCObjectiveFunction
646
666
  the objective function and store containing the best-fit model evaluated at the best-fit point.
647
667
  """
648
- optimizer = optimizer if isinstance(optimizer, _Optimizer) else _CustomLMOptimizer.cast(optimizer)
668
+ optimizer = optimizer if isinstance(optimizer, _Optimizer) else _SimplerLMOptimizer.cast(optimizer)
649
669
  comm = mdc_store.resource_alloc.comm
650
670
  profiler = mdc_store.resource_alloc.profiler
651
671
  printer = VerbosityPrinter.create_printer(verbosity, comm)
@@ -658,16 +678,10 @@ def run_gst_fit(mdc_store, optimizer, objective_function_builder, verbosity=0):
658
678
  if _np.linalg.norm(mdc_store.model.to_vector() - v_cmp) > 1e-6:
659
679
  raise ValueError("MPI ERROR: *different* MC2GST start models"
660
680
  " given to different processors!") # pragma: no cover
661
-
662
- #MEM from ..baseobjs.profiler import Profiler
663
- #MEM debug_prof = Profiler(comm)
664
- #MEM debug_prof.print_memory("run_gst_fit1", True)
665
-
681
+
666
682
  if objective_function_builder is not None:
667
683
  objective_function_builder = _objfns.ObjectiveFunctionBuilder.cast(objective_function_builder)
668
- #MEM debug_prof.print_memory("run_gst_fit2", True)
669
684
  objective = objective_function_builder.build_from_store(mdc_store, printer) # (objective is *also* a store)
670
- #MEM debug_prof.print_memory("run_gst_fit3", True)
671
685
  else:
672
686
  assert(isinstance(mdc_store, _objfns.ObjectiveFunction)), \
673
687
  "When `objective_function_builder` is None, `mdc_store` must be an objective fn!"
@@ -686,14 +700,8 @@ def run_gst_fit(mdc_store, optimizer, objective_function_builder, verbosity=0):
686
700
 
687
701
  printer.log("Completed in %.1fs" % (_time.time() - tStart), 1)
688
702
 
689
- #if target_model is not None:
690
- # target_vec = target_model.to_vector()
691
- # targetErrVec = _objective_func(target_vec)
692
- # return minErrVec, soln_gs, targetErrVec
693
703
  profiler.add_time("do_mc2gst: total time", tStart)
694
- #TODO: evTree.permute_computation_to_original(minErrVec) #Doesn't work b/c minErrVec is flattened
695
- # but maybe best to just remove minErrVec from return value since this isn't very useful
696
- # anyway?
704
+
697
705
  return opt_result, objective
698
706
 
699
707
 
@@ -834,7 +842,7 @@ def iterative_gst_generator(dataset, start_model, circuit_lists,
834
842
  (an "evaluated" model-dataset-circuits store).
835
843
  """
836
844
  resource_alloc = _ResourceAllocation.cast(resource_alloc)
837
- optimizer = optimizer if isinstance(optimizer, _Optimizer) else _CustomLMOptimizer.cast(optimizer)
845
+ optimizer = optimizer if isinstance(optimizer, _Optimizer) else _SimplerLMOptimizer.cast(optimizer)
838
846
  comm = resource_alloc.comm
839
847
  profiler = resource_alloc.profiler
840
848
  printer = VerbosityPrinter.create_printer(verbosity, comm)
@@ -869,10 +877,30 @@ def iterative_gst_generator(dataset, start_model, circuit_lists,
869
877
  #The ModelDatasetCircuitsStore
870
878
  printer.log('Precomputing CircuitOutcomeProbabilityArray layouts for each iteration.', 2)
871
879
  precomp_layouts = []
880
+
881
+ #pre-compute a dictionary caching completed circuits for layout construction performance.
882
+ unique_circuits = list({ckt for circuit_list in circuit_lists for ckt in circuit_list})
883
+ if isinstance(mdl.sim, (_fwdsims.MatrixForwardSimulator, _fwdsims.MapForwardSimulator)):
884
+ precomp_layout_circuit_cache = mdl.sim.create_copa_layout_circuit_cache(unique_circuits, mdl, dataset=dataset)
885
+ else:
886
+ precomp_layout_circuit_cache = None
887
+
872
888
  for i, circuit_list in enumerate(circuit_lists):
873
889
  printer.log(f'Layout for iteration {i}', 2)
874
- precomp_layouts.append(mdl.sim.create_layout(circuit_list, dataset, resource_alloc, array_types, verbosity= printer - 1))
875
-
890
+ precomp_layouts.append(mdl.sim.create_layout(circuit_list, dataset, resource_alloc, array_types, verbosity= printer - 1,
891
+ layout_creation_circuit_cache = precomp_layout_circuit_cache))
892
+
893
+ #precompute a cache of possible outcome counts for each circuits to accelerate MDC store creation
894
+ if isinstance(mdl, _models.model.OpModel):
895
+ if precomp_layout_circuit_cache is not None: #then grab the split circuits from there.
896
+ expanded_circuit_outcome_list = mdl.bulk_expand_instruments_and_separate_povm(unique_circuits,
897
+ completed_circuits= precomp_layout_circuit_cache['completed_circuits'].values())
898
+ else:
899
+ expanded_circuit_outcome_list = mdl.bulk_expand_instruments_and_separate_povm(unique_circuits)
900
+ outcome_count_by_circuit_cache = {ckt: len(outcome_tup) for ckt,outcome_tup in zip(unique_circuits, expanded_circuit_outcome_list)}
901
+ else:
902
+ outcome_count_by_circuit_cache = {ckt: mdl.compute_num_outcomes(ckt) for ckt in unique_circuits}
903
+
876
904
  with printer.progress_logging(1):
877
905
  for i in range(starting_index, len(circuit_lists)):
878
906
  circuitsToEstimate = circuit_lists[i]
@@ -889,7 +917,8 @@ def iterative_gst_generator(dataset, start_model, circuit_lists,
889
917
  mdl.basis = start_model.basis # set basis in case of CPTP constraints (needed?)
890
918
  initial_mdc_store = _objfns.ModelDatasetCircuitsStore(mdl, dataset, circuitsToEstimate, resource_alloc,
891
919
  array_types=array_types, verbosity=printer - 1,
892
- precomp_layout = precomp_layouts[i])
920
+ precomp_layout = precomp_layouts[i],
921
+ outcome_count_by_circuit=outcome_count_by_circuit_cache)
893
922
  mdc_store = initial_mdc_store
894
923
 
895
924
  for j, obj_fn_builder in enumerate(iteration_objfn_builders):
@@ -1120,8 +1149,6 @@ def find_closest_unitary_opmx(operation_mx):
1120
1149
  # d = _np.sqrt(operation_mx.shape[0])
1121
1150
  # I = _np.identity(d)
1122
1151
 
1123
- #def getu_1q(basisVec): # 1 qubit version
1124
- # return _spl.expm( 1j * (basisVec[0]*_tools.sigmax + basisVec[1]*_tools.sigmay + basisVec[2]*_tools.sigmaz) )
1125
1152
  def _get_gate_mx_1q(basis_vec): # 1 qubit version
1126
1153
  return _tools.single_qubit_gate(basis_vec[0],
1127
1154
  basis_vec[1],