-
Notifications
You must be signed in to change notification settings - Fork 54
Bugfix reparameterize #480
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
Conversation
…s valid GLND representation for povm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just bookkeeping: Not ready for review, rerequest from me when ready.
…e subset of models GLND, CPTPLND, H+S, S, full TP all to all when converting models with no noise. There is currently no support for converting to the same type for many of these
…re failing for some reason
pygsti/baseobjs/errorgenbasis.py
Outdated
TODO: 2 qubit labels returning None when label does exist in self.labels. | ||
'(support, left_support) not in self._offsets[eetype]' returning True incorrectly | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fancy code below (now commented out) to find the index of a label was not working for 2 qubits. Temporary easy solution implemented by just calling index(). This was creating problems during the creation of 2 qubit FOGI models
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure that I implemented a similar fix for this on PR #538. Making note of this in case there are merge conflicts that need to eventually get resolved here.
if ideal_effect is not None: | ||
base_items.append((lbl, convert_effect(ideal_effect, 'static', basis, ideal_effect, flatten_structure))) | ||
else: | ||
base_items.append((lbl, convert_effect(vec, 'static', basis, idl.get(lbl, None), flatten_structure))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is code to properly collect the ideal POVM effects. Before, the ideal_effect passed in was being ignored
raise ValueError("Failed to find an errorgen such that <ideal|exp(errorgen) = <effect|") | ||
errgen_vec = _np.linalg.pinv(phys_directions) @ soln.x | ||
errorgen.from_vector(errgen_vec) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code added to find errgen parameterization for POVMs based on optimization, just like state prep was being done before, but for some reason was never implemented on POVMs. Note that the optimization variations are done over a POVM space that lacks the dumb-gauge/metagauge. To find that space we wrote the function calc_physical_subspace which does a numerical calculation of the Jacobian with respect to POVM parameters.
phys_directions = calc_physical_subspace(dense_state) | ||
|
||
#We use optimization to find the best error generator representation | ||
#we only vary physical directions, not independent error generators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as explained in the POVM init file, we added a function to identify the dumb-gauge/metagauge and move orthogonally to it. This allows for better optimization.
pygsti/models/explicitmodel.py
Outdated
@@ -340,7 +340,7 @@ def __getitem__(self, label): | |||
raise KeyError("Key %s has an invalid prefix" % label) | |||
|
|||
def convert_members_inplace(self, to_type, categories_to_convert='all', labels_to_convert='all', | |||
ideal_model=None, flatten_structure=False, set_default_gauge_group=False, cptp_truncation_tol= 1e-6): | |||
ideal_model=None, flatten_structure=False, set_default_gauge_group=False, cptp_truncation_tol= 1e-7, spam_cptp_penalty = 1e-6): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added piping for the cptp penalty factor to be used in the optimization within the SPAM convert functions discussed above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One refactor requested, and a few minor fixes while you are at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to hit Enter on my refactor request...
@juangmendoza19 and @sserita : Do either of you recall what still needs to get sorted out on this PR? I see that there is at least one merge conflict (probably from merging in develop recently) and some unresolved discussion threads above. |
Stefan’s requests above have not been implemented yet. |
…ing issues for FOGI model construction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. Happy to iterate quickly to see them resolved!
…smaller than this and perturbations along the S errgens showed up as the identity operator
@coreyostrove this looks good to me. Other than resolving any merge conflicts or failing tests, do you still have unaddressed comments? I see that Stefan has unresolved comments. Rather than try to resolve those I suggest we dismiss Stefan's review (see screenshot below) and make a GitHub issue about following up on Stefan's unresolved points later. |
One more minor change related to an errant file on my end, but after that I'm satisfied with all of this. I'll approve once that last change is made and we have confirmation that tests are still passing. |
The failing tests seem related to the proposed changes:
Fixes are hopefully straightforward. @juangmendoza19, can you investigate? |
Per the pyGSTi dev call today, we believe Juan has addressed all of Stefan's comments. All tests pass as of this moment, so I'm formally dismissing Stefan's review to remove the block from merging.
@coreyostrove all tests pass. If you approve then we can merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, @juangmendoza19! And thanks for bearing with the many changes requested during the review process.
Addressing issue #425.
convert() function has been changed for POVM elements and state preparation. They now support proper conversion from full TP to GLND parameterization. The optimization is now done over non-gauge directions, which are found through Jacobians.
This function still needs to be changed to appropriately handle other reparameterizations.
Lastly, this is not guaranteed to work for POVMs, just because the number of degrees of freedom of a POVM can be greater than the number of error generators that span TP maps for a given number of qubits. By pigeon hole principle, we may not be able to find a description for a POVM consisting of Ideal_POVM + error generators. There is an assertion to try to catch this.