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

Bugfix Model Parameter Desync #482

Merged
merged 5 commits into from
Sep 19, 2024
Merged

Bugfix Model Parameter Desync #482

merged 5 commits into from
Sep 19, 2024

Conversation

coreyostrove
Copy link
Contributor

These changes are meant to address the concerns raised in issue #456. To summarize that issue, when manually adding model members of a model's member dictionary it was previously possible to run into scenarios where the values returned for certain public facing attributes, such as the list of parameter labels, had fallen out of sync with the current constituents of the model. In this PR this has been addressed by adding additional checks to various public facing model attributes which check whether we need to rebuild the model, and performs that rebuild if needed before returning the requested value.

This specifically adds checks to the parameters_labels, set_parameter_label, parameter_bounds and num_modeltest_params properties/methods.

Also included is an unrelated bug in the Circuit class which got caught by unit testing.

In the course of testing these changes I also discovered some unexpected and undocumented behavior related to the handling of parameter bounds during the model rebuild stage. When manually setting parameter bounds at the Model level and not at the ModelMember level these manually specified values get overwritten during the rebuild process by whatever values (if any) are present in the constituent model members. We now have a check in the rebuild process which detects when there is a non-trivial parameter bound vector for a model, and a warning is raised alerting users to this behavior and the possible need to reset any manually specified parameter bounds again at the Model level (if appropriate).

Corey Ostrove added 3 commits August 30, 2024 21:11
These changes address unexpected behavior that can occur when manually adding an operation without then manually rebuilding the parameter vector. When this happens it is possible for the Model's internal attributes to fall out of sync with those of it's child objects. Now we check for the need to rebuild the parameter vector every time.
Fixes a minor bug in circuit that was caught by unit tests.
This adds a warning for when rebuilds are performed on models with nontrivial parameter bounds, which may result in manually set bounds being overwritten.
@coreyostrove coreyostrove added this to the 0.9.13 milestone Sep 5, 2024
@coreyostrove coreyostrove self-assigned this Sep 5, 2024
@coreyostrove coreyostrove requested review from a team as code owners September 5, 2024 04:58
@coreyostrove coreyostrove requested a review from sserita September 5, 2024 04:58
Performing this pre-PR merge since this could have potentially
conflicted with fixes from #488 for parameter_labels
and #489 for IS_SIMPLE.
Copy link
Contributor

@sserita sserita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential merge conflict with #488 to resolve (which was not caught by git or the tests, apparently).

pygsti/models/model.py Outdated Show resolved Hide resolved
@sserita sserita merged commit 3e2fa7c into develop Sep 19, 2024
0 of 4 checks passed
@sserita sserita deleted the bugfix-model-parameters branch September 19, 2024 22:35
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

Successfully merging this pull request may close these issues.

2 participants