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

The callback appears to be called for linesearch iterations #724

Open
goerz opened this issue Mar 26, 2024 · 1 comment
Open

The callback appears to be called for linesearch iterations #724

goerz opened this issue Mar 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@goerz
Copy link

goerz commented Mar 26, 2024

The documentation of callback says

The callback function callback is a function which is called after every optimizer step

However, it appears to me that callback (at least for some optimizers like NLopt.LD_LBFGS()) is called for all evaluation of the loss function, which includes evaluations inside a linesearch.

See https://discourse.julialang.org/t/questionable-zygote-gradients-for-quantum-optimal-control-problem/112060/6?u=goerz, which I've since double checked to verify that indeed, the calls of the loss function and the calls to callback match up.

This behavior isn't really what I would understand as "called after every optimizer step" (since linesearch iterations are arguably internal to a single step of the optimizer). I mean, a callback for every evaluation of the loss function could be useful too in some circumstances, but it prevents things like checking for monotonic convergence. If you really wanted to go overboard, there could be an additional flag to choose what the callback behavior should be.

P.S.: I can provide a MWE, some variation of https://gist.github.com/goerz/e35a8418edd9d358f9dbaa6972c143b5#file-mwe_zygote-jl if that helps, but the issue is probably more on a conceptual level.

@goerz goerz added the bug Something isn't working label Mar 26, 2024
@ChrisRackauckas
Copy link
Member

We should try and at least have a queryable way of knowing which behavior and optimizer is giving you, since it's algorithm-dependent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants