Skip to content

Commit f2702b2

Browse files
authored
Merge pull request #371 from SciML/ap/fast_testing
Parallel Testing
2 parents f3b0b1b + 49ca687 commit f2702b2

26 files changed

+639
-729
lines changed

Diff for: .buildkite/pipeline.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ steps:
44
- JuliaCI/julia#v1:
55
version: "1"
66
- JuliaCI/julia-test#v1:
7-
coverage: false # 1000x slowdown
7+
coverage: true
88
agents:
99
queue: "juliagpu"
1010
cuda: "*"
11-
timeout_in_minutes: 30
11+
timeout_in_minutes: 60
1212
# Don't run Buildkite if the commit message includes the text [skip tests]
1313
if: build.message !~ /\[skip tests\]/
1414

1515
env:
1616
GROUP: GPU
1717
JULIA_PKG_SERVER: "" # it often struggles with our large artifacts
18-
# SECRET_CODECOV_TOKEN: "..."
18+
RETESTITEMS_NWORKERS: 4
19+
RETESTITEMS_NWORKER_THREADS: 2
20+
SECRET_CODECOV_TOKEN: "HC7K/ymhi62KUQ5OLU4DOl+11gaQt4JhXX/2nfTGlTsBB8mEMxQ8R+sHIp/2HjEup5eSXAN2IWQDQ7RDBuQvVp0T1UVtr2e4YNZFztKnsJXrFO15hXxYShJodI//X/8DzhlQd/lyTDOAOJu3eznsc3sC2CUgJzXZxLUtQN9YaZ1i3a+NoN1mO5UpkkHVhXigwF5gjy+0tei8fCdcP+SIhG0EanS5yd9q/SurtCpMHsHyUG97+ZVPglSKgdaqr31+PdmiPJ+ynp4+Hnc/esosxUSHSIL+ryRTO+28RNwPTiNf99J51RJLQmz1knWTR1ky6tiYIZ5218O6wvNil0SqNw==;U2FsdGVkX18nBY3t4LZYlEIz3EVKjpqCd994JNeJGt006up+sAjXEssI0tgCVXnfXsenVsP3NCCEoOS1GXc44g=="

Diff for: .github/workflows/CI.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
group:
21-
- RootFinding
22-
- NLLSSolvers
23-
- 23TestProblems
24-
- Wrappers
25-
- Miscellaneous
21+
- Core
2622
version:
27-
- '1.10'
23+
- "1"
2824
os:
2925
- ubuntu-latest
3026
- macos-latest
@@ -49,9 +45,14 @@ jobs:
4945
env:
5046
GROUP: ${{ matrix.group }}
5147
JULIA_NUM_THREADS: 11
48+
RETESTITEMS_NWORKERS: 4
49+
RETESTITEMS_NWORKER_THREADS: 2
5250
- uses: julia-actions/julia-processcoverage@v1
5351
with:
5452
directories: src,ext
5553
- uses: codecov/codecov-action@v4
5654
with:
5755
file: lcov.info
56+
token: ${{ secrets.CODECOV_TOKEN }}
57+
verbose: true
58+
fail_ci_if_error: true

Diff for: .github/workflows/Downgrade.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,29 @@ on:
44
branches:
55
- master
66
paths-ignore:
7-
- 'docs/**'
7+
- "docs/**"
88
push:
99
branches:
1010
- master
1111
paths-ignore:
12-
- 'docs/**'
12+
- "docs/**"
1313
jobs:
1414
test:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
version: ['1']
18+
version: ["1"]
1919
steps:
2020
- uses: actions/checkout@v4
2121
- uses: julia-actions/setup-julia@v1
2222
with:
2323
version: ${{ matrix.version }}
2424
- uses: cjdoris/julia-downgrade-compat-action@v1
25-
# if: ${{ matrix.version == '1.6' }}
2625
with:
2726
skip: Pkg,TOML
2827
- uses: julia-actions/julia-buildpkg@v1
29-
- uses: julia-actions/julia-runtest@v1
28+
- uses: julia-actions/julia-runtest@v1
29+
env:
30+
JULIA_NUM_THREADS: 11
31+
RETESTITEMS_NWORKERS: 4
32+
RETESTITEMS_NWORKER_THREADS: 2

