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

Provide an option to exclude some AD backends #327

Closed
wants to merge 3 commits into from

Conversation

amontoison
Copy link
Member

@amontoison amontoison commented Feb 1, 2025

close #324
cc @jbcaillau @PierreMartinon
It will be easier for you to exclude some ADbackend with the option exclude_backend.

using ADNLPModels, NLPModels

f(x) = (x[1] - 1)^2
T = Float64
x0 = T[-1.2; 1.0]
lvar, uvar = zeros(T, 2), ones(T, 2)
lcon, ucon = -T[0.5], T[0.5]
c!(cx, x) = begin
  cx[1] = x[2]
  return cx
end
nlp = ADNLPModel!(f, x0, lvar, uvar, c!, lcon, ucon, backend = :optimized,
                  excluded_backend=[:jprod_backend, :jtprod_backend, :hprod_backend, :ghjvprod_backend])
ADNLPModel - Model with automatic differentiation backend ADModelBackend{
  ReverseDiffADGradient,
  EmptyADbackend,
  EmptyADbackend,
  EmptyADbackend,
  SparseADJacobian,
  SparseReverseADHessian,
  EmptyADbackend,
}

@amontoison amontoison requested a review from tmigot February 1, 2025 03:00
@amontoison amontoison changed the title Provide an option to exlude some AD backends Provide an option to exclude some AD backends Feb 1, 2025
Copy link
Contributor

github-actions bot commented Feb 1, 2025

Package name latest stable
ExpressionTreeForge
JSOSuite
PartiallySeparableNLPModels
PartiallySeparableSolvers
SolverTest

@tmigot
Copy link
Member

tmigot commented Feb 1, 2025

The current way to achieve this is to set the mentioned backend to EmptyADbackend, but if you guys think that might be useful why not.

Copy link
Member

@tmigot tmigot left a comment

Choose a reason for hiding this comment

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

Looks overall good, thanks @amontoison !
Could you also update the section https://jso.dev/ADNLPModels.jl/dev/performance/ for the doc and maybe add a very short unit test?

src/ad.jl Outdated Show resolved Hide resolved
Co-authored-by: Tangi Migot <[email protected]>
@amontoison
Copy link
Member Author

amontoison commented Feb 1, 2025

The current way to achieve this is to set the mentioned backend to EmptyADbackend, but if you guys think that might be useful why not.

I forgot that we can do that!
I found it in the documentation: https://jso.dev/ADNLPModels.jl/dev/performance/#Use-only-the-needed-operations

I don't think this PR will bring any advantage. I will just update the documentation to specify the backends needed for Ipopt / Knitro / MadNLP.

using ADNLPModels, NLPModels

f(x) = (x[1] - 1)^2
T = Float64
x0 = T[-1.2; 1.0]
lvar, uvar = zeros(T, 2), ones(T, 2)
lcon, ucon = -T[0.5], T[0.5]
c!(cx, x) = begin
  cx[1] = x[2]
  return cx
end
nlp = ADNLPModel!(f, x0, lvar, uvar, c!, lcon, ucon, backend = :optimized,
                         jprod_backend = ADNLPModels.EmptyADbackend,
                         jtprod_backend = ADNLPModels.EmptyADbackend,
                         hprod_backend = ADNLPModels.EmptyADbackend,
                         ghjvprod_backend = ADNLPModels.EmptyADbackend)

@amontoison amontoison closed this Feb 1, 2025
@amontoison amontoison deleted the excluded_backend branch February 1, 2025 17:44
@amontoison
Copy link
Member Author

I updated the documentation in #328.

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.

Add an option to provide the list of backends that we want
2 participants