Skip to content

Commit 544cc32

Browse files
committed
fix: multiple fixes
1 parent 3900d24 commit 544cc32

File tree

3 files changed

+53
-40
lines changed

3 files changed

+53
-40
lines changed

benchmarks/NonlinearProblem/Manifest.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.9"
44
manifest_format = "2.0"
5-
project_hash = "cd9959830f6db746c990086c85b190f684bf136a"
5+
project_hash = "dfc256be508dd699050df95ae79fddc9918030f6"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "e2478490447631aedba0823d4d7a80b2cc8cdb32"
@@ -1119,9 +1119,9 @@ weakdeps = ["Unitful"]
11191119

11201120
[[deps.IntervalArithmetic]]
11211121
deps = ["CRlibm_jll", "LinearAlgebra", "MacroTools", "OpenBLASConsistentFPCSR_jll", "RoundingEmulator"]
1122-
git-tree-sha1 = "5aad168b75fc3b6b25e99feb1e6e3168d41e4c08"
1122+
git-tree-sha1 = "2c337f943879911c74bb62c927b65b9546552316"
11231123
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
1124-
version = "0.22.28"
1124+
version = "0.22.29"
11251125
weakdeps = ["DiffRules", "ForwardDiff", "IntervalSets", "RecipesBase"]
11261126

11271127
[deps.IntervalArithmetic.extensions]
@@ -1928,9 +1928,9 @@ version = "0.12.3"
19281928

19291929
[[deps.Parsers]]
19301930
deps = ["Dates", "PrecompileTools", "UUIDs"]
1931-
git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
1931+
git-tree-sha1 = "44f6c1f38f77cafef9450ff93946c53bd9ca16ff"
19321932
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
1933-
version = "2.8.1"
1933+
version = "2.8.2"
19341934

19351935
[[deps.Pixman_jll]]
19361936
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LLVMOpenMP_jll", "Libdl"]
@@ -2425,9 +2425,9 @@ version = "0.4.18"
24252425

24262426
[[deps.SpecialFunctions]]
24272427
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
2428-
git-tree-sha1 = "64cca0c26b4f31ba18f13f6c12af7c85f478cfde"
2428+
git-tree-sha1 = "41852b8679f78c8d8961eeadc8f62cef861a52e3"
24292429
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
2430-
version = "2.5.0"
2430+
version = "2.5.1"
24312431
weakdeps = ["ChainRulesCore"]
24322432

24332433
[deps.SpecialFunctions.extensions]
@@ -2591,9 +2591,9 @@ version = "0.2.2"
25912591

25922592
[[deps.SymbolicUtils]]
25932593
deps = ["AbstractTrees", "ArrayInterface", "Bijections", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "ExproniconLite", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "TaskLocalValues", "TermInterface", "TimerOutputs", "Unityper"]
2594-
git-tree-sha1 = "516a23c7f8f5204aa110b2447c77df1d0440ec7d"
2594+
git-tree-sha1 = "2c9879cd67d1bb2f2989669e5849639bb4d3c792"
25952595
uuid = "d1185830-fcd6-423d-90d6-eec64667417b"
2596-
version = "3.26.0"
2596+
version = "3.26.1"
25972597

25982598
[deps.SymbolicUtils.extensions]
25992599
SymbolicUtilsLabelledArraysExt = "LabelledArrays"
@@ -2802,9 +2802,9 @@ version = "5.8.1+0"
28022802

28032803
[[deps.Xorg_libX11_jll]]
28042804
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
2805-
git-tree-sha1 = "9dafcee1d24c4f024e7edc92603cedba72118283"
2805+
git-tree-sha1 = "b5899b25d17bf1889d25906fb9deed5da0c15b3b"
28062806
uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc"
2807-
version = "1.8.6+3"
2807+
version = "1.8.12+0"
28082808

28092809
[[deps.Xorg_libXau_jll]]
28102810
deps = ["Artifacts", "JLLWrappers", "Libdl"]
@@ -2820,15 +2820,15 @@ version = "1.1.6+0"
28202820

28212821
[[deps.Xorg_libXext_jll]]
28222822
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll"]
2823-
git-tree-sha1 = "d7155fea91a4123ef59f42c4afb5ab3b4ca95058"
2823+
git-tree-sha1 = "a4c0ee07ad36bf8bbce1c3bb52d21fb1e0b987fb"
28242824
uuid = "1082639a-0dae-5f34-9b06-72781eeb8cb3"
2825-
version = "1.3.6+3"
2825+
version = "1.3.7+0"
28262826

28272827
[[deps.Xorg_libXrender_jll]]
28282828
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll"]
2829-
git-tree-sha1 = "a490c6212a0e90d2d55111ac956f7c4fa9c277a6"
2829+
git-tree-sha1 = "7ed9347888fac59a618302ee38216dd0379c480d"
28302830
uuid = "ea2f1a96-1ddc-540d-b46f-429655e07cfa"
2831-
version = "0.9.11+1"
2831+
version = "0.9.12+0"
28322832

28332833
[[deps.Xorg_libxcb_jll]]
28342834
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libXau_jll", "Xorg_libXdmcp_jll"]

