Skip to content

Commit

Permalink
Use tags
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed May 17, 2024
1 parent b040693 commit 964b4db
Show file tree
Hide file tree
Showing 21 changed files with 105 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ steps:
if: build.message !~ /\[skip tests\]/

env:
GROUP: GPU
GROUP: CUDA
JULIA_PKG_SERVER: "" # it often struggles with our large artifacts
RETESTITEMS_NWORKERS: 4
RETESTITEMS_NWORKER_THREADS: 2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
group:
- Core
- Downstream
- Misc
- Wrappers
version:
- "1"
os:
Expand Down
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
SIAMFANLEquations = "084e46ad-d928-497d-ad5e-07fa361a48c4"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SpeedMapping = "f1835b91-879b-4a3f-a438-e4baacf14412"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand All @@ -140,4 +139,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Aqua", "BandedMatrices", "BenchmarkTools", "CUDA", "Enzyme", "FastLevenbergMarquardt", "FixedPointAcceleration", "LeastSquaresOptim", "MINPACK", "ModelingToolkit", "NLSolvers", "NLsolve", "NaNMath", "NonlinearProblemLibrary", "OrdinaryDiffEq", "Pkg", "Random", "ReTestItems", "SIAMFANLEquations", "SafeTestsets", "SparseDiffTools", "SpeedMapping", "StableRNGs", "StaticArrays", "Sundials", "Symbolics", "Test", "Zygote"]
test = ["Aqua", "BandedMatrices", "BenchmarkTools", "CUDA", "Enzyme", "FastLevenbergMarquardt", "FixedPointAcceleration", "LeastSquaresOptim", "MINPACK", "ModelingToolkit", "NLSolvers", "NLsolve", "NaNMath", "NonlinearProblemLibrary", "OrdinaryDiffEq", "Pkg", "Random", "ReTestItems", "SIAMFANLEquations", "SpeedMapping", "StableRNGs", "StaticArrays", "Sundials", "Symbolics", "Test", "Zygote"]
16 changes: 8 additions & 8 deletions test/core/23_test_problems_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end
export test_on_library, problems, dicts
end

@testitem "PolyAlgorithms" setup=[RobustnessTesting] begin
@testitem "PolyAlgorithms" setup=[RobustnessTesting] tags=[:core] begin
alg_ops = (RobustMultiNewton(), FastShortcutNonlinearPolyalg())

broken_tests = Dict(alg => Int[] for alg in alg_ops)
Expand All @@ -50,7 +50,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

@testitem "NewtonRaphson" setup=[RobustnessTesting] begin
@testitem "NewtonRaphson" setup=[RobustnessTesting] tags=[:core] begin
alg_ops = (NewtonRaphson(),)

broken_tests = Dict(alg => Int[] for alg in alg_ops)
Expand All @@ -59,7 +59,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

@testitem "TrustRegion" setup=[RobustnessTesting] begin
@testitem "TrustRegion" setup=[RobustnessTesting] tags=[:core] begin
alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple),
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan),
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei),
Expand All @@ -78,7 +78,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

@testitem "LevenbergMarquardt" setup=[RobustnessTesting] begin
@testitem "LevenbergMarquardt" setup=[RobustnessTesting] tags=[:core] begin
using LinearSolve

