pyGSTi 0.9.12__cp38-cp38-win32.whl → 0.9.13__cp38-cp38-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 +185 -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.cp38-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.cp38-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.cp38-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.cp38-win32.pyd +0 -0
  41. pygsti/evotypes/densitymx/effectreps.pyx +1 -1
  42. pygsti/evotypes/densitymx/opreps.cp38-win32.pyd +0 -0
  43. pygsti/evotypes/densitymx/opreps.pyx +2 -2
  44. pygsti/evotypes/densitymx/statereps.cp38-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.cp38-win32.pyd +0 -0
  51. pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
  52. pygsti/evotypes/stabilizer/opreps.cp38-win32.pyd +0 -0
  53. pygsti/evotypes/stabilizer/opreps.pyx +0 -4
  54. pygsti/evotypes/stabilizer/statereps.cp38-win32.pyd +0 -0
  55. pygsti/evotypes/stabilizer/statereps.pyx +1 -5
  56. pygsti/evotypes/stabilizer/termreps.cp38-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.cp38-win32.pyd +0 -0
  62. pygsti/evotypes/statevec/effectreps.pyx +1 -1
  63. pygsti/evotypes/statevec/opreps.cp38-win32.pyd +0 -0
  64. pygsti/evotypes/statevec/opreps.pyx +2 -2
  65. pygsti/evotypes/statevec/statereps.cp38-win32.pyd +0 -0
  66. pygsti/evotypes/statevec/statereps.pyx +1 -1
  67. pygsti/evotypes/statevec/termreps.cp38-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.cp38-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.cp38-win32.pyd +0 -0
  87. pygsti/forwardsims/termforwardsim_calc_statevec.cp38-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.cp38-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
@@ -24,6 +24,8 @@ from pygsti.baseobjs.advancedoptions import GSTAdvancedOptions as _GSTAdvancedOp
24
24
  from pygsti.models.model import Model as _Model
25
25
  from pygsti.models.modelconstruction import _create_explicit_model, create_explicit_model
26
26
  from pygsti.protocols.gst import _load_pspec_or_model
27
+ from pygsti.forwardsims import ForwardSimulator
28
+ from typing import Optional
27
29
 
28
30
  ROBUST_SUFFIX_LIST = [".robust", ".Robust", ".robust+", ".Robust+"]
29
31
  DEFAULT_BAD_FIT_THRESHOLD = 2.0
@@ -35,7 +37,8 @@ def run_model_test(model_filename_or_object,
35
37
  germs_list_or_filename, max_lengths, gauge_opt_params=None,
36
38
  advanced_options=None, comm=None, mem_limit=None,
37
39
  output_pkl=None, verbosity=2, checkpoint=None, checkpoint_path=None,
38
- disable_checkpointing= False):
40
+ disable_checkpointing=False,
41
+ simulator: Optional[ForwardSimulator.Castable]=None):
39
42
  """
40
43
  Compares a :class:`Model`'s predictions to a `DataSet` using GST-like circuits.
41
44
 
@@ -138,6 +141,11 @@ def run_model_test(model_filename_or_object,
138
141
  to disk during the course of this protocol. It is strongly recommended
139
142
  that this be kept set to False without good reason to disable the checkpoints.
140
143
 
144
+ simulator : ForwardSimulator.Castable or None
145
+ Ignored if None. If not None, then we call
146
+ fwdsim = ForwardSimulator.cast(simulator),
147
+ and we set the .sim attribute of every Model we encounter to fwdsim.
148
+
141
149
  Returns
142
150
  -------
143
151
  Results
@@ -170,6 +178,7 @@ def run_model_test(model_filename_or_object,
170
178
  if isinstance(pspec_or_model, _Model):
171
179
  target_model= pspec_or_model
172
180
  elif isinstance(pspec_or_model, _ProcessorSpec):
181
+
173
182
  target_model= create_explicit_model(pspec_or_model,
174
183
  basis= _load_model(model_filename_or_object).basis)
175
184
 
@@ -185,7 +194,9 @@ def run_model_test(model_filename_or_object,
185
194
  proto.circuit_weights = advanced_options.get('circuit_weights', None)
186
195
  proto.unreliable_ops = advanced_options.get('unreliable_ops', ['Gcnot', 'Gcphase', 'Gms', 'Gcn', 'Gcx', 'Gcz'])
187
196
 
188
- results = proto.run(data, mem_limit, comm, checkpoint=checkpoint, checkpoint_path=checkpoint_path, disable_checkpointing=disable_checkpointing)
197
+ results = proto.run(data, mem_limit, comm,
198
+ checkpoint=checkpoint, checkpoint_path=checkpoint_path, disable_checkpointing=disable_checkpointing,
199
+ simulator=simulator)
189
200
  _output_to_pickle(results, output_pkl, comm)
190
201
  return results
191
202
 
@@ -306,7 +317,8 @@ def run_long_sequence_gst(data_filename_or_set, target_model_filename_or_object,
306
317
  germs_list_or_filename, max_lengths, gauge_opt_params=None,
307
318
  advanced_options=None, comm=None, mem_limit=None,
308
319
  output_pkl=None, verbosity=2, checkpoint=None, checkpoint_path=None,
309
- disable_checkpointing = False):
320
+ disable_checkpointing=False,
321
+ simulator: Optional[ForwardSimulator.Castable]=None):
310
322
  """
