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

Gauge transformations on SPAM #378

Closed
juangmendoza19 opened this issue Dec 1, 2023 · 2 comments
Closed

Gauge transformations on SPAM #378

juangmendoza19 opened this issue Dec 1, 2023 · 2 comments
Labels
bug A bug or regression
Milestone

Comments

@juangmendoza19
Copy link

Describe the bug
When using the transform_inplace(s) method for models, I obtained a new model where only the logical operations were gauge transformed, but not the SPAM operators.

To Reproduce
Steps to reproduce the behavior:
Create your favorite non-TP gauge transformation, "T"
import your favorite model from the modelpacks, "model"

ggEl = FullGaugeGroupElement(T)
model.transform_inplace(ggEl)

Expected behavior
Either a warning message should be displayed telling the user that non-TP gauge transformations are not allowed, or the SPAM should also be transformed.

Additional context
Currently we have one if statement in modelmembers/operations/experrorgenop.py in ExpErrorgenOp.spam_transform_inplace()
"
if isinstance(s, _gaugegroup.UnitaryGaugeGroupElement)
or isinstance(s, _gaugegroup.TPSpamGaugeGroupElement):
"

which is False for non-TP matrices. Thus nothing gets done to the SPAM in this case.
I believe this condition is not tested for gates. See modelmember/operations/composedop.py ComposedOp.transform_inplace()

@juangmendoza19 juangmendoza19 added the bug A bug or regression label Dec 1, 2023
@sserita sserita added this to the 0.9.12.1 milestone Dec 2, 2023
@juangmendoza19
Copy link
Author

Update: Found out that even providing a TP matrix for T (I used the identity) in the code above

"ggEl = FullGaugeGroupElement(T)
model.transform_inplace(ggEl)"

Still evaluates

isinstance(s, _gaugegroup.TPSpamGaugeGroupElement)

as False.

sserita added a commit that referenced this issue Jan 30, 2024
@sserita
Copy link
Contributor

sserita commented Jan 30, 2024

Hi @juangmendoza19, thanks for the bug report and sorry for the slow response. I have added the same warning that checks for Unitary/TP gauge groups in LindbladErrorgen.transform_inplace() to the ExpErrorgenOp.spam_transform_inplace(), which I think satisfies your desired solution of an exception being raised.

A few other comments though: In general, non-TP gauge transformations are allowed (in that we don't check whether gauge transformations are TP or not, we just call transform_inplace() recursively on the modelmembers). While trying to reproducing this, I was able to do something like

from pygsti.models.gaugegroup import FullGaugeGroupElement
from pygsti.modelpacks import smq1Q_XYI as modelpack

T = np.diag([0.9, 1, 1, 1])
ggEl = FullGaugeGroupElement(T)
model = modelpack.target_model(gate_type='full')
model.transform_inplace(ggEl)

and the resulting model did have the SPAM modified.

This leads me to believe that you were testing a model that was not "full" parameterized, but maybe "CPTPLND"? Or perhaps just the SPAM was "CPTPLND"? In that case, a non-TP gauge transformation would have been performed on the gates, but not on the SPAM due to the if statement you mention in the issue. (But if your ops were also CPTPLND, then they should have hit the else branch in LindbladErrorgen.transform_inplace()). I could be wrong though.

Finally, with regards to your followup comment: I think this is intended behavior. Even though T is TP in your case, you created a FullGaugeGroupElement with it. That object does not automatically test for TP-ness, so you still fail the if statement.

@sserita sserita closed this as completed Jan 31, 2024
@sserita sserita added the fixed-but-not-in-release-yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label Jan 31, 2024
@sserita sserita removed the fixed-but-not-in-release-yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants