Skip to content

Implement keyword selector#130

Merged
pbrehmer merged 72 commits intomasterfrom
pb-kwarg-selector
Mar 10, 2025
Merged

Implement keyword selector#130
pbrehmer merged 72 commits intomasterfrom
pb-kwarg-selector

Conversation

@pbrehmer
Copy link
Collaborator

In this PR we implement a keyword selector function which parses optimization kwargs onto the corresponding algorithm structs and outputs a PEPSOptimize to fixedpoint. This simplifies the user interface since one doesn't have to create multiple nested algorithm structs.

The same could be done also for leading_boundary since it is another frequently-used function with many algorithmic parameters.

This idea follows KrylovKit's design which supplies a user-friendly kwarg-based method and an "expert" method. See e.g. the eigselector.

@pbrehmer pbrehmer marked this pull request as draft February 12, 2025 18:05
@codecov
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/optimization/peps_optimization.jl 75.00% 7 Missing ⚠️
src/algorithms/ctmrg/projectors.jl 68.75% 5 Missing ⚠️
...rithms/optimization/fixed_point_differentiation.jl 90.90% 3 Missing ⚠️
src/Defaults.jl 85.71% 1 Missing ⚠️
src/algorithms/ctmrg/ctmrg.jl 93.75% 1 Missing ⚠️
src/algorithms/select_algorithm.jl 95.83% 1 Missing ⚠️
src/operators/infinitepepo.jl 0.00% 1 Missing ⚠️
src/utility/svd.jl 95.45% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/PEPSKit.jl 100.00% <ø> (+12.50%) ⬆️
src/algorithms/ctmrg/sequential.jl 98.36% <100.00%> (ø)
src/algorithms/ctmrg/simultaneous.jl 98.18% <100.00%> (ø)
src/algorithms/time_evolution/simpleupdate.jl 86.84% <ø> (ø)
src/algorithms/truncation/bond_truncation.jl 97.01% <ø> (ø)
src/algorithms/truncation/fullenv_truncation.jl 96.96% <ø> (ø)
src/algorithms/truncation/truncationschemes.jl 100.00% <100.00%> (ø)
src/environments/ctmrg_environments.jl 69.27% <100.00%> (ø)
src/networks/tensors.jl 62.50% <100.00%> (ø)
src/operators/transfermatrix.jl 64.86% <ø> (ø)
... and 8 more
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pbrehmer
Copy link
Collaborator Author

I will finish this up tomorrow: I want to further test around and I need to finish up the docstrings. I will then also make the tests use the kwarg-based interface since that should get rid of a few lines. Perhaps we can get this merged tomorrow :-)

@pbrehmer pbrehmer marked this pull request as ready for review February 14, 2025 14:35
@pbrehmer pbrehmer requested a review from lkdvos February 14, 2025 14:35
Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

I sadly won't have time to really look over this in detail today (and Monday is a holiday here), but I will look into it next week. Do you mind if I try out some changes and push them to your branch if I get to it?

@lkdvos lkdvos mentioned this pull request Feb 16, 2025
@pbrehmer pbrehmer requested a review from lkdvos February 18, 2025 13:56
@lkdvos
Copy link
Member

lkdvos commented Mar 10, 2025

wait, I'm in the middle of doing this, you just ruined my merge 😀

lkdvos
lkdvos previously approved these changes Mar 10, 2025
Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

I think this is now okay to merge for me. There are definitely still a couple kinks left, especially with the Krylov dimension, but I think these really deserve their own PRs anyways.

Given that this is somewhat large/opnionated PR, let's get some more reviews in: @Yue-Zhengyuan and @leburgel , do you have any more comments? (Keeping in mind that we can still make changes in follow-up PRs)

@pbrehmer
Copy link
Collaborator Author

Thanks for cleaning up the rest, looks great to me! I'd be fine with merging as is.