311
323
  Perform long-sequence GST (LSGST).
312
324
 
@@ -439,11 +451,17 @@ def run_long_sequence_gst(data_filename_or_set, target_model_filename_or_object,
439
451
  completed iteration number appended to it before writing it to disk.
440
452
  If none, the value of {name} will be set to the name of the protocol
441
453
  being run.
454
+
442
455
  disable_checkpointing : bool, optional (default False)
443
456
  When set to True checkpoint objects will not be constructed and written
444
457
  to disk during the course of this protocol. It is strongly recommended
445
458
  that this be kept set to False without good reason to disable the checkpoints.
446
459
 
460
+ simulator : ForwardSimulator.Castable or None
461
+ Ignored if None. If not None, then we call
462
+ fwdsim = ForwardSimulator.cast(simulator),
463
+ and we set the .sim attribute of every Model we encounter to fwdsim.
464
+
447
465
  Returns
448
466
  -------
449
467
  Results
@@ -488,7 +506,9 @@ def run_long_sequence_gst(data_filename_or_set, target_model_filename_or_object,
488
506
  proto.circuit_weights = advanced_options.get('circuit_weights', None)
489
507
  proto.unreliable_ops = advanced_options.get('unreliable_ops', ['Gcnot', 'Gcphase', 'Gms', 'Gcn', 'Gcx', 'Gcz'])
490
508
 
491
- results = proto.run(data, mem_limit, comm, checkpoint=checkpoint, checkpoint_path= checkpoint_path, disable_checkpointing=disable_checkpointing)
509
+ results = proto.run(data, mem_limit, comm,
510
+ checkpoint=checkpoint, checkpoint_path= checkpoint_path, disable_checkpointing=disable_checkpointing,
511
+ simulator=simulator)
492
512
  _output_to_pickle(results, output_pkl, comm)
493
513
  return results
494
514
 
@@ -497,7 +517,8 @@ def run_long_sequence_gst_base(data_filename_or_set, target_model_filename_or_ob
497
517
  lsgst_lists, gauge_opt_params=None,
498
518
  advanced_options=None, comm=None, mem_limit=None,
499
519
  output_pkl=None, verbosity=2, checkpoint=None, checkpoint_path=None,
500
- disable_checkpointing = False):
520
+ disable_checkpointing=False,
521
+ simulator: Optional[ForwardSimulator.Castable]=None):
501
522
  """
502
523
  A more fundamental interface for performing end-to-end GST.
503
524
 
@@ -582,7 +603,12 @@ def run_long_sequence_gst_base(data_filename_or_set, target_model_filename_or_ob
582
603
  When set to True checkpoint objects will not be constructed and written
583
604
  to disk during the course of this protocol. It is strongly recommended
584
605
  that this be kept set to False without good reason to disable the checkpoints.
585
-
606
+
607
+ simulator : ForwardSimulator.Castable or None
608
+ Ignored if None. If not None, then we call
609
+ fwdsim = ForwardSimulator.cast(simulator),
610
+ and we set the .sim attribute of every Model we encounter to fwdsim.
611
+
586
612
  Returns
587
613
  -------
588
614
  Results
@@ -615,7 +641,9 @@ def run_long_sequence_gst_base(data_filename_or_set, target_model_filename_or_ob
615
641
  proto.circuit_weights = advanced_options.get('circuit_weights', None)
616
642
  proto.unreliable_ops = advanced_options.get('unreliable_ops', ['Gcnot', 'Gcphase', 'Gms', 'Gcn', 'Gcx', 'Gcz'])
617
643
 
618
- results = proto.run(data, mem_limit, comm, checkpoint=checkpoint, checkpoint_path=checkpoint_path, disable_checkpointing=disable_checkpointing)
644
+ results = proto.run(data, mem_limit, comm,
645
+ checkpoint=checkpoint, checkpoint_path=checkpoint_path, disable_checkpointing=disable_checkpointing,
646
+ simulator=simulator)
619
647
  _output_to_pickle(results, output_pkl, comm)
620
648
  return results
621
649
 
@@ -624,7 +652,8 @@ def run_stdpractice_gst(data_filename_or_set, target_model_filename_or_object, p
624
652
  meas_fiducial_list_or_filename, germs_list_or_filename, max_lengths,
625
653
  modes=('full TP','CPTPLND','Target'), gaugeopt_suite='stdgaugeopt', gaugeopt_target=None,
626
654
  models_to_test=None, comm=None, mem_limit=None, advanced_options=None, output_pkl=None,
627
- verbosity=2, checkpoint=None, checkpoint_path=None, disable_checkpointing = False):
655
+ verbosity=2, checkpoint=None, checkpoint_path=None, disable_checkpointing=False,
656
+ simulator: Optional[ForwardSimulator.Castable]=None):
628
657
  """
629
658
  Perform end-to-end GST analysis using standard practices.
630
659
 
@@ -748,6 +777,11 @@ def run_stdpractice_gst(data_filename_or_set, target_model_filename_or_object, p
748
777
  to disk during the course of this protocol. It is strongly recommended
749
778
  that this be kept set to False without good reason to disable the checkpoints.
750
779
 
780
+ simulator : ForwardSimulator.Castable or None
781
+ Ignored if None. If not None, then we call
782
+ fwdsim = ForwardSimulator.cast(simulator),
783
+ and we set the .sim attribute of every Model we encounter to fwdsim.
784
+
751
785
  Returns
752
786
  -------
753
787
  Results
@@ -791,7 +825,9 @@ def run_stdpractice_gst(data_filename_or_set, target_model_filename_or_object, p
791
825
  badfit_options=_get_badfit_options(advanced_options), verbosity=printer,
792
826
  name=advanced_options.get('estimate_label', None))
793
827
 
794
- results = proto.run(data, mem_limit, comm, checkpoint=checkpoint, checkpoint_path= checkpoint_path, disable_checkpointing=disable_checkpointing)
828
+ results = proto.run(data, mem_limit, comm,
829
+ checkpoint=checkpoint, checkpoint_path= checkpoint_path, disable_checkpointing=disable_checkpointing,
830
+ simulator=simulator)
795
831
  _output_to_pickle(results, output_pkl, comm)
796
832
  return results
797
833
 
@@ -895,7 +931,7 @@ def _get_optimizer(advanced_options, model_being_optimized):
895
931
  from pygsti.forwardsims.matrixforwardsim import MatrixForwardSimulator as _MatrixFSim
896
932
  advanced_options = advanced_options or {}
897
933
  default_fditer = 1 if isinstance(model_being_optimized.sim, _MatrixFSim) else 0
898
- optimizer = {'maxiter': advanced_options.get('max_iterations', 100000),
934
+ optimizer = {'maxiter': advanced_options.get('max_iterations', 100),
899
935
  'tol': advanced_options.get('tolerance', 1e-6),
900
936
  'fditer': advanced_options.get('finitediff_iterations', default_fditer)}
901
937
  optimizer.update(advanced_options.get('extra_lm_opts', {}))
@@ -49,11 +49,6 @@ class OpRep(_basereps.OpRep):
49
49
  def _chp_ops(self, seed_or_state=None):
50
50
  return self.base_chp_ops
51
51
 
52
- #def chp_str(self, seed_or_state=None):
53
- # op_str = '\n'.join(self.chp_ops(seed_or_state=seed_or_state))
54
- # if len(op_str) > 0: op_str += '\n'
55
- # return op_str
56
-
57
52
  def to_dense(self, on_space):
58
53
  try:
59
54
  str_ops = str(self._chp_ops())
@@ -217,63 +212,7 @@ class OpRepStochastic(OpRepRandomUnitary):
217
212
 
218
213
  super(OpRepStochastic, self).__init__(basis, _np.array(rates, 'd'), reps, seed_or_state, state_space)
219
214
 
220
- #OLD
221
- #self.basis = basis
222
- #assert (basis.name == 'pp'), "Only Pauli basis is allowed for 'chp' evotype"
223
- #
224
- #if isinstance(seed_or_state, _RandomState):
225
- # self.rand_state = seed_or_state
226
- #else:
227
- # self.rand_state = _RandomState(seed_or_state)
228
- #
229
- ##TODO: need to fix this: `basis` above functions as basis to make superoperators out of, but here we have
230
- ## a CHP stochastic op which is given a basis for the space - e.g. a dim=2 vector space for 1 qubit, so
231
- ## we need to distinguish/specify the basis better for this... and what about rate_poly_dicts (see svterm)
232
- #nqubits = state_space.num_qubits
233
- #assert(self.basis.dim == 4**nqubits), "Must have an integral number of qubits"
234
- #
235
- #std_chp_ops = _itgs.standard_gatenames_chp_conversions()
236
- #
237
- ## For CHP, need to make a Composed + EmbeddedOp for the super operators
238
- ## For lower overhead, make this directly using the rep instead of with objects
239
- #self.stochastic_superop_reps = []
240
- #for label in self.basis.labels[1:]:
241
- # combined_chp_ops = []
242
- #
243
- # for i, pauli in enumerate(label):
244
- # name = 'Gi' if pauli == "I" else 'G%spi' % pauli.lower()
245
- # chp_op = std_chp_ops[name]
246
- # chp_op_targeted = [op.replace('0', str(i)) for op in chp_op]
247
- # combined_chp_ops.extend(chp_op_targeted)
248
- #
249
- # sub_rep = OpRep(combined_chp_ops, state_space)
250
- # self.stochastic_superop_reps.append(sub_rep)
251
- #self.rates = initial_rates
252
- #super(OpRepStochastic, self).__init__([], state_space) # don't store any chp_ops in base
253
-
254
215
  def update_rates(self, rates):
255
216
  unitary_rates = [1 - sum(rates)] + list(rates)
256
217
  self.rates[:] = rates
257
218
  self.update_unitary_rates(unitary_rates)
258
-
259
- #TODO REMOVE - covered by OpRepRandomUnitary
260
- #def chp_ops(self, seed_or_state=None):
261
- # # Optionally override RNG for this call
262
- # if seed_or_state is not None:
263
- # if isinstance(seed_or_state, _np.random.RandomState):
264
- # rand_state = seed_or_state
265
- # else:
266
- # rand_state = _np.random.RandomState(seed_or_state)
267
- # else:
268
- # rand_state = self.rand_state
269
- #
270
- # rates = self.rates
271
- # all_rates = [*rates, 1.0 - sum(rates)] # Include identity so that probabilities are 1
272
- # index = rand_state.choice(self.basis.size, p=all_rates)
273
- #
274
- # # If final entry, no operation selected
275
- # if index == self.basis.size - 1:
276
- # return []
277
- #
278
- # rep = self.stochastic_superop_reps[index]
279
- # return rep._chp_ops()
@@ -40,16 +40,6 @@ class StateRep(_basereps.StateRep):
40
40
  def num_qubits(self):
41
41
  return self.state_space.num_qubits
42
42
 
43
- #REMOVE
44
- #def chp_ops(self, seed_or_state=None):
45
- # return self.base_chp_ops
46
-
47
- #REMOVE
48
- #def chp_str(self, seed_or_state=None):
49
- # op_str = '\n'.join(self.chp_ops(seed_or_state=seed_or_state))
50
- # if len(op_str) > 0: op_str += '\n'
51
- # return op_str
52
-
53
43
  def copy(self):
54
44
  return StateRep(self.chp_ops, self.state_space)
55
45
 
@@ -87,25 +77,3 @@ class StateRepComposed(StateRep):
87
77
  def actionable_staterep(self):
88
78
  state_rep = self.state_rep.actionable_staterep()
89
79
  return self.op_rep.acton(state_rep)
90
-
91
- #REMOVE
92
- # def chp_ops(self, seed_or_state=None):
93
- # return self.state_rep.chp_ops(seed_or_state=seed_or_state) \
94
- # + self.op_rep.chp_ops(seed_or_state=seed_or_state)
95
-
96
- # TODO: Untested, only support computational and composed for now
97
- #class StateRepTensorProduct(StateRep):
98
- # def __init__(self, factor_state_reps, state_space):
99
- # self.factor_reps = factor_state_reps
100
- # super(StateRepTensorProduct, self).__init__([], state_space)
101
- # self.reps_have_changed()
102
- #
103
- # def reps_have_changed(self):
104
- # chp_ops = []
105
- # current_iqubit = 0
106
- # for factor in self.factor_reps:
107
- # local_to_tp_index = {str(iloc): str(itp) for iloc, itp in
108
- # enumerate(range(current_iqubit, current_iqubit + factor.num_qubits))}
109
- # chp_ops.extend([_update_chp_op(op, local_to_tp_index) for op in self.chp_ops])
110
- # current_iqubit += factor.num_qubits
111
- # self.chp_ops = chp_ops
@@ -147,7 +147,7 @@ namespace CReps_densitymx {
147
147
  finalIndx += ((finds >> k) & 1) * 3 * base;
148
148
  base = base >> 2; // /= 4 so base == 4**(N-1-k)
149
149
  }
150
-
150
+
151
151
  //Apply result
152
152
  if(parity(finds & _zvals_int))
153
153
  ret -= _abs_elval * state->_dataptr[finalIndx]; // minus sign
@@ -157,15 +157,14 @@ namespace CReps_densitymx {
157
157
  return ret;
158
158
  }
159
159
 
160
- INT EffectCRep_Computational::parity(INT x) {
161
- // int64-bit specific
162
- x = (x & 0x00000000FFFFFFFF)^(x >> 32);
163
- x = (x & 0x000000000000FFFF)^(x >> 16);
164
- x = (x & 0x00000000000000FF)^(x >> 8);
165
- x = (x & 0x000000000000000F)^(x >> 4);
166
- x = (x & 0x0000000000000003)^(x >> 2);
167
- x = (x & 0x0000000000000001)^(x >> 1);
168
- return x & 1; // return the last bit (0 or 1)
160
+ inline INT EffectCRep_Computational::parity(INT x) {
161
+ x ^= (x >> 32);
162
+ x ^= (x >> 16);
163
+ x ^= (x >> 8);
164
+ x ^= (x >> 4);
165
+ x ^= (x >> 2);
166
+ x ^= (x >> 1);
167
+ return x & 1; // Return the last bit
169
168
  }
170
169
 
171
170
 
@@ -108,7 +108,7 @@ cdef class EffectRepTensorProduct(EffectRep):
108
108
  cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] factor_dims = \
109
109
  _np.ascontiguousarray(_np.array([fct.state_space.dim for fct in povm_factors], _np.int64))
110
110
 
111
- cdef INT dim = _np.product(factor_dims)
111
+ cdef INT dim = _np.prod(factor_dims)
112
112
  cdef INT nfactors = len(povm_factors)
113
113
  self.povm_factors = povm_factors
114
114
  self.effect_labels = effect_labels
@@ -540,7 +540,7 @@ def _compute_embedding_quantities_cachekey(state_space, target_labels, embedded_
540
540
  # final map just acts as identity w.r.t.
541
541
  labelIndices = [tensorProdBlkLabels.index(label) for label in target_labels]
542
542
  cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] action_inds = _np.array(labelIndices, _np.int64)
543
- assert(_np.product([num_basis_els[i] for i in action_inds]) == embedded_rep_dim), \
543
+ assert(_np.prod([num_basis_els[i] for i in action_inds]) == embedded_rep_dim), \
544
544
  "Embedded operation has dimension (%d) inconsistent with the given target labels (%s)" % (
545
545
  embedded_rep_dim, str(target_labels))
546
546
 
@@ -550,7 +550,7 @@ def _compute_embedding_quantities_cachekey(state_space, target_labels, embedded_
550
550
  cdef INT ncomponents_in_active_block = len(state_space.tensor_product_block_labels(active_block_index))
551
551
  cdef INT embedded_dim = embedded_rep_dim
552
552
  cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] blocksizes = \
553
- _np.array([_np.product(state_space.tensor_product_block_dimensions(k))
553
+ _np.array([_np.prod(state_space.tensor_product_block_dimensions(k))
554
554
  for k in range(nblocks)], _np.int64)
555
555
  cdef INT i, j
556
556
 
@@ -163,7 +163,7 @@ cdef class StateRepTensorProduct(StateRep):
163
163
 
164
164
  def __cinit__(self, factor_state_reps, state_space):
165
165
  self.factor_reps = factor_state_reps
166
- dim = _np.product([fct.dim for fct in self.factor_reps])
166
+ dim = _np.prod([fct.dim for fct in self.factor_reps])
167
167
  self._cinit_base(_np.zeros(dim, 'd'), state_space)
168
168
  self.reps_have_changed()
169
169
 
@@ -13,12 +13,13 @@ POVM effect representation classes for the `densitymx_slow` evolution type.
13
13
  import numpy as _np
14
14
 
15
15
  # import functools as _functools
16
- from .. import basereps as _basereps
17
16
  from pygsti.baseobjs.statespace import StateSpace as _StateSpace
18
17
  from ...tools import matrixtools as _mt
19
18
 
20
19
 
21
- class EffectRep(_basereps.EffectRep):
20
+ class EffectRep:
21
+ """Any representation of an "effect" in the sense of a POVM."""
22
+
22
23
  def __init__(self, state_space):
23
24
  self.state_space = _StateSpace.cast(state_space)
24
25
 
@@ -27,6 +28,10 @@ class EffectRep(_basereps.EffectRep):
27
28
 
28
29
 
29
30
  class EffectRepConjugatedState(EffectRep):
31
+ """
32
+ A real superket representation of an "effect" in the sense of a POVM.
33
+ Internally uses a StateRepDense object to hold the real superket.
34
+ """
30
35
 
31
36
  def __init__(self, state_rep):
32
37
  self.state_rep = state_rep
@@ -100,11 +105,6 @@ class EffectRepTensorProduct(EffectRep):
100
105
  super(EffectRepTensorProduct, self).__init__(state_space)
101
106
  self.factor_effects_have_changed()
102
107
 
103
- #TODO: fix this:
104
- #def __reduce__(self):
105
- # return (EffectRepTensorProduct,
106
- # (self.kron_array, self.factor_dims, self.nfactors, self.max_factor_dim, self.dim))
107
-
108
108
  def to_dense(self, on_space, outvec=None):
109
109
 
110
110
  if on_space not in ('minimal', 'HilbertSchmidt'):
@@ -159,22 +159,6 @@ class EffectRepTensorProduct(EffectRep):
159
159
  def factor_effects_have_changed(self):
160
160
  self._fill_fast_kron() # updates effect reps
161
161
 
162
- #def to_dense(self):
163
- # if len(self.factors) == 0: return _np.empty(0, complex if self._evotype == "statevec" else 'd')
164
- # #NOTE: moved a fast version of to_dense to replib - could use that if need a fast to_dense call...
165
- #
166
- # factorPOVMs = self.factors
167
- # ret = factorPOVMs[0][self.effectLbls[0]].to_dense()
168
- # for i in range(1, len(factorPOVMs)):
169
- # ret = _np.kron(ret, factorPOVMs[i][self.effectLbls[i]].to_dense())
170
- # return ret
171
- # elif self._evotype == "stabilizer":
172
- # # each factor is a StabilizerEffectVec
173
- # raise ValueError("Cannot convert Stabilizer tensor product effect to an array!")
174
- # # should be using effect.outcomes property...
175
- # else: # self._evotype in ("svterm","cterm")
176
- # raise NotImplementedError("to_dense() not implemented for %s evolution type" % self._evotype)
177
-
178
162
 
179
163
  class EffectRepComposed(EffectRep):
180
164
  def __init__(self, op_rep, effect_rep, op_id, state_space):
@@ -17,7 +17,6 @@ import scipy.sparse as _sps
17
17
  from scipy.sparse.linalg import LinearOperator
18
18
 
19
19
  from .statereps import StateRepDense as _StateRepDense
20
- from .. import basereps as _basereps
21
20
  from pygsti.baseobjs.statespace import StateSpace as _StateSpace
22
21
  from ...tools import basistools as _bt
23
22
  from ...tools import internalgates as _itgs
@@ -26,7 +25,11 @@ from ...tools import matrixtools as _mt
26
25
  from ...tools import optools as _ot
27
26
 
28
27
 
29
- class OpRep(_basereps.OpRep):
28
+ class OpRep:
29
+ """
30
+ A real superoperator on Hilbert-Schmidt space.
31
+ """
32
+
30
33
  def __init__(self, state_space):
31
34
  self.state_space = state_space
32
35
 
@@ -41,6 +44,10 @@ class OpRep(_basereps.OpRep):
41
44
  raise NotImplementedError()
42
45
 
43
46
  def aslinearoperator(self):
47
+ """
48
+ Return a SciPy LinearOperator that accepts superket representations of vectors
49
+ in Hilbert-Schmidt space and returns a vector of that same representation.
50
+ """
44
51
  def mv(v):
45
52
  if v.ndim == 2 and v.shape[1] == 1: v = v[:, 0]
46
53
  in_state = _StateRepDense(_np.ascontiguousarray(v, 'd'), self.state_space, None)
@@ -54,6 +61,12 @@ class OpRep(_basereps.OpRep):
54
61
 
55
62
 
56
63
  class OpRepDenseSuperop(OpRep):
64
+ """
65
+ A real superoperator on Hilbert-Schmidt space.
66
+ The operator's action (and adjoint action) work with Hermitian matrices
67
+ stored as *vectors* in their real superket representations.
68
+ """
69
+
57
70
  def __init__(self, mx, basis, state_space):
58
71
  state_space = _StateSpace.cast(state_space)
59
72
  if mx is None:
@@ -174,7 +187,7 @@ class OpRepStandard(OpRepDenseSuperop):
174
187
  state_space = _StateSpace.cast(state_space)
175
188
  assert(superop.shape[0] == state_space.dim)
176
189
 
177
- super(OpRepStandard, self).__init__(superop, state_space)
190
+ super(OpRepStandard, self).__init__(superop, basis, state_space)
178
191
 
179
192
 
180
193
  class OpRepKraus(OpRep):
@@ -257,10 +270,6 @@ class OpRepStochastic(OpRepRandomUnitary):
257
270
  self.rates[:] = rates
258
271
  self.update_unitary_rates(unitary_rates)
259
272
 
260
- #class OpRepClifford(OpRep): # TODO?
261
- # #def __init__(self, unitarymx, symplecticrep):
262
- # # pass
263
-
264
273
 
265
274
  class OpRepComposed(OpRep):
266
275
 
@@ -362,13 +371,6 @@ class OpRepEmbedded(OpRep):
362
371
  self.offset = sum(blocksizes[0:self.active_block_index])
363
372
  super(OpRepEmbedded, self).__init__(state_space)
364
373
 
365
- #def __reduce__(self):
366
- # return (DMOpRepEmbedded, (self.embedded,
367
- # self.num_basis_els, self.action_inds,
368
- # self.blocksizes, self.embeddedDim,
369
- # self.ncomponents, self.active_block_index,
370
- # self.nblocks, self.dim))
371
-
372
374
  def _acton_other_blocks_trivially(self, output_state, state):
373
375
  offset = 0
374
376
  for iBlk, blockSize in enumerate(self.blocksizes):
@@ -453,15 +455,6 @@ class OpRepExpErrorgen(OpRep):
453
455
  def exp_params(self):
454
456
  return (self.mu, self.eta, self.m_star, self.s)
455
457
 
456
- #def __reduce__(self):
457
- # if self.unitary_postfactor is None:
458
- # return (DMOpRepLindblad, (self.errorgen_rep, self.mu, self.eta, self.m_star, self.s,
459
- # _np.empty(0, 'd'), _np.empty(0, _np.int64), _np.zeros(1, _np.int64)))
460
- # else:
461
- # return (DMOpRepLindblad, (self.errorgen_rep, self.mu, self.eta, self.m_star, self.s,
462
- # self.unitary_postfactor.data, self.unitary_postfactor.indices,
463
- # self.unitary_postfactor.indptr))
464
-
465
458
  def acton(self, state):
466
459
  """ Act this gate map on an input state """
467
460
  statedata = state.data.copy() # must COPY because _custom... call below *modifies* "b" arg
@@ -14,7 +14,6 @@ import functools as _functools
14
14
 
15
15
  import numpy as _np
16
16
 
17
- from .. import basereps as _basereps
18
17
  from pygsti.baseobjs.statespace import StateSpace as _StateSpace
19
18
  from ...tools import basistools as _bt
20
19
  from ...tools import optools as _ot
@@ -25,13 +24,17 @@ except ImportError:
25
24
  _fastcalc = None
26
25
 
27
26
 
28
- class StateRep(_basereps.StateRep):
27
+ class StateRep:
28
+ """A real superket representation of an element in Hilbert-Schmidt space."""
29
+
29
30
  def __init__(self, data, state_space):
30
31
  #vec = _np.asarray(vec, dtype='d')
31
32
  assert(data.dtype == _np.dtype('d'))
32
33
  self.data = _np.require(data.copy(), requirements=['OWNDATA', 'C_CONTIGUOUS'])
33
34
  self.state_space = _StateSpace.cast(state_space)
34
- assert(len(self.data) == self.state_space.dim)
35
+ ds0 = self.data.shape[0]
36
+ assert(ds0 == self.state_space.dim)
37
+ assert(ds0 == self.data.size)
35
38
 
36
39
  def __reduce__(self):
37
40
  return (StateRep, (self.data, self.state_space), (self.data.flags.writeable,))
@@ -62,6 +65,10 @@ class StateRep(_basereps.StateRep):
62
65
 
63
66
 
64
67
  class StateRepDense(StateRep):
68
+ """
69
+ An almost-trivial wrapper around StateRep.
70
+ Implements the "base" property and defines a trivial "base_has_changed" function.
71
+ """
65
72
 
66
73
  def __init__(self, data, state_space, basis):
67
74
  #ignore basis for now (self.basis = basis in future?)
@@ -1,6 +1,7 @@
1
1
  import importlib as _importlib
2
2
 
3
3
  from . import basereps as _basereps
4
+ from pygsti.baseobjs.statespace import StateSpace as _StateSpace
4
5
 
5
6
 
6
7
  class Evotype(object):
@@ -50,10 +51,46 @@ class Evotype(object):
50
51
  }
51
52
 
52
53
  @classmethod
53
- def cast(cls, obj, default_prefer_dense_reps=False):
54
+ def cast(cls, obj, default_prefer_dense_reps=None, state_space=None):
55
+ """
56
+ Cast the specified object to an Evotype with options for default Evotype
57
+ handling.
58
+
59
+ Parameters
60
+ ----------
61
+ obj : Evotype or str
62
+ Object to cast to an Evotype. If already an Evotype the object is simply
63
+ returned. Otherwise if a string we attempt to cast it to a recognized
64
+ evotype option. If the string "default" is passed in then we determine
65
+ the type of evotype used in conjunction with the two optional kwargs below.
66
+
67
+ default_prefer_dense_reps : None or bool, optional (default None)
68
+ Flag to indicate preference for dense representation types when casting
69
+ a string. If None then there is no preference and this will be determined
70
+ by the optional state_space kwarg, if present. Otherwise if a boolean value
71
+ this selection overrides any logic based on the state space.
72
+
73
+ state_space : StateSpace, optional (default None)
74
+ If not None then the dimension of the state space is used to determine whether
75
+ or not to prefer the use of dense representation types when not already specified
76
+ by the default_prefer_dense_reps kwarg.
77
+
78
+ Returns
79
+ -------
80
+ Evotype
81
+ """
54
82
  if isinstance(obj, Evotype):
55
83
  return obj
56
- elif obj == "default":
84
+
85
+ if default_prefer_dense_reps is None:
86
+ if state_space is None:
87
+ default_prefer_dense_reps = False #reproduces legacy behavior.
88
+ else:
89
+ if not isinstance(state_space, _StateSpace):
90
+ raise ValueError('state_space must be a StateSpace object.')
91
+ default_prefer_dense_reps = False if state_space.dim > 64 else True #HARDCODED
92
+
93
+ if obj == "default":
57
94
  return Evotype(cls.default_evotype, default_prefer_dense_reps)
58
95
  else: # assume obj is a string naming an evotype
59
96
  return Evotype(str(obj), default_prefer_dense_reps)
@@ -39,10 +39,6 @@ cdef class EffectRep(_basereps_cython.EffectRep):
39
39
  def nqubits(self):
40
40
  return self.state_space.num_qubits
41
41
 
42
- #@property
43
- #def dim(self):
44
- # return 2**(self.c_effect._n) # assume "unitary evolution"-type mode
45
-
46
42
  def probability(self, StateRep state not None):
47
43
  #unnecessary (just put in signature): cdef StateRep st = <StateRep?>state
48
44
  return self.c_effect.probability(state.c_state)
@@ -40,10 +40,6 @@ cdef class OpRep(_basereps_cython.OpRep):
40
40
  def nqubits(self):
41
41
  return self.state_space.num_qubits
42
42
 
43
- #@property
44
- #def dim(self):
45
- # return 2**(self.nqubits) # assume "unitary evolution"-type mode
46
-
47
43
  def acton(self, StateRep state not None):
48
44
  cdef INT n = self.c_rep._n
49
45
  cdef INT namps = state.c_state._namps
@@ -49,10 +49,6 @@ cdef class StateRep(_basereps_cython.StateRep):
49
49
  def nqubits(self):
50
50
  return self.state_space.num_qubits
51
51
 
52
- #@property
53
- #def dim(self):
54
- # return 2**(self.c_state._n) # assume "unitary evolution"-type mode
55
-
56
52
  def actionable_staterep(self):
57
53
  # return a state rep that can be acted on by op reps or mapped to
58
54
  # a probability/amplitude by POVM effect reps.
@@ -129,7 +125,7 @@ cdef class StateRepTensorProduct(StateRep):
129
125
  def __cinit__(self, factor_state_reps, state_space):
130
126
  self.factor_reps = factor_state_reps
131
127
  n = sum([sf.nqubits for sf in self.factor_reps]) # total number of qubits
132
- np = int(_np.product([len(sf.pvectors) for sf in self.factor_reps]))
128
+ np = int(_np.prod([len(sf.pvectors) for sf in self.factor_reps]))
133
129
  self._cinit_base(_np.zeros((2 * n, 2 * n), _np.int64),
134
130
  _np.zeros((np, 2 * n), _np.int64),
135
131
  _np.ones(np, complex),