benchmarks/NonlinearProblem/Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2323
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
2424
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
2525
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
26+
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
2627
SpeedMapping = "f1835b91-879b-4a3f-a438-e4baacf14412"
2728
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
2829
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -60,5 +61,6 @@ StaticArrays = "1"
6061
Sundials = "4.22"
6162
Symbolics = "5, 6"
6263

63-
[sources]
64-
NonlinearSolve = {url = "https://github.com/SciML/NonlinearSolve.jl", rev = "ap/petsc_debug"}
64+
[sources.NonlinearSolve]
65+
rev = "ap/petsc_debug"
66+
url = "https://github.com/SciML/NonlinearSolve.jl"

benchmarks/NonlinearProblem/bruss.jmd

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Fetch required packages
1111
```julia
1212
using NonlinearSolve, SparseDiffTools, LinearAlgebra, SparseArrays, DiffEqDevTools,
1313
CairoMakie, Symbolics, BenchmarkTools, PolyesterForwardDiff, LinearSolve, Sundials,
14-
Enzyme, SparseConnectivityTracer, DifferentiationInterface
14+
Enzyme, SparseConnectivityTracer, DifferentiationInterface, SparseMatrixColorings
1515
import NLsolve, MINPACK, PETSc, RecursiveFactorization
1616

1717
const RUS = RadiusUpdateSchemes;
@@ -156,31 +156,38 @@ function cache_and_compute_10_jacobians(adtype, f!::F, y, x, p) where {F}
156156
return J
157157
end
158158

159-
Ns = [2^i for i in 1:8]
159+
Ns = [2^i for i in 3:8];
160160

161161
adtypes = [
162162
(
163-
AutoSparse(AutoFiniteDiff(); sparsity_detector=TracerSparsityDetector()),
163+
AutoSparse(
164+
AutoFiniteDiff();
165+
sparsity_detector=TracerSparsityDetector(),
166+
coloring_algorithm=GreedyColoringAlgorithm(LargestFirst())
167+
),
164168
[:finitediff, :exact_sparse]
165169
),
166170
(
167171
AutoSparse(
168172
AutoPolyesterForwardDiff(; chunksize=8);
169-
sparsity_detector=TracerSparsityDetector()
173+
sparsity_detector=TracerSparsityDetector(),
174+
coloring_algorithm=GreedyColoringAlgorithm(LargestFirst())
170175
),
171176
[:polyester, :exact_sparse]
172177
),
173178
(
174179
AutoSparse(
175180
AutoEnzyme(; mode=Enzyme.Forward);
176-
sparsity_detector=TracerSparsityDetector()
181+
sparsity_detector=TracerSparsityDetector(),
182+
coloring_algorithm=GreedyColoringAlgorithm(LargestFirst())
177183
),
178184
[:enzyme, :exact_sparse]
179185
),
180186
(
181187
AutoSparse(
182188
AutoFiniteDiff();
183-
sparsity_detector=DenseSparsityDetector(AutoFiniteDiff(); atol=1e-5)
189+
sparsity_detector=DenseSparsityDetector(AutoFiniteDiff(); atol=1e-5),
190+
coloring_algorithm=GreedyColoringAlgorithm(LargestFirst())
184191
),
185192
[:finitediff, :approx_sparse]
186193
),
@@ -189,7 +196,8 @@ adtypes = [
189196
AutoPolyesterForwardDiff(; chunksize=8);
190197
sparsity_detector=DenseSparsityDetector(
191198
AutoPolyesterForwardDiff(; chunksize=8); atol=1e-5
192-
)
199+
),
200+
coloring_algorithm=GreedyColoringAlgorithm(LargestFirst())
193201
),
194202
[:polyester, :approx_sparse]
195203
),
@@ -198,17 +206,18 @@ adtypes = [
198206
AutoEnzyme(; mode=Enzyme.Forward);
199207
sparsity_detector=DenseSparsityDetector(
200208
AutoEnzyme(; mode=Enzyme.Forward); atol=1e-5
201-
)
209+
),
210+
coloring_algorithm=GreedyColoringAlgorithm(LargestFirst())
202211
),
203212
[:enzyme, :approx_sparse]
204213
),
205214
(
206215
AutoPolyesterForwardDiff(; chunksize=8),
207216
[:polyester, :none]
208217
),
209-
]
218+
];
210219

211-
times = Matrix{Float64}(undef, length(Ns), length(adtypes))
220+
times = Matrix{Float64}(undef, length(Ns), length(adtypes));
212221

213222
for (i, N) in enumerate(Ns)
214223
str = "$(lpad(N, 10)) "
@@ -227,6 +236,7 @@ for (i, N) in enumerate(Ns)
227236
end
228237
println(str)
229238
end
239+
nothing
230240
```
231241

232242
Plotting the results.
@@ -255,10 +265,11 @@ fig = begin
255265
colormap=:tableau_20)
256266

