Skip to content

Type instability in ADNLPModels #347

Open
@MaxenceGollier

Description

@MaxenceGollier

Hello,
I am trying to implement an efficient optimization solver. In order to test performance I use ADNLPModels models from OptimizationProblems.jl, I am currently trying to catch type instabilities/allocations using JET.jl and I have found that a lot of issues where coming from this package.
This is weird because even for very simple operations Jet throws type instabilities at me, I guess I am doing something wrong but I can not find my error. I am not sure whether this belongs here or if I should post it on OptimizationProblems.jl.
Anyway, here is a minimal working example:

using JET, ADNLPModels, NLPModels, OptimizationProblems, OptimizationProblems.ADNLPProblems
nlp = bt1()
x = zeros(2)
@report_opt obj(nlp, x)

which results in

═════ 1 possible error found ═════
┌ obj(nlp::ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}, x::Vector{Float64}) @ ADNLPModels C:\Users\mgoll\.julia\packages\ADNLPModels\ELm6c\src\nlp.jl:538
│ runtime dispatch detected: %22::Any(x::Vector{Float64})::Any

Additionnally, this causes allocations as

 @allocated obj(nlp, x)
 @allocated obj(nlp, x)

results in 16 which is quite small but I might have to call this function and other ADNLPModels related functions very often.

Let me know what you think, thank you !

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions