Indeed. SPGBox
mutated the AA.xs0
! I have checked that LBFGSB.jl doesn’t mutate the x0
.
- ForwardDiff and finite difference have almost the same time, consistent across optimization methods
- SPGBox is 40% faster than LBFGSB.jl, even with
copy(xs0)
inside the@btime
loop (I usecopy(xs0)
so that the code is simpler) - LBFGSB.jl is about 2x faster than scipy.optimize(method=‘L-BFGS-B’)
Log:
Benchmarking single function execution
12.977 μs (1 allocation: 160 bytes)
Benchmarking PharmCat v2 (CG) using grad specified by ForwardDiff
383.874 ms (18888 allocations: 3.41 MiB)
-6.263329327214707
Benchmarking SPGBox using grad specified by ForwardDiff
3.363 ms (138 allocations: 31.19 KiB)
-6.263329329419884
Benchmarking PharmCat v2 (CG) using finite difference grad
388.767 ms (34072 allocations: 4.52 MiB)
-6.26332930693809
Benchmarking SPGBox using finite difference grad
3.330 ms (270 allocations: 40.83 KiB)
-6.263329329419884
Benchmarking LBFGSB.jl using grad specified by ForwardDiff
5.198 ms (203 allocations: 44.95 KiB)
-6.263329329419884
Benchmarking LBFGSB.jl using finite difference grad
5.105 ms (401 allocations: 59.48 KiB)
-6.263329329419884
Benchmarking scipy.optimize(method='L-BFGS-B') which uses finite difference grad
10.605 ms (9197 allocations: 447.61 KiB)
-6.263329329419884
Fixed in [BUGFIX] Prevent SPGBox from mutating xs0 · rht/climate_stress_test_benchmark@caea4dd · GitHub.