alg_ops = (LevenbergMarquardt(), LevenbergMarquardt(; α_geodesic = 0.1),
Expand All @@ -92,7 +92,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

@testitem "DFSane" setup=[RobustnessTesting] begin
@testitem "DFSane" setup=[RobustnessTesting] tags=[:core] begin
alg_ops = (DFSane(),)

broken_tests = Dict(alg => Int[] for alg in alg_ops)
Expand All @@ -101,7 +101,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

@testitem "Broyden" setup=[RobustnessTesting] begin
@testitem "Broyden" setup=[RobustnessTesting] tags=[:core] begin
alg_ops = (Broyden(), Broyden(; init_jacobian = Val(:true_jacobian)),
Broyden(; update_rule = Val(:bad_broyden)),
Broyden(; init_jacobian = Val(:true_jacobian), update_rule = Val(:bad_broyden)))
Expand All @@ -115,7 +115,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

@testitem "Klement" retries=5 setup=[RobustnessTesting] begin
@testitem "Klement" retries=5 setup=[RobustnessTesting] tags=[:core] begin
alg_ops = (Klement(), Klement(; init_jacobian = Val(:true_jacobian_diagonal)))

broken_tests = Dict(alg => Int[] for alg in alg_ops)
Expand All @@ -125,7 +125,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

@testitem "PseudoTransient" setup=[RobustnessTesting] begin
@testitem "PseudoTransient" setup=[RobustnessTesting] tags=[:core] begin
# PT relies on the root being a stable equilibrium for convergence, so it won't work on
# most problems
alg_ops = (PseudoTransient(),)
Expand Down
2 changes: 1 addition & 1 deletion test/core/forward_ad_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ __compatible(::KINSOL, ::Val{:oop_cache}) = false
export test_f!, test_f, jacobian_f, solve_with, __compatible
end

@testitem "ForwardDiff.jl Integration" setup=[ForwardADTesting] begin
@testitem "ForwardDiff.jl Integration" setup=[ForwardADTesting] tags=[:core] begin
for alg in (NewtonRaphson(), TrustRegion(), LevenbergMarquardt(),
PseudoTransient(; alpha_initial = 10.0), Broyden(), Klement(), DFSane(),
nothing, NLsolveJL(), CMINPACK(), KINSOL(; globalization_strategy = :LineSearch))
Expand Down
6 changes: 3 additions & 3 deletions test/core/nlls_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end
export solvers, θ_init, x, y_target, true_function, θ_true, loss_function
end

@testitem "General NLLS Solvers" setup=[CoreNLLSTesting] begin
@testitem "General NLLS Solvers" setup=[CoreNLLSTesting] tags=[:core] begin
prob_oop = NonlinearLeastSquaresProblem{false}(loss_function, θ_init, x)
prob_iip = NonlinearLeastSquaresProblem(
NonlinearFunction(loss_function; resid_prototype = zero(y_target)), θ_init, x)
Expand All @@ -62,7 +62,7 @@ end
end
end

@testitem "Custom VJP" setup=[CoreNLLSTesting] begin
@testitem "Custom VJP" setup=[CoreNLLSTesting] tags=[:core] begin
# This is just for testing that we can use vjp provided by the user
function vjp(v, θ, p)
resid = zeros(length(p))
Expand Down Expand Up @@ -96,7 +96,7 @@ end
end
end

@testitem "NLLS Analytic Jacobian" begin
@testitem "NLLS Analytic Jacobian" tags=[:core] begin
dataIn = 1:10
f(x, p) = x[1] * dataIn .^ 2 .+ x[2] * dataIn .+ x[3]
dataOut = f([1, 2, 3], nothing) + 0.1 * randn(10, 1)
Expand Down
19 changes: 9 additions & 10 deletions test/core/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function newton_fails(u, p)
end

const TERMINATION_CONDITIONS = [
SteadyStateDiffEqTerminationMode(), SimpleNonlinearSolveTerminationMode(),
NormTerminationMode(), RelTerminationMode(), RelNormTerminationMode(),
AbsTerminationMode(), AbsNormTerminationMode(), RelSafeTerminationMode(),
AbsSafeTerminationMode(), RelSafeBestTerminationMode(), AbsSafeBestTerminationMode()]
Expand Down Expand Up @@ -53,7 +52,7 @@ end

# --- NewtonRaphson tests ---

@testitem "NewtonRaphson" setup=[CoreRootfindTesting] begin
@testitem "NewtonRaphson" setup=[CoreRootfindTesting] tags=[:core] begin
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad))" for lsmethod in (
Static(), StrongWolfe(), BackTracking(), HagerZhang(), MoreThuente()),
ad in (AutoFiniteDiff(), AutoZygote())
Expand Down Expand Up @@ -119,7 +118,7 @@ end

# --- TrustRegion tests ---

@testitem "TrustRegion" setup=[CoreRootfindTesting] begin
@testitem "TrustRegion" setup=[CoreRootfindTesting] tags=[:core] begin
radius_update_schemes = [RadiusUpdateSchemes.Simple, RadiusUpdateSchemes.NocedalWright,
RadiusUpdateSchemes.NLsolve, RadiusUpdateSchemes.Hei,
RadiusUpdateSchemes.Yuan, RadiusUpdateSchemes.Fan, RadiusUpdateSchemes.Bastin]
Expand Down Expand Up @@ -237,7 +236,7 @@ end

# --- LevenbergMarquardt tests ---

@testitem "LevenbergMarquardt" setup=[CoreRootfindTesting] begin
@testitem "LevenbergMarquardt" setup=[CoreRootfindTesting] tags=[:core] begin
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)
@testset "[OOP] u0: $(typeof(u0))" for u0 in u0s
sol = benchmark_nlsolve_oop(quadratic_f, u0; solver = LevenbergMarquardt())
Expand Down Expand Up @@ -323,7 +322,7 @@ end

