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

Update optimization to use rrule system #23

Merged
merged 21 commits into from
May 3, 2024
Merged

Conversation

lkdvos
Copy link
Member

@lkdvos lkdvos commented May 1, 2024

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.

src/algorithms/peps_opt.jl Outdated Show resolved Hide resolved
@lkdvos lkdvos requested a review from pbrehmer May 1, 2024 20:17
pbrehmer
pbrehmer previously approved these changes May 2, 2024
Copy link
Collaborator

@pbrehmer pbrehmer left a 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).

@lkdvos
Copy link
Member Author

lkdvos commented May 2, 2024

Great, I'll look into the documentation pr first, as this is probably easier to merge in that order?

@pbrehmer
Copy link
Collaborator

pbrehmer commented May 2, 2024

Yes that's a good idea, I would think it is easier to merge that way.

@lkdvos
Copy link
Member Author

lkdvos commented May 2, 2024

I'll rebase tomorrow and get this ready to merge

@lkdvos lkdvos requested a review from pbrehmer May 3, 2024 08:42
@lkdvos lkdvos merged commit 1ea6fd2 into master May 3, 2024
11 checks passed
@leburgel leburgel deleted the lb/leading_boundary_diff branch May 16, 2024 08:03
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.

3 participants