Diff for: Project.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NonlinearSolve"
22
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
33
authors = ["SciML"]
4-
version = "3.5.3"
4+
version = "3.5.4"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -60,6 +60,7 @@ ArrayInterface = "7.7"
6060
BandedMatrices = "1.4"
6161
BenchmarkTools = "1.4"
6262
ConcreteStructs = "0.2.3"
63+
CUDA = "5.1"
6364
DiffEqBase = "6.146.0"
6465
Enzyme = "0.11.11"
6566
FastBroadcast = "0.2.8"
@@ -84,6 +85,7 @@ PrecompileTools = "1.2"
8485
Preferences = "1.4"
8586
Printf = "1.10"
8687
Random = "1.91"
88+
ReTestItems = "1"
8789
RecursiveArrayTools = "3.4"
8890
Reexport = "1.2"
8991
SIAMFANLEquations = "1.0.1"
@@ -107,6 +109,7 @@ julia = "1.10"
107109
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
108110
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
109111
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
112+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
110113
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
111114
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
112115
FastLevenbergMarquardt = "7a0df574-e128-4d35-8cbd-3d84502bf7ce"
@@ -122,6 +125,8 @@ NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141"
122125
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
123126
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
124127
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
128+
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
129+
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
125130
SIAMFANLEquations = "084e46ad-d928-497d-ad5e-07fa361a48c4"
126131
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
127132
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
@@ -134,4 +139,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
134139
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
135140

136141
[targets]
137-
test = ["Aqua", "Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools", "NonlinearProblemLibrary", "LeastSquaresOptim", "FastLevenbergMarquardt", "NaNMath", "BandedMatrices", "DiffEqBase", "StableRNGs", "MINPACK", "NLsolve", "OrdinaryDiffEq", "SpeedMapping", "FixedPointAcceleration", "SIAMFANLEquations", "Sundials"]
142+
test = ["Aqua", "Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools", "NonlinearProblemLibrary", "LeastSquaresOptim", "FastLevenbergMarquardt", "NaNMath", "BandedMatrices", "DiffEqBase", "StableRNGs", "MINPACK", "NLsolve", "OrdinaryDiffEq", "SpeedMapping", "FixedPointAcceleration", "SIAMFANLEquations", "Sundials", "ReTestItems", "Reexport", "CUDA"]

Diff for: src/algorithms/levenberg_marquardt.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ end
6969
J_diag_cache
7070
J_damped
7171
damping_f
72+
initial_damping
7273
end
7374

7475
function reinit_cache!(cache::LevenbergMarquardtDampingCache, args...; kwargs...)
75-
cache.λ = cache.damping_f.initial_damping
76+
cache.λ = cache.initial_damping
7677
cache.λ_factor = cache.damping_f.increase_factor
7778
if !(cache.DᵀD isa Number)
7879
if can_setindex(cache.DᵀD.diag)
@@ -110,7 +111,7 @@ function __internal_init(prob::AbstractNonlinearProblem,
110111
J_damped = T(initial_damping) .* DᵀD
111112
return LevenbergMarquardtDampingCache(T(f.increase_factor), T(f.decrease_factor),
112113
T(f.min_damping), T(f.increase_factor), T(initial_damping), DᵀD, J_diag_cache,
113-
J_damped, f)
114+
J_damped, f, T(initial_damping))
114115
end
115116

116117
(damping::LevenbergMarquardtDampingCache)(::Nothing) = damping.J_damped

Diff for: test/core/23_test_problems.jl renamed to test/core/23_test_problems_tests.jl

+31-25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@testsetup module RobustnessTesting
12
using NonlinearSolve, LinearAlgebra, LinearSolve, NonlinearProblemLibrary, Test
23