# --- DFSane tests ---

@testitem "DFSane" setup=[CoreRootfindTesting] begin
@testitem "DFSane" setup=[CoreRootfindTesting] tags=[:core] begin
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)

@testset "[OOP] u0: $(typeof(u0))" for u0 in u0s
Expand Down Expand Up @@ -394,7 +393,7 @@ end

# --- PseudoTransient tests ---

@testitem "PseudoTransient" setup=[CoreRootfindTesting] begin
@testitem "PseudoTransient" setup=[CoreRootfindTesting] tags=[:core] begin
# These are tests for NewtonRaphson so we should set alpha_initial to be high so that we
# converge quickly
@testset "PT: alpha_initial = 10.0 PT AD: $(ad)" for ad in (
Expand Down Expand Up @@ -463,7 +462,7 @@ end

# --- Broyden tests ---

@testitem "Broyden" setup=[CoreRootfindTesting] begin
@testitem "Broyden" setup=[CoreRootfindTesting] tags=[:core] begin
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad)) Init Jacobian: $(init_jacobian) Update Rule: $(update_rule)" for lsmethod in (
Static(), StrongWolfe(), BackTracking(),
HagerZhang(), MoreThuente(), LiFukushimaLineSearch()),
Expand Down Expand Up @@ -513,7 +512,7 @@ end

# --- Klement tests ---

@testitem "Klement" setup=[CoreRootfindTesting] begin
@testitem "Klement" setup=[CoreRootfindTesting] tags=[:core] begin
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad)) Init Jacobian: $(init_jacobian)" for lsmethod in (
Static(), StrongWolfe(), BackTracking(), HagerZhang(), MoreThuente()),
ad in (AutoFiniteDiff(), AutoZygote()),
Expand Down Expand Up @@ -562,7 +561,7 @@ end

# --- LimitedMemoryBroyden tests ---

@testitem "LimitedMemoryBroyden" setup=[CoreRootfindTesting] begin
@testitem "LimitedMemoryBroyden" setup=[CoreRootfindTesting] tags=[:core] begin
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad))" for lsmethod in (
Static(), StrongWolfe(), BackTracking(),
HagerZhang(), MoreThuente(), LiFukushimaLineSearch()),
Expand Down Expand Up @@ -612,7 +611,7 @@ end
end

# Miscellaneous Tests
@testitem "Custom JVP" setup=[CoreRootfindTesting] begin
@testitem "Custom JVP" setup=[CoreRootfindTesting] tags=[:core] begin
function F(u::Vector{Float64}, p::Vector{Float64})
Δ = Tridiagonal(-ones(99), 2 * ones(100), -ones(99))
return u + 0.1 * u .* Δ * u - p
Expand Down
92 changes: 47 additions & 45 deletions test/downstream/mtk_cache_indexing_tests.jl
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
using ModelingToolkit, NonlinearSolve
using ModelingToolkit: t_nounits as t

@parameters p d
@variables X(t)
eqs = [0 ~ sin(X + p) - d * sqrt(X + 1)]
@mtkbuild nlsys = NonlinearSystem(eqs, [X], [p, d])

# Creates an integrator.
nlprob = NonlinearProblem(nlsys, [X => 1.0], [p => 2.0, d => 3.0])

@testset "GeneralizedFirstOrderAlgorithmCache" begin
nint = init(nlprob, NewtonRaphson())
@test nint isa NonlinearSolve.GeneralizedFirstOrderAlgorithmCache

@test nint[X] == 1.0
@test nint[nlsys.X] == 1.0
@test nint[:X] == 1.0
@test nint.ps[p] == 2.0
@test nint.ps[nlsys.p] == 2.0
@test nint.ps[:p] == 2.0
end

@testset "NonlinearSolvePolyAlgorithmCache" begin
nint = init(nlprob, FastShortcutNonlinearPolyalg())
@test nint isa NonlinearSolve.NonlinearSolvePolyAlgorithmCache

@test nint[X] == 1.0
@test nint[nlsys.X] == 1.0
@test nint[:X] == 1.0
@test nint.ps[p] == 2.0
@test nint.ps[nlsys.p] == 2.0
@test nint.ps[:p] == 2.0
end

@testset "NonlinearSolveNoInitCache" begin
nint = init(nlprob, SimpleNewtonRaphson())
@test nint isa NonlinearSolve.NonlinearSolveNoInitCache