Regarding the Krylov dimension: I think once we have #150 ready (hopefully soon), then we can hopefully use the TensorKit rrule per default also for the :fixed mode - meaning that the Krylov dimension isn't the most pressing issue, I think.

Copy link
Member

@Yue-Zhengyuan Yue-Zhengyuan left a comment

Choose a reason for hiding this comment

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

Thanks to @pbrehmer for improving the user interface! I only have a few minor suggestions below about things more relevant to my use cases. In addition, we may also update the SU examples examples/heisenberg_evol/simpleupdate.jl and examples/hubbard_su.jl to use the new leading_boundary syntax (I can push the changes to this branch if you don't mind).

BTW, I think that the old way to run CTMRG by providing the parameters as a combined ctm_alg actually still works? Since the new syntax just helps users to combine them, so users don't have to do it by themselves.

@lkdvos
Copy link
Member

lkdvos commented Mar 10, 2025

Thanks for the comments. I would be very happy if you want to add the changes you are suggesting here

- `:fixed` : the differentiated CTMRG iteration uses a pre-computed SVD with a fixed set of gauges
- `:diffgauge` : the differentiated iteration consists of a CTMRG iteration and a subsequent gauge-fixing step such that the gauge-fixing procedure is differentiated as well
* `solver_alg::Union{KrylovKit.KrylovAlgorithm,NamedTuple}=(; alg=:$(Defaults.gradient_eigsolver)` : Eigen solver algorithm which, if supplied directly as a `KrylovKit.KrylovAlgorithm` overrides the above specified `tol`, `maxiter` and `verbosity`. Alternatively, it can be supplied via a `NamedTuple` where `alg` can be one of the following:
- `:arnoldi` : Arnoldi Krylov algorithm, see the [KrylovKit docs](https://jutho.github.io/KrylovKit.jl/stable/man/algorithms/#KrylovKit.Arnoldi) for details
Copy link
Member

Choose a reason for hiding this comment

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

More as a reminder for the future, we should enable external references when we update the documentation.

χenv = 16
svd_algs = [SVDAdjoint(; fwd_alg=TensorKit.SDD()), SVDAdjoint(; fwd_alg=IterSVD())]
projector_algs = [HalfInfiniteProjector] #, FullInfiniteProjector]
projector_algs = [:halfinfinite] #, :fullinfinite]
Copy link
Member

Choose a reason for hiding this comment

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

Kind of unrelated, but why is the full infinite projector commented out? What was the problem, and mainly, is there an issue tracking this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point: IIRC there were stability issues with the full-infinite scheme and the element-wise convergence. That was actually not the only thing where full-infinite did weird things. I'll take a quick look and file an issue!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See #152

@pbrehmer
Copy link
Collaborator Author

BTW, I think that the old way to run CTMRG by providing the parameters as a combined ctm_alg actually still works?

Indeed, the old syntax still works and its intended as the "expert" mode since that exposes all the algorithm structs at once. So if you want to use that style you can still do so.

@leburgel
Copy link
Member

Looks great overall, I really think this is a massive improvement. Left some final comments, I'm happy to actually apply the suggestions people agree with, just say so and tag me so there's no conflicts with who's working on what :)

@pbrehmer
Copy link
Collaborator Author

I can also quickly add all the remaining suggestions, thanks for the comments! :)

pbrehmer and others added 5 commits March 10, 2025 15:48
Co-authored-by: Lander Burgelman <39218680+leburgel@users.noreply.github.com>
Co-authored-by: Lander Burgelman <39218680+leburgel@users.noreply.github.com>
Co-authored-by: Lander Burgelman <39218680+leburgel@users.noreply.github.com>
@pbrehmer
Copy link
Collaborator Author

Alright, this is mergeable from my side, once the tests turn green!

@pbrehmer pbrehmer merged commit 9039367 into master Mar 10, 2025
33 checks passed
@pbrehmer pbrehmer deleted the pb-kwarg-selector branch March 10, 2025 16:30
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.

4 participants