Skip to content

Commit

Permalink
Merge pull request #371 from SciML/ap/fast_testing
Browse files Browse the repository at this point in the history
Parallel Testing
  • Loading branch information
avik-pal authored Feb 9, 2024
2 parents f3b0b1b + 49ca687 commit f2702b2
Show file tree
Hide file tree
Showing 26 changed files with 639 additions and 729 deletions.
8 changes: 5 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ steps:
- JuliaCI/julia#v1:
version: "1"
- JuliaCI/julia-test#v1:
coverage: false # 1000x slowdown
coverage: true
agents:
queue: "juliagpu"
cuda: "*"
timeout_in_minutes: 30
timeout_in_minutes: 60
# Don't run Buildkite if the commit message includes the text [skip tests]
if: build.message !~ /\[skip tests\]/

env:
GROUP: GPU
JULIA_PKG_SERVER: "" # it often struggles with our large artifacts
# SECRET_CODECOV_TOKEN: "..."
RETESTITEMS_NWORKERS: 4
RETESTITEMS_NWORKER_THREADS: 2
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=="
13 changes: 7 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ jobs:
fail-fast: false
matrix:
group:
- RootFinding
- NLLSSolvers
- 23TestProblems
- Wrappers
- Miscellaneous
- Core
version:
- '1.10'
- "1"
os:
- ubuntu-latest
- macos-latest
Expand All @@ -49,9 +45,14 @@ jobs:
env:
GROUP: ${{ matrix.group }}
JULIA_NUM_THREADS: 11
RETESTITEMS_NWORKERS: 4
RETESTITEMS_NWORKER_THREADS: 2
- uses: julia-actions/julia-processcoverage@v1
with:
directories: src,ext
- uses: codecov/codecov-action@v4
with:
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
fail_ci_if_error: true
13 changes: 8 additions & 5 deletions .github/workflows/Downgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ on:
branches:
- master
paths-ignore:
- 'docs/**'
- "docs/**"
push:
branches:
- master
paths-ignore:
- 'docs/**'
- "docs/**"
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['1']
version: ["1"]
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
- uses: cjdoris/julia-downgrade-compat-action@v1
# if: ${{ matrix.version == '1.6' }}
with:
skip: Pkg,TOML
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-runtest@v1
env:
JULIA_NUM_THREADS: 11
RETESTITEMS_NWORKERS: 4
RETESTITEMS_NWORKER_THREADS: 2
9 changes: 7 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolve"
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
authors = ["SciML"]
version = "3.5.3"
version = "3.5.4"

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

[targets]
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"]
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"]
5 changes: 3 additions & 2 deletions src/algorithms/levenberg_marquardt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ end
J_diag_cache
J_damped
damping_f
initial_damping
end

function reinit_cache!(cache::LevenbergMarquardtDampingCache, args...; kwargs...)
cache.λ = cache.damping_f.initial_damping
cache.λ = cache.initial_damping
cache.λ_factor = cache.damping_f.increase_factor
if !(cache.DᵀD isa Number)
if can_setindex(cache.DᵀD.diag)
Expand Down Expand Up @@ -110,7 +111,7 @@ function __internal_init(prob::AbstractNonlinearProblem,
J_damped = T(initial_damping) .* DᵀD
return LevenbergMarquardtDampingCache(T(f.increase_factor), T(f.decrease_factor),
T(f.min_damping), T(f.increase_factor), T(initial_damping), DᵀD, J_diag_cache,
J_damped, f)
J_damped, f, T(initial_damping))
end

(damping::LevenbergMarquardtDampingCache)(::Nothing) = damping.J_damped
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@testsetup module RobustnessTesting
using NonlinearSolve, LinearAlgebra, LinearSolve, NonlinearProblemLibrary, Test

