-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add GPU tests * Add CUDA version compatible with 1.6 * Update the GPU tests to use buildkite --------- Co-authored-by: Alexis Montoison <[email protected]>
- Loading branch information
1 parent
be41bb6
commit 53a494c
Showing
26 changed files
with
161 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
using CUDA, Test | ||
using CUDA, LinearAlgebra, SparseArrays, Test | ||
using ADNLPModels, NLPModels, NLPModelsTest | ||
|
||
for problem in NLPModelsTest.nlp_problems ∪ ["GENROSE"] | ||
include("nlp/problems/$(lowercase(problem)).jl") | ||
end | ||
for problem in NLPModelsTest.nls_problems | ||
include("nls/problems/$(lowercase(problem)).jl") | ||
end | ||
|
||
@test CUDA.functional() | ||
|
||
@testset "Checking NLPModelsTest (NLP) tests with $backend - GPU multiple precision" for backend in keys(ADNLPModels.predefined_backend) | ||
@testset "Checking GPU multiple precision on problem $problem" for problem in NLPModelsTest.nlp_problems | ||
nlp_from_T = eval(Meta.parse(lowercase(problem) * "_autodiff")) | ||
CUDA.allowscalar() do | ||
# sparse Jacobian/Hessian doesn't work here | ||
multiple_precision_nlp_array(T -> nlp_from_T(T; jacobian_backend = ADNLPModels.ForwardDiffADJacobian, hessian_backend = ADNLPModels.ForwardDiffADHessian), CuArray, exclude = [jth_hprod, hprod, jprod], linear_api = true) | ||
end | ||
end | ||
end | ||
|
||
@testset "Checking NLPModelsTest (NLS) tests with $backend - GPU multiple precision" for backend in keys(ADNLPModels.predefined_backend) | ||
@testset "Checking GPU multiple precision on problem $problem" for problem in NLPModelsTest.nls_problems | ||
nls_from_T = eval(Meta.parse(lowercase(problem) * "_autodiff")) | ||
CUDA.allowscalar() do | ||
# sparse Jacobian/Hessian doesn't work here | ||
multiple_precision_nls_array(T -> nls_from_T(T; jacobian_backend = ADNLPModels.ForwardDiffADJacobian, hessian_backend = ADNLPModels.ForwardDiffADHessian, jacobian_residual_backend = ADNLPModels.ForwardDiffADJacobian, hessian_residual_backend = ADNLPModels.ForwardDiffADHessian), CuArray, exclude = [jprod, jprod_residual, hprod_residual], linear_api = true) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export hs10_autodiff | ||
|
||
function hs10_autodiff(::Type{T} = Float64; kwargs...) where {T} | ||
x0 = T[-10.0; 10.0] | ||
hs10_autodiff(::Type{T}; kwargs...) where {T <: Number} = hs10_autodiff(Vector{T}; kwargs...) | ||
function hs10_autodiff(::Type{S} = Vector{Float64}; kwargs...) where {S} | ||
x0 = S([-10; 10]) | ||
f(x) = x[1] - x[2] | ||
c(x) = [-3 * x[1]^2 + 2 * x[1] * x[2] - x[2]^2 + 1] | ||
lcon = T[0.0] | ||
ucon = T[Inf] | ||
lcon = S([0]) | ||
ucon = S([Inf]) | ||
|
||
return ADNLPModel(f, x0, c, lcon, ucon, name = "hs10_autodiff"; kwargs...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export hs11_autodiff | ||
|
||
function hs11_autodiff(::Type{T} = Float64; kwargs...) where {T} | ||
x0 = T[4.9; 0.1] | ||
hs11_autodiff(::Type{T}; kwargs...) where {T <: Number} = hs11_autodiff(Vector{T}; kwargs...) | ||
function hs11_autodiff(::Type{S} = Vector{Float64}; kwargs...) where {S} | ||
x0 = S([49 // 10; 1 // 10]) | ||
f(x) = (x[1] - 5)^2 + x[2]^2 - 25 | ||
c(x) = [-x[1]^2 + x[2]] | ||
lcon = T[-Inf] | ||
ucon = T[0.0] | ||
lcon = S([-Inf]) | ||
ucon = S([0]) | ||
|
||
return ADNLPModel(f, x0, c, lcon, ucon, name = "hs11_autodiff"; kwargs...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
export hs13_autodiff | ||
|
||
function hs13_autodiff(::Type{T} = Float64; kwargs...) where {T} | ||
hs13_autodiff(::Type{T}; kwargs...) where {T <: Number} = hs13_autodiff(Vector{T}; kwargs...) | ||
function hs13_autodiff(::Type{S} = Vector{Float64}; kwargs...) where {S} | ||
function f(x) | ||
return (x[1] - 2)^2 + x[2]^2 | ||
end | ||
x0 = -2 * ones(T, 2) | ||
lvar = zeros(T, 2) | ||
uvar = T(Inf) * ones(T, 2) | ||
x0 = fill!(S(undef, 2), -2) | ||
lvar = fill!(S(undef, 2), 0) | ||
uvar = fill!(S(undef, 2), Inf) | ||
function c(x) | ||
return [(1 - x[1])^3 - x[2]] | ||
end | ||
lcon = zeros(T, 1) | ||
ucon = T(Inf) * ones(T, 1) | ||
lcon = fill!(S(undef, 1), 0) | ||
ucon = fill!(S(undef, 1), Inf) | ||
return ADNLPModels.ADNLPModel(f, x0, lvar, uvar, c, lcon, ucon, name = "hs13_autodiff"; kwargs...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
export hs5_autodiff | ||
|
||
function hs5_autodiff(::Type{T} = Float64; kwargs...) where {T} | ||
x0 = zeros(T, 2) | ||
hs5_autodiff(::Type{T}; kwargs...) where {T <: Number} = hs5_autodiff(Vector{T}; kwargs...) | ||
function hs5_autodiff(::Type{S} = Vector{Float64}; kwargs...) where {S} | ||
x0 = fill!(S(undef, 2), 0) | ||
f(x) = sin(x[1] + x[2]) + (x[1] - x[2])^2 - 3x[1] / 2 + 5x[2] / 2 + 1 | ||
l = T[-1.5; -3.0] | ||
u = T[4.0; 3.0] | ||
l = S([-1.5; -3.0]) | ||
u = S([4.0; 3.0]) | ||
|
||
return ADNLPModel(f, x0, l, u, name = "hs5_autodiff"; kwargs...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export hs6_autodiff | ||
|
||
function hs6_autodiff(::Type{T} = Float64; kwargs...) where {T} | ||
x0 = T[-1.2; 1.0] | ||
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 = T[0.0] | ||
ucon = T[0.0] | ||
lcon = fill!(S(undef, 1), 0) | ||
ucon = fill!(S(undef, 1), 0) | ||
|
||
return ADNLPModel(f, x0, c, lcon, ucon, name = "hs6_autodiff"; kwargs...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.