@test nint[X] == 1.0
@test nint[nlsys.X] == 1.0
@test nint[:X] == 1.0
@test nint.ps[p] == 2.0
@test nint.ps[nlsys.p] == 2.0
@test nint.ps[:p] == 2.0
@testitem "Modeling Toolkit Cache Indexing" tags=[:downstream] begin
using ModelingToolkit
using ModelingToolkit: t_nounits as t

@parameters p d
@variables X(t)
eqs = [0 ~ sin(X + p) - d * sqrt(X + 1)]
@mtkbuild nlsys = NonlinearSystem(eqs, [X], [p, d])

# Creates an integrator.
nlprob = NonlinearProblem(nlsys, [X => 1.0], [p => 2.0, d => 3.0])

@testset "GeneralizedFirstOrderAlgorithmCache" begin
nint = init(nlprob, NewtonRaphson())
@test nint isa NonlinearSolve.GeneralizedFirstOrderAlgorithmCache

@test nint[X] == 1.0
@test nint[nlsys.X] == 1.0
@test nint[:X] == 1.0
@test nint.ps[p] == 2.0
@test nint.ps[nlsys.p] == 2.0
@test nint.ps[:p] == 2.0
end

@testset "NonlinearSolvePolyAlgorithmCache" begin
nint = init(nlprob, FastShortcutNonlinearPolyalg())
@test nint isa NonlinearSolve.NonlinearSolvePolyAlgorithmCache

@test nint[X] == 1.0
@test nint[nlsys.X] == 1.0
@test nint[:X] == 1.0
@test nint.ps[p] == 2.0
@test nint.ps[nlsys.p] == 2.0
@test nint.ps[:p] == 2.0
end

@testset "NonlinearSolveNoInitCache" begin
nint = init(nlprob, SimpleNewtonRaphson())
@test nint isa NonlinearSolve.NonlinearSolveNoInitCache

@test nint[X] == 1.0
@test nint[nlsys.X] == 1.0
@test nint[:X] == 1.0
@test nint.ps[p] == 2.0
@test nint.ps[nlsys.p] == 2.0
@test nint.ps[:p] == 2.0
end
end
2 changes: 1 addition & 1 deletion test/gpu/core_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "CUDA Tests" begin
@testitem "CUDA Tests" tags=[:cuda] skip=:(using CUDA; !CUDA.functional()) begin
using CUDA, NonlinearSolve, LinearSolve, StableRNGs

CUDA.allowscalar(false)
Expand Down
2 changes: 1 addition & 1 deletion test/misc/aliasing_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "PolyAlgorithm Aliasing" begin
@testitem "PolyAlgorithm Aliasing" tags=[:misc] begin
using NonlinearProblemLibrary

# Use a problem that the initial solvers cannot solve and cause the initial value to
Expand Down
2 changes: 1 addition & 1 deletion test/misc/banded_matrices_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Banded Matrix vcat" begin
@testitem "Banded Matrix vcat" tags=[:misc] begin
using BandedMatrices, LinearAlgebra, SparseArrays

b = BandedMatrix(Ones(5, 5), (1, 1))
Expand Down
2 changes: 1 addition & 1 deletion test/misc/bruss_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Brusselator 2D" begin
@testitem "Brusselator 2D" tags=[:misc] begin
using LinearAlgebra, SparseArrays, Symbolics

const N = 32
Expand Down
2 changes: 1 addition & 1 deletion test/misc/linsolve_switching_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Singular Systems -- Auto Linear Solve Switching" begin
@testitem "Singular Systems -- Auto Linear Solve Switching" tags=[:misc] begin
using LinearSolve, NonlinearSolve

function f!(du, u, p)
Expand Down
4 changes: 2 additions & 2 deletions test/misc/matrix_resizing_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "Out-of-place Matrix Resizing" begin
@testitem "Out-of-place Matrix Resizing" tags=[:misc] begin
using StableRNGs

ff(u, p) = u .* u .- p
Expand All @@ -14,7 +14,7 @@
end
end

@testitem "Inplace Matrix Resizing" begin
@testitem "Inplace Matrix Resizing" tags=[:misc] begin
using StableRNGs

fiip(du, u, p) = (du .= u .* u .- p)
Expand Down
2 changes: 1 addition & 1 deletion test/misc/noinit_caching_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testitem "NoInit Caching" begin
@testitem "NoInit Caching" tags=[:misc] begin
using LinearAlgebra
import NLsolve, NLSolvers

Expand Down
Loading

0 comments on commit 964b4db

Please sign in to comment.