-
Notifications
You must be signed in to change notification settings - Fork 12
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
Update optimization to use rrule system #23
Conversation
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 refactor looks really great, overall it's a big improvement. Thanks!
The gradient test was broken since it wasn't yet adapted to the hook_pullback
wrapper, so I quickly repaired it. Also, the ManualIter
fixed-point differentiation had a weird convergence criterion. I changed that to make it comparable to GeometricSum
(these two approaches are kind of equivalent anyways).
Great, I'll look into the documentation pr first, as this is probably easier to merge in that order? |
Yes that's a good idea, I would think it is easier to merge that way. |
I'll rebase tomorrow and get this ready to merge |
9086899
to
bcb29fc
Compare
This is a major refactor of the optimization code to have a uniform interface.
In particular, I implemented all of the
ctmrg_gradient
functions through AD by using @pbrehmer 's implementation of the gradient and transforming them into rrules via @leburgel 's adaptation.Then, in order to be able to dynamically select which rrule to use, I added the function
hook_pullback
, which functions as a convenient interface to change the rrule algorithm through an optional keyword that can later be dispatched on in the rrule.Finally, I added some rrules for constructors/getters for InfinitePEPS and CTMRGEnv, which prevents our costfunction from yielding weird tangent types. This liquidates lots of the checks to see if the tangents are the correct type and gives a bit of a cleaner implementation. I have not played around with how robust this is, and if custom costfunctions would easily break this, but I did add a type check in the implementation of the rrules to at least detect when this is happening.