problems = NonlinearProblemLibrary.problems
Expand Down Expand Up @@ -36,7 +37,10 @@ function test_on_library(problems, dicts, alg_ops, broken_tests, ϵ = 1e-4;
end
end

@testset "NewtonRaphson 23 Test Problems" begin
export test_on_library, problems, dicts
end

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

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

# @testset "TrustRegion 23 Test Problems" begin
# alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple),
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan),
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei),
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan),
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin),
# TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve))

# broken_tests = Dict(alg => Int[] for alg in alg_ops)
# broken_tests[alg_ops[1]] = [11, 21]
# broken_tests[alg_ops[2]] = [11, 21]
# broken_tests[alg_ops[3]] = [11, 21]
# broken_tests[alg_ops[4]] = [11, 21]
# broken_tests[alg_ops[5]] = [21]
# broken_tests[alg_ops[6]] = [21]

# test_on_library(problems, dicts, alg_ops, broken_tests)
# end

@testset "LevenbergMarquardt 23 Test Problems" begin
@testitem "TrustRegion" setup=[RobustnessTesting] begin
alg_ops = (TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Simple),
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Fan),
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Hei),
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Yuan),
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.Bastin),
TrustRegion(; radius_update_scheme = RadiusUpdateSchemes.NLsolve))

broken_tests = Dict(alg => Int[] for alg in alg_ops)
broken_tests[alg_ops[1]] = [11, 21]
broken_tests[alg_ops[2]] = [11, 21]
broken_tests[alg_ops[3]] = [11, 21]
broken_tests[alg_ops[4]] = [8, 11, 21]
broken_tests[alg_ops[5]] = [21]
broken_tests[alg_ops[6]] = [11, 21]

test_on_library(problems, dicts, alg_ops, broken_tests)
end

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

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

@testset "DFSane 23 Test Problems" begin
@testitem "DFSane" setup=[RobustnessTesting] begin
alg_ops = (DFSane(),)

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