257267
ax = Axis(fig[1, 2]; title="Scaling of Sparse Jacobian Computation",
258-
titlesize=22, titlegap=10, xscale=log10, yscale=log10,
268+
titlesize=22, titlegap=10, xscale=log2, yscale=log2,
259269
xticksize=20, yticksize=20, xticklabelsize=20, yticklabelsize=20,
260270
xtickwidth=2.5, ytickwidth=2.5, spinewidth=2.5,
261-
xlabel=L"Input Dimension ($\mathbf{N}$)", ylabel=L"Time $\mathbf{(s)}$", xlabelsize=22,
271+
xlabel=L"Input Dimension ($\mathbf{N}$)",
272+
ylabel=L"Time $\mathbf{(s)}$", xlabelsize=22,
262273
ylabelsize=22, yaxisposition=:right)
263274

264275
colors = cgrad(:tableau_20, length(adtypes); categorical=true)
@@ -334,7 +345,7 @@ fig = begin
334345
[symbol_to_adname[adtypes[idx][2][1]] for idx in local_sparse_idxs],
335346
[symbol_to_adname[adtypes[idx][2][1]] for idx in non_sparse_idxs],
336347
],
337-
["Exact Sparsity", "Approx. Local Sparsity", "No Sparsity"];
348+
["Exact Sparsity", "Approx. Local Sparsity", "Dense"];
338349
position=:rb, framevisible=true, framewidth=2.5, titlesize=18,
339350
labelsize=16, patchsize=(40.0f0, 20.0f0)
340351
)
@@ -447,9 +458,9 @@ fig = begin
447458
theme = Theme(Lines = (cycle = cycle,), Scatter = (cycle = cycle,))
448459
LINESTYLES = Dict(
449460
(:nonlinearsolve, :none) => :solid,
450-
# (:nonlinearsolve, :approx) => :dash,
451461
(:nonlinearsolve, :exact) => :dashdot,
452462
# (:simplenonlinearsolve, :none) => :solid,
463+
(:wrapper, :exact) => :dash,
453464
(:wrapper, :none) => :dot,
454465
)
455466

@@ -553,20 +564,20 @@ Ns = 2 .^ (2:7)
553564
solvers_scaling_jacobian_free = [
554565
(; pkg = :nonlinearsolve, name = "Newton Krylov", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES())),
555566
(; pkg = :nonlinearsolve, name = "Newton Krylov (ILU)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; precs = incompletelu), concrete_jac = true)),
556-
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG)", alg = NewtonRaphson(; linsolve = KrylovJL_CG(; precs = algebraicmultigrid), concrete_jac = true)),
557-
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG Jacobi)", alg = NewtonRaphson(; linsolve = KrylovJL_CG(; precs = algebraicmultigrid_jacobi), concrete_jac = true)),
567+
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid), concrete_jac = true)),
568+
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG Jacobi)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid_jacobi), concrete_jac = true)),
558569
(; pkg = :wrapper, name = "Newton Krylov [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", snes_mf = true)),
559570
(; pkg = :wrapper, name = "Newton Krylov (ILU) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "ilu")),
560-
(; pkg = :wrapper, name = "Newton Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "cg", pc_type = "gamg")),
561-
(; pkg = :wrapper, name = "Newton Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "cg", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi")),
571+
(; pkg = :wrapper, name = "Newton Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "gamg")),
572+
(; pkg = :wrapper, name = "Newton Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi")),
562573
(; pkg = :nonlinearsolve, name = "TR Krylov", alg = TrustRegion(; linsolve = KrylovJL_GMRES())),
563574
(; pkg = :nonlinearsolve, name = "TR Krylov (ILU)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; precs = incompletelu), concrete_jac = true)),
564-
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG)", alg = TrustRegion(; linsolve = KrylovJL_CG(; precs = algebraicmultigrid), concrete_jac = true)),
565-
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG Jacobi)", alg = TrustRegion(; linsolve = KrylovJL_CG(; precs = algebraicmultigrid_jacobi), concrete_jac = true)),
575+
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid), concrete_jac = true)),
576+
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG Jacobi)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid_jacobi), concrete_jac = true)),
566577
(; pkg = :wrapper, name = "TR Krylov [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", snes_mf = true)),
567578
(; pkg = :wrapper, name = "TR Krylov (ILU) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "ilu")),
568-
(; pkg = :wrapper, name = "TR Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "cg", pc_type = "gamg")),
569-
(; pkg = :wrapper, name = "TR Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "cg", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi")),
579+
(; pkg = :wrapper, name = "TR Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "gamg")),
580+
(; pkg = :wrapper, name = "TR Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi")),
570581
(; pkg = :wrapper, name = "Newton Krylov [Sundials]", alg = KINSOL(; linear_solver = :GMRES)),
571582
]
572583

@@ -787,7 +798,7 @@ fig = begin
787798
cycle = Cycle([:marker], covary = true)
788799
plot_theme = Theme(Lines = (; cycle), Scatter = (; cycle))
789800

790-
with_theme(plot_theme) do
801+
with_theme(plot_theme) do
791802
fig = Figure(; size = (WIDTH, HEIGHT))
792803
# `textbf` doesn't work
793804
ax = Axis(fig[1, 1], ylabel = L"Time $\mathbf{(s)}$",

0 commit comments

Comments
 (0)