-
Notifications
You must be signed in to change notification settings - Fork 602
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
Make templates valid Pytrees #5698
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5698 +/- ##
==========================================
- Coverage 99.67% 99.66% -0.02%
==========================================
Files 416 416
Lines 38686 38742 +56
==========================================
+ Hits 38562 38613 +51
- Misses 124 129 +5 ☔ View full report in Codecov by Sentry. |
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.
So I still think there's some issues with QDrift._flatten
/ _unflatten
. If we bind new parameters for the hamiltonian coefficients, then the decomposition should be appropriately updated. Right now it's not updated. But this might need to be resolved in tandem with the algorithms team.
But other than that issue, this is looking great 🎉
It does bring up the issue of templates being prone to unexpected edge cases. Since it seems like SymbolicOp
wasn't actually very helpful with resolving these issues, maybe we could develop a NestedTemplate
operator to help with these things. But that is definitely a task for later.
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.
👍
Feel free to modify the seed behavior of QDrift
so that it's stays None
. I approve both options.
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! The updates to assert valid will make it very simple to have one test checking for everything!
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Context:
Most templates are operations themselves. Therefore they should be valid PyTrees, but some are not.
Description of the Change:
This PR adapts the
parameters
and/orhyperparameters
, as well as the methods_flatten
and/or_unflatten
for a number of parameters.It adds
standard_validity
tests to all template test files whereassert_valid
is not being called on the respective template yet.Explicit flatten/unflatten tests are removed, because they are contained in
assert_valid
.Benefits:
Code quality/self-consistency and consistency of templates with PL functionality.
Test suite quality.
Possible Drawbacks:
Related GitHub Issues:
This helps us go forward with capturing of templates, because
primitive_bind_call
can be created in a way that is consistent with__init__
and_unflatten
.[sc-63810]