@testset "Broyden 23 Test Problems" begin
@testitem "Broyden" retries=5 setup=[RobustnessTesting] begin
alg_ops = (Broyden(),
Broyden(; init_jacobian = Val(:true_jacobian)),
Broyden(; update_rule = Val(:bad_broyden)),
Expand All @@ -101,7 +107,7 @@ end
test_on_library(problems, dicts, alg_ops, broken_tests)
end

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

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

@testset "PseudoTransient 23 Test Problems" begin
@testitem "PseudoTransient" setup=[RobustnessTesting] 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
81 changes: 44 additions & 37 deletions test/core/forward_ad.jl → test/core/forward_ad_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ForwardDiff,
NonlinearSolve, MINPACK, NLsolve, StaticArrays, Sundials, Test, LinearAlgebra
@testsetup module ForwardADTesting
using Reexport, NonlinearSolve
@reexport using ForwardDiff, MINPACK, NLsolve, StaticArrays, Sundials, LinearAlgebra

test_f!(du, u, p) = (@. du = u^2 - p)
test_f(u, p) = (@. u^2 - p)
Expand Down Expand Up @@ -58,49 +59,55 @@ __compatible(::NLsolveJL, ::Val{:oop_cache}) = false
__compatible(::KINSOL, ::Val{:iip_cache}) = false
__compatible(::KINSOL, ::Val{:oop_cache}) = false

@testset "ForwardDiff.jl Integration: $(alg)" for alg in (NewtonRaphson(), TrustRegion(),
LevenbergMarquardt(), PseudoTransient(; alpha_initial = 10.0), Broyden(), Klement(),
DFSane(), nothing, NLsolveJL(), CMINPACK(), KINSOL())
us = (2.0, @SVector[1.0, 1.0], [1.0, 1.0], ones(2, 2), @SArray ones(2, 2))
export test_f!, test_f, jacobian_f, solve_with, __compatible
end

@testitem "ForwardDiff.jl Integration" setup=[ForwardADTesting] begin
for alg in (NewtonRaphson(), TrustRegion(),
LevenbergMarquardt(), PseudoTransient(; alpha_initial = 10.0), Broyden(), Klement(),
DFSane(), nothing, NLsolveJL(), CMINPACK(),
KINSOL(; globalization_strategy = :LineSearch))
us = (2.0, @SVector[1.0, 1.0], [1.0, 1.0], ones(2, 2), @SArray ones(2, 2))

@testset "Scalar AD" begin
for p in 1.0:0.1:100.0, u0 in us, mode in (:iip, :oop, :iip_cache, :oop_cache)
__compatible(u0, alg) || continue
__compatible(u0, Val(mode)) || continue
__compatible(alg, Val(mode)) || continue
@testset "Scalar AD" begin
for p in 1.0:0.1:100.0, u0 in us, mode in (:iip, :oop, :iip_cache, :oop_cache)
__compatible(u0, alg) || continue
__compatible(u0, Val(mode)) || continue
__compatible(alg, Val(mode)) || continue

sol = solve(NonlinearProblem(test_f, u0, p), alg)
if SciMLBase.successful_retcode(sol)
gs = abs.(ForwardDiff.derivative(solve_with(Val{mode}(), u0, alg), p))
gs_true = abs.(jacobian_f(u0, p))
if !(isapprox(gs, gs_true, atol = 1e-5))
@show sol.retcode, sol.u
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_gradient=gs true_gradient=gs_true
else
@test abs.(gs)abs.(gs_true) atol=1e-5
sol = solve(NonlinearProblem(test_f, u0, p), alg)
if SciMLBase.successful_retcode(sol)
gs = abs.(ForwardDiff.derivative(solve_with(Val{mode}(), u0, alg), p))
gs_true = abs.(jacobian_f(u0, p))
if !(isapprox(gs, gs_true, atol = 1e-5))
@show sol.retcode, sol.u
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_gradient=gs true_gradient=gs_true
else
@test abs.(gs)abs.(gs_true) atol=1e-5
end
end
end
end
end

@testset "Jacobian" begin
for u0 in us, p in ([2.0, 1.0], [2.0 1.0; 3.0 4.0]),
mode in (:iip, :oop, :iip_cache, :oop_cache)
@testset "Jacobian" begin
for u0 in us, p in ([2.0, 1.0], [2.0 1.0; 3.0 4.0]),
mode in (:iip, :oop, :iip_cache, :oop_cache)

__compatible(u0, p) || continue
__compatible(u0, alg) || continue
__compatible(u0, Val(mode)) || continue
__compatible(alg, Val(mode)) || continue
__compatible(u0, p) || continue
__compatible(u0, alg) || continue
__compatible(u0, Val(mode)) || continue
__compatible(alg, Val(mode)) || continue

sol = solve(NonlinearProblem(test_f, u0, p), alg)
if SciMLBase.successful_retcode(sol)
gs = abs.(ForwardDiff.jacobian(solve_with(Val{mode}(), u0, alg), p))
gs_true = abs.(jacobian_f(u0, p))
if !(isapprox(gs, gs_true, atol = 1e-5))
@show sol.retcode, sol.u
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_jacobian=gs true_jacobian=gs_true
else
@test abs.(gs)abs.(gs_true) atol=1e-5
sol = solve(NonlinearProblem(test_f, u0, p), alg)
if SciMLBase.successful_retcode(sol)
gs = abs.(ForwardDiff.jacobian(solve_with(Val{mode}(), u0, alg), p))
gs_true = abs.(jacobian_f(u0, p))
if !(isapprox(gs, gs_true, atol = 1e-5))
@show sol.retcode, sol.u
@error "ForwardDiff Failed for u0=$(u0) and p=$(p) with $(alg)" forwardiff_jacobian=gs true_jacobian=gs_true
else
@test abs.(gs)abs.(gs_true) atol=1e-5
end
end
end
end
Expand Down
Loading

2 comments on commit f2702b2

@avik-pal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/100536

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.5.4 -m "<description of version>" f2702b2dc46ee5c1be9c39a89a667f270e1f3cf2
git push origin v3.5.4

Please sign in to comment.