34
problems = NonlinearProblemLibrary.problems
@@ -36,7 +37,10 @@ function test_on_library(problems, dicts, alg_ops, broken_tests, ϵ = 1e-4;
3637
end
3738
end
3839

39-
@testset "NewtonRaphson 23 Test Problems" begin
40+
export test_on_library, problems, dicts
41+
end
42+
43+
@testitem "NewtonRaphson" setup=[RobustnessTesting] begin
4044
alg_ops = (NewtonRaphson(),)
4145

4246
broken_tests = Dict(alg => Int[] for alg in alg_ops)
@@ -45,26 +49,28 @@ end
4549
test_on_library(problems, dicts, alg_ops, broken_tests)
4650
end
4751

48-
# @testset "TrustRegion 23 Test Problems" begin
49-
# alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple),
50-
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan),
51-
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei),
52-
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan),
53-
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin),
54-
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve))
55-
56-
# broken_tests = Dict(alg => Int[] for alg in alg_ops)
57-
# broken_tests[alg_ops[1]] = [11, 21]
58-
# broken_tests[alg_ops[2]] = [11, 21]
59-
# broken_tests[alg_ops[3]] = [11, 21]
60-
# broken_tests[alg_ops[4]] = [11, 21]
61-
# broken_tests[alg_ops[5]] = [21]
62-
# broken_tests[alg_ops[6]] = [21]
63-
64-
# test_on_library(problems, dicts, alg_ops, broken_tests)
65-
# end
66-
67-
@testset "LevenbergMarquardt 23 Test Problems" begin
52+
@testitem "TrustRegion" setup=[RobustnessTesting] begin
53+
alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple),
54+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan),
55+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei),
56+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan),
57+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin),
58+
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve))
59+
60+
broken_tests = Dict(alg => Int[] for alg in alg_ops)
61+
broken_tests[alg_ops[1]] = [11, 21]
62+
broken_tests[alg_ops[2]] = [11, 21]
63+
broken_tests[alg_ops[3]] = [11, 21]
64+
broken_tests[alg_ops[4]] = [8, 11, 21]
65+
broken_tests[alg_ops[5]] = [21]
66+
broken_tests[alg_ops[6]] = [11, 21]
67+
68+
test_on_library(problems, dicts, alg_ops, broken_tests)
69+
end
70+
71+
@testitem "LevenbergMarquardt" setup=[RobustnessTesting] begin
72+
using LinearSolve
73+
6874
alg_ops = (LevenbergMarquardt(),
6975
LevenbergMarquardt(; α_geodesic = 0.1),
7076
LevenbergMarquardt(; linsolve = CholeskyFactorization()))
@@ -77,7 +83,7 @@ end
7783
test_on_library(problems, dicts, alg_ops, broken_tests)
7884
end
7985

80-
@testset "DFSane 23 Test Problems" begin
86+
@testitem "DFSane" setup=[RobustnessTesting] begin
8187
alg_ops = (DFSane(),)
8288

8389
broken_tests = Dict(alg => Int[] for alg in alg_ops)
@@ -86,7 +92,7 @@ end
8692
test_on_library(problems, dicts, alg_ops, broken_tests)
8793
end
8894

