ADNLPModels.jl icon indicating copy to clipboard operation
ADNLPModels.jl copied to clipboard

Disable gradient and Hessian backends for NLSModels (part 2)

Open tmigot opened this issue 2 months ago • 2 comments

@amontoison @dpo I must say I don't like this PR https://github.com/JuliaSmoothOptimizers/ADNLPModels.jl/pull/357 . I am creating a new issue to continue the discussion.

I understand the issue that loading Hessian backends are heavy and that smart algorithms for NLS should use only the needed operations.

Before this PR, ADNPLModel implements the whole API, so it's simple for any users. Advanced users with performance needs had to know either the matrix_free keyword or specify the EmptyADBackend. It used to also be the only package that guarantee implementing the whole API.

After this PR, users have to specify the different backends to make ADNLPModels work with the rest of JSO.

For instance, these two examples would no longer work:

using ADNLPModels
using NLPModelsModifiers, NLPModelsIpopt, OptimizationProblems

nls = OptimizationProblems.ADNLPProblems.arglina(; use_nls=true)
ipopt(nls) # fails
ff_nls = FeasibilityFormNLS(nls)
ipopt(ff_nls) # fails

you would have to find the names of different backends for hess (in the first case) and hess_residual (in the second case) and choose between the different possibilities.

I am slightly surprised that the Breakage tests did not show that.

Overall, I agree that some backends should be Empty by default (like gradient), but the others ? Maybe can we extend on the keyword systems to simplify switch modes ?

tmigot avatar Oct 16 '25 23:10 tmigot

I think we can add a keyword argument full_api::Bool and maybe set to true by default? I plan to change a bunch a things for the next major release of ADNLPModels.jl so it is fine if it is a little bit breaking as long as it is documented. I plan to use DI.jl but I need to finalize something in SMC.jl for that before. Note that it may takes a few months.

amontoison avatar Oct 17 '25 02:10 amontoison

I have no problem with breaking things either. The big challenge with this package is that it should be easy to use and a good starting point for JSO, while also being efficient. I think passing keywords is a good way (probably not the only one) to switch from one mode to another.

tmigot avatar Oct 18 '25 11:10 tmigot