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

Allow return code when directly calling adjoint_sensitivities #1012

Open
sebapersson opened this issue Feb 15, 2024 · 0 comments
Open

Allow return code when directly calling adjoint_sensitivities #1012

sebapersson opened this issue Feb 15, 2024 · 0 comments

Comments

@sebapersson
Copy link

Is your feature request related to a problem? Please describe.

As noted in the docs directly calling adjoint_sensitivities can be more efficient, and it is what we for example do in PEtab.jl. However, as adjoint_sensitivities does not return any retcode for adj_sol it is currently not possible when, for example doing parameter estimation, to catch gradient evaluation failures. As the forward problem can often be easier to solve, being able to catch the error in the forward-solve is not enough.

I have also seen questions about this on Slack in the sciml-bridged channel.

Describe the solution you’d like

I do not know exactly how to solve this, but one option could be to allow _adjoint_sensitivities to also return adj_sol, then for the function adjoint_sensitivities have a kwarg like retadjsol=false that by default is false and return as currently du, dp, but if true also returns adj_sol.

Describe alternatives you’ve considered

An alternative is in for example packages like PEtab.jl to copy in the code from _adjoint_sensitivities for each method, however, this is not feasible to maintain. It is also possible to generally capture if a warning was thrown, but accessing the retcode would be a more convenient and less hacky solution.

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

No branches or pull requests

1 participant