89-
@testset "Broyden 23 Test Problems" begin
95+
@testitem "Broyden" retries=5 setup=[RobustnessTesting] begin
9096
alg_ops = (Broyden(),
9197
Broyden(; init_jacobian = Val(:true_jacobian)),
9298
Broyden(; update_rule = Val(:bad_broyden)),
@@ -101,7 +107,7 @@ end
101107
test_on_library(problems, dicts, alg_ops, broken_tests)
102108
end
103109

104-
@testset "Klement 23 Test Problems" begin
110+
@testitem "Klement" retries=5 setup=[RobustnessTesting] begin
105111
alg_ops = (Klement(), Klement(; init_jacobian = Val(:true_jacobian_diagonal)))
106112

107113
broken_tests = Dict(alg => Int[] for alg in alg_ops)
@@ -111,7 +117,7 @@ end
111117
test_on_library(problems, dicts, alg_ops, broken_tests)
112118
end
113119

114-
@testset "PseudoTransient 23 Test Problems" begin
120+
@testitem "PseudoTransient" setup=[RobustnessTesting] begin
115121
# PT relies on the root being a stable equilibrium for convergence, so it won't work on
116122
# most problems
117123
alg_ops = (PseudoTransient(),)

Diff for: test/core/forward_ad.jl renamed to test/core/forward_ad_tests.jl

+44-37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using ForwardDiff,
2-
NonlinearSolve, MINPACK, NLsolve, StaticArrays, Sundials, Test, LinearAlgebra
1+
@testsetup module ForwardADTesting
2+
using Reexport, NonlinearSolve
3+
@reexport using ForwardDiff, MINPACK, NLsolve, StaticArrays, Sundials, LinearAlgebra
34

45
test_f!(du, u, p) = (@. du = u^2 - p)
56
test_f(u, p) = (@. u^2 - p)
@@ -58,49 +59,55 @@ __compatible(::NLsolveJL, ::Val{:oop_cache}) = false
5859
__compatible(::KINSOL, ::Val{:iip_cache}) = false
5960
__compatible(::KINSOL, ::Val{:oop_cache}) = false
6061

61-
@testset "ForwardDiff.jl Integration: $(alg)" for alg in (NewtonRaphson(), TrustRegion(),
62-
LevenbergMarquardt(), PseudoTransient(; alpha_initial = 10.0), Broyden(), Klement(),
63-
DFSane(), nothing, NLsolveJL(), CMINPACK(), KINSOL())
64-
us = (2.0, @SVector[1.0, 1.0], [1.0, 1.0], ones(2, 2), @SArray ones(2, 2))
62+
export test_f!, test_f, jacobian_f, solve_with, __compatible
63+
end
64+
65+
@testitem "ForwardDiff.jl Integration" setup=[ForwardADTesting] begin
66+
for alg in (NewtonRaphson(), TrustRegion(),
67+
LevenbergMarquardt(), PseudoTransient(; alpha_initial = 10.0), Broyden(), Klement(),
68+
DFSane(), nothing, NLsolveJL(), CMINPACK(),
69+
KINSOL(; globalization_strategy = :LineSearch))
70+
us = (2.0, @SVector[1.0, 1.0], [1.0, 1.0], ones(2, 2), @SArray ones(2, 2))
6571

66-
@testset "Scalar AD" begin
67-
for p in 1.0:0.1:100.0, u0 in us, mode in (:iip, :oop, :iip_cache, :oop_cache)
68-
__compatible(u0, alg) || continue
69-
__compatible(u0, Val(mode)) || continue
70-
__compatible(alg, Val(mode)) || continue
72+
@testset "Scalar AD" begin
73+
for p in 1.0:0.1:100.0, u0 in us, mode in (:iip, :oop, :iip_cache, :oop_cache)
74+
__compatible(u0, alg) || continue
75+
__compatible(u0, Val(mode)) || continue
76+
__compatible(alg, Val(mode)) || continue
7177

72-
sol = solve(NonlinearProblem(test_f, u0, p), alg)
73-
if SciMLBase.successful_retcode(sol)
74-
gs = abs.(ForwardDiff.derivative(solve_with(Val{mode}(), u0, alg), p))
75-
gs_true = abs.(jacobian_f(u0, p))
76-
if !(isapprox(gs, gs_true, atol = 1e-5))
77-
@show sol.retcode, sol.u
78-
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_gradient=gs true_gradient=gs_true
79-
else
80-
@test abs.(gs)abs.(gs_true) atol=1e-5
78+
sol = solve(NonlinearProblem(test_f, u0, p), alg)
79+
if SciMLBase.successful_retcode(sol)
80+
gs = abs.(ForwardDiff.derivative(solve_with(Val{mode}(), u0, alg), p))
81+
gs_true = abs.(jacobian_f(u0, p))
82+
if !(isapprox(gs, gs_true, atol = 1e-5))
83+
@show sol.retcode, sol.u
84+
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_gradient=gs true_gradient=gs_true
85+
else
86+
@test abs.(gs)abs.(gs_true) atol=1e-5
87+
end
8188
end
8289
end
8390
end
84-
end
8591

86-
@testset "Jacobian" begin
87-
for u0 in us, p in ([2.0, 1.0], [2.0 1.0; 3.0 4.0]),
88-
mode in (:iip, :oop, :iip_cache, :oop_cache)
92+
@testset "Jacobian" begin
93+
for u0 in us, p in ([2.0, 1.0], [2.0 1.0; 3.0 4.0]),
94+
mode in (:iip, :oop, :iip_cache, :oop_cache)
8995

90-
__compatible(u0, p) || continue
91-
__compatible(u0, alg) || continue
92-
__compatible(u0, Val(mode)) || continue
93-
__compatible(alg, Val(mode)) || continue
96+
__compatible(u0, p) || continue
97+
__compatible(u0, alg) || continue
98+
__compatible(u0, Val(mode)) || continue
99+
__compatible(alg, Val(mode)) || continue
94100

95-
sol = solve(NonlinearProblem(test_f, u0, p), alg)
96-
if SciMLBase.successful_retcode(sol)
97-
gs = abs.(ForwardDiff.jacobian(solve_with(Val{mode}(), u0, alg), p))
98-
gs_true = abs.(jacobian_f(u0, p))
99-
if !(isapprox(gs, gs_true, atol = 1e-5))
100-
@show sol.retcode, sol.u
101-
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_jacobian=gs true_jacobian=gs_true
102-
else
103-
@test abs.(gs)abs.(gs_true) atol=1e-5
101+
sol = solve(NonlinearProblem(test_f, u0, p), alg)
102+
if SciMLBase.successful_retcode(sol)
103+
gs = abs.(ForwardDiff.jacobian(solve_with(Val{mode}(), u0, alg), p))
104+
gs_true = abs.(jacobian_f(u0, p))
105+
if !(isapprox(gs, gs_true, atol = 1e-5))
106+
@show sol.retcode, sol.u
107+
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_jacobian=gs true_jacobian=gs_true
108+
else
109+
@test abs.(gs)abs.(gs_true) atol=1e-5
110+
end
104111
end
105112
end
106113
end

0 commit comments

Comments
 (0)