Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior of convert_effect in modelmember/povms/__init__.py. #544

Open
rileyjmurray opened this issue Feb 21, 2025 · 3 comments
Milestone

Comments

@rileyjmurray
Copy link
Contributor

I have a CPTP model, and I want to convert spam members in-place to only be TP. The following codepath gets hit in that conversion.

if not flatten_structure and isinstance(effect, ComposedPOVMEffect):
return ComposedPOVMEffect(effect.effect_vec.copy(), # don't convert (usually static) effect vec
_mm.operations.convert(effect.error_map, to_type, basis, "identity",
flatten_structure))

I don't know if the code's current behavior is intended, but it doesn't return an effect that can be fed into a TPPOVM class.

Comments, @coreyostrove and @sserita?

@rileyjmurray
Copy link
Contributor Author

Okay, I now see that I should have set flatten_structure if I wanted effects to be changed. So this isn't necessarily a bug. Can anyone think of a reason why we'd be okay with ComposedPOVMEffects inside a TPPOVM?

@coreyostrove
Copy link
Contributor

I can't think of any instance where we'd expect that to be the case and enforcing the intuitive conversion behavior is fine by me.

@rileyjmurray
Copy link
Contributor Author

Here's a minimal example, per @coreyostrove's request in chat:

from pygsti.modelpacks import smq1Q_XYI
model = smq1Q_XYI.target_model()
model.convert_members_inplace('full TP') # no error
model.convert_members_inplace('CPTPLND') # no error
model.convert_members_inplace('full TP') # error

The specific error is

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rjmurr/Documents/pygsti-general/pyGSTi/pygsti/models/explicitmodel.py", line 359, in convert_members_inplace
    self._clean_paramvec()  # param indices were probabaly updated
  File "/Users/rjmurr/Documents/pygsti-general/pyGSTi/pygsti/models/model.py", line 754, in _clean_paramvec
    self._rebuild_paramvec()
  File "/Users/rjmurr/Documents/pygsti-general/pyGSTi/pygsti/models/model.py", line 1091, in _rebuild_paramvec
    w[obj.gpindices] = obj.to_vector()
  File "/Users/rjmurr/Documents/pygsti-general/pyGSTi/pygsti/modelmembers/povms/tppovm.py", line 98, in to_vector
    assert isinstance(effect, _FullPOVMEffect)
AssertionError

@sserita sserita added this to the 0.9.15+ milestone Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants