You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this while refactoring some unit tests to shift away from using legacy modelpacks. As part of that change I also for different reasons thought it would be good to switch to a 'full TP' parameterized model for the target models used in some of the unit tests. In doing so I discovered that LGST (which is tested in test_core.py) doesn't actually work when using a 'full TP' parameterized model as the target model. Here is a minimal working example:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[18], line 1
----> 1 pygsti.algorithms.core.run_lgst(ds, smq1Q_XY.prep_fiducials(), smq1Q_XY.meas_fiducials(), target_model=test_model)
File ~\Documents\pyGSTi_new_FPR_method\pygsti\algorithms\core.py:282, in run_lgst(dataset, prep_fiducials, effect_fiducials, target_model, op_labels, op_label_aliases, guess_model_for_gauge, svd_truncate_to, verbosity)
279 for i in range(guessTrunc): guessPj[i, i] = 1.0
280 # guessPjt = _np.transpose(guessPj) # shape = (guessTrunc, K)
--> 282 AMat = _construct_a(effect_fiducials, guess_model_for_gauge) # shape = (nESpecs, gsDim)
283 # AMat_p = _np.dot( guessPjt, _np.dot(Ud, AMat)) #truncate Evec => Evec', shape (guessTrunc,gsDim) (square!)
285 BMat = _construct_b(prep_fiducials, guess_model_for_gauge) # shape = (gsDim, nRhoSpecs)
File ~\Documents\pyGSTi_new_FPR_method\pygsti\algorithms\core.py:455, in _construct_a(effect_fiducials, model)
453 for i in range(dim): # propagate each basis initial state
454 basis_st[i] = 1.0
--> 455 model.preps['rho_LGST_tmp'] = basis_st
456 probs = model.probabilities(_circuits.Circuit(('rho_LGST_tmp',), line_labels=estr.line_labels) + estr)
457 A[eoff:eoff + povmLen, i] = [probs[(ol,)] for ol in model.povms[povmLbl]] # CHECK will this work?
File ~\Documents\pyGSTi_new_FPR_method\pygsti\models\memberdict.py:334, in OrderedMemberDict.__setitem__(self, key, value)
329 new_item = None # keep track of newly set item for later
331 else:
332 #otherwise, we've been given a non-ModelMember-object that doesn't
333 # exist yet, so use default creation flags to make one:
--> 334 obj = self.cast_to_model_member(value)
336 if obj is None:
337 raise ValueError("Cannot set a value of type: ", type(value))
File ~\Documents\pyGSTi_new_FPR_method\pygsti\models\memberdict.py:264, in OrderedMemberDict.cast_to_model_member(self, value)
262 if self.flags['cast_to_type'] == "state":
263 obj = _state.StaticState(value, basis, evotype, state_space)
--> 264 obj = _state.convert(obj, self.default_param, basis)
265 elif self.flags['cast_to_type'] == "operation":
266 obj = _op.StaticArbitraryOp(value, None, evotype, state_space)
File ~\Documents\pyGSTi_new_FPR_method\pygsti\modelmembers\states\__init__.py:291, in convert(state, to_type, basis, ideal_state, flatten_structure)
287 except ValueError as e:
288 #_warnings.warn('Failed to convert state to type %s with error: %s' % (to_type, e))
289 error_msgs[to_type] = str(e) # try next to_type
--> 291 raise ValueError("Could not convert state to to type(s): %s\n%s" % (str(to_types), str(error_msgs)))
ValueError: Could not convert state to to type(s): ['full TP']
{'full TP': 'Could not create a state of type(s) full TP from the given superket vector!'}
As indicated in the traceback the issue looks to be in the function _construct_a which does a propagation of basis vectors, but appears to do so in such a way that it also propagates the basis element for the identity, which the conversion code for switching to TP states doesn't like. This should be fixable with some appropriate logic for detecting when we have a TP model and avoiding the propagation of the identity element in those cases.
This is a bit of a rabbit hole with respect to the refactor and fixes to the unit tests which led to discovering this, and those are higher priority at the moment so bookmarking this for the future.
Environment (please complete the following information):
pyGSTi version: develop
python version 3.9
OS Windows 11
The text was updated successfully, but these errors were encountered:
I ran into this while refactoring some unit tests to shift away from using legacy modelpacks. As part of that change I also for different reasons thought it would be good to switch to a 'full TP' parameterized model for the target models used in some of the unit tests. In doing so I discovered that LGST (which is tested in test_core.py) doesn't actually work when using a 'full TP' parameterized model as the target model. Here is a minimal working example:
This produces the traceback:
As indicated in the traceback the issue looks to be in the function _construct_a which does a propagation of basis vectors, but appears to do so in such a way that it also propagates the basis element for the identity, which the conversion code for switching to TP states doesn't like. This should be fixable with some appropriate logic for detecting when we have a TP model and avoiding the propagation of the identity element in those cases.
This is a bit of a rabbit hole with respect to the refactor and fixes to the unit tests which led to discovering this, and those are higher priority at the moment so bookmarking this for the future.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: