-
Notifications
You must be signed in to change notification settings - Fork 0
Test allocs #36
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
base: main
Are you sure you want to change the base?
Test allocs #36
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds allocation testing for optimization problems, specifically focusing on reducing memory allocations during function evaluations. The PR introduces new test files to verify zero-allocation behavior and refactors gradient and Hessian product computations to avoid temporary vector allocations.
- Adds allocation testing infrastructure for optimization problems hs5 and hs6
- Refactors gradient and Hessian product functions to use element-wise assignments instead of vectorized operations
- Updates the NLPModel constructor to use keyword arguments for bounds and adds type parameters for better performance
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
test/runtests.jl | Includes new allocation test file |
test/allocs.jl | New test file for zero-allocation verification |
test/problems/hs5.jl | Refactors gradient and hprod functions to avoid allocations |
test/problems/hs6.jl | Refactors gradient function to use element-wise assignment |
test/Project.toml | Adds compatibility constraints for dependencies |
src/structure.jl | Updates NLPModel struct with type parameters and constructor changes |
Comments suppressed due to low confidence (2)
test/allocs.jl:5
- The test_zero_allocations function is called but not defined or imported in this file. This will cause the test to fail unless test_zero_allocations is defined elsewhere and imported.
test_zero_allocations(hs5())
test/allocs.jl:12
- The test_zero_allocations function is called but not defined or imported in this file. This will cause the test to fail unless test_zero_allocations is defined elsewhere and imported.
test_zero_allocations(hs6())
julia> using ManualNLPModels, NLPModelsTest
julia> include("test/problems/hs6.jl")
hs6 (generic function with 3 methods)
julia> model = hs6();
julia> table = test_allocs_nlpmodels(model)
Dict{Symbol, Float64} with 17 entries:
:hprod_lag! => 32.0
:jtprod! => 0.0
:jprod! => 0.0
:obj => 0.0
:jac_op_transpose_prod! => 16.0
:cons! => 0.0
:hess_lag_op! => NaN
:hess_coord! => 0.0
:jac_op_prod! => 0.0
:grad! => 0.0
:hess_lag_coord! => 32.0
:hess_lag_op_prod! => 32.0
:jac_coord! => 0.0
:hess_structure! => 0.0
:hprod! => 0.0
:jac_structure! => 0.0
:hess_op_prod! => 0.0 |
Needs #33
Not sure where the allocations are coming from.
At the command line, hs5 doesn't allocate.