JuliaSmoothOptimizers / JuliaSmoothOptimizers/ADNLPModels.jl
Sparse Jacobian/Hessian not GPU-compatible
- Dominant language
- Julia
- Stars
- 44
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
See the following tests:
- [ ] https://github.com/JuliaSmoothOptimizers/ADNLPModels.jl/blob/53a494c6e19177d326275fb027f6732f985ade9a/test/nls/nlpmodelstest.jl#L42
- [ ] https://github.com/JuliaSmoothOptimizers/ADNLPModels.jl/blob/53a494c6e19177d326275fb027f6732f985ade9a/test/nlp/nlpmodelstest.jl#L25
- [ ] https://github.com/JuliaSmoothOptimizers/ADNLPModels.jl/blob/53a494c6e19177d326275fb027f6732f985ade9a/test/gpu.jl#L28
- [ ] https://github.com/JuliaSmoothOptimizers/ADNLPModels.jl/blob/53a494c6e19177d326275fb027f6732f985ade9a/test/gpu.jl#L18
A MWE:
```julia
using CUDA, ADNLPModels, NLPModels, Symbolics
hs6_autodiff(::Type{T}; kwargs...) where {T <: Number} = hs6_autodiff(Vector{T}; kwargs...)
function hs6_autodiff(::Type{S} = Vector{Float64}; kwargs...) where {S}
x0 = S([-12 // 10; 1])
f(x) = (1 - x[1])^2
c(x) = [10 * (x[2] - x[1]^2)]
lcon = fill!(S(undef, 1), 0)
ucon = fill!(S(undef, 1), 0)
return ADNLPModel(f, x0, c, lcon, ucon, name = "hs6_autodiff"; kwargs...)
end
S = CuArray{Float64}
function c!(cx, x)
cx .= [10 * (x[2] - x[1]^2)]
return cx
end
x0 = S([-12 // 10; 1])
output = similar(x0, 1)
# nlp = hs6_autodiff(CuArray{Float64})
# ADNLPModels.SparseADJacobian(2, x -> (1 - x[1])^2, 1, c!, x0 = x0)
# J = ADNLPModels.compute_jacobian_sparsity(c!, output, x0)
J = Symbolics.jacobian_sparsity(c!, cx, x0)
```
Contributor guide
Assessment
This issue has not been assessed yet.