SciML / JumpProcesses.jl

Build and simulate jump equations like Gillespie simulations and jump diffusions with constant and state-dependent rates and mix with differential equations and scientific machine learning (SciML)
https://docs.sciml.ai/JumpProcesses/stable/
Other
135 stars 35 forks source link

restrict FastBroadcast to 0.3 and delete the extension #425

Closed oscardssmith closed 3 weeks ago

oscardssmith commented 3 weeks ago

Surprisingly enough, with the new FastBroadcast version, everything just seems to work out of the box (and the extension was broken)

isaacsas commented 3 weeks ago

Everything just worked before the extension too, but without the extension it was falling back to very slow default versions. The extension was added because the performance was terrible with these fallbacks.

isaacsas commented 3 weeks ago

What performance impact does dropping the extension have on systems with VariableRateJumps?

isaacsas commented 3 weeks ago

https://github.com/SciML/JumpProcesses.jl/issues/335

It would be unifortunate if the result of this is undoing all the work done to solve that issue

oscardssmith commented 3 weeks ago

Looks like the performance is still good. Using the benchmark from the end of that issue, I see

julia> function test_single_dot(out, array)
            @inbounds  @. out = array + 1.0 * array + 1.2 * array
       end
test_single_dot (generic function with 1 method)

julia> @benchmark test_single_dot(bench_out_array, bench_in_array)
BenchmarkTools.Trial: 7308 samples with 1 evaluation.
 Range (min … max):  600.089 μs …  1.456 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     651.551 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   676.034 μs ± 80.437 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%

    ▄█▅▂                                                        
  ▂▆█████▇▇▇▆▆▅▅▄▄▃▃▃▃▃▂▂▂▂▂▂▂▂▂▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  600 μs          Histogram: frequency by time         1.01 ms <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> @benchmark test_single_dot(base_out_array, base_in_array)
BenchmarkTools.Trial: 7592 samples with 1 evaluation.
 Range (min … max):  604.956 μs …  1.456 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     632.637 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   650.833 μs ± 56.660 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%

     ▄▇█▆▃                                                      
  ▁▄███████▆▅▄▄▄▄▄▄▄▄▃▃▂▃▂▂▂▂▂▂▂▂▂▂▂▁▁▁▂▁▁▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  605 μs          Histogram: frequency by time          829 μs <

 Memory estimate: 0 bytes, allocs estimate: 0.

 julia> function test_single_dot_dot(out, array)
            @inbounds  @.. out = array + 1.0 * array + 1.2 * array
       end
test_single_dot (generic function with 1 method)

julia> @benchmark test_single_dot_dot(base_out_array, base_in_array)
BenchmarkTools.Trial: 7130 samples with 1 evaluation.
 Range (min … max):  576.155 μs …   1.627 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     659.532 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   691.824 μs ± 119.064 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%

   ▄█▆▄▄▄▅▄▄▃▁                                                   
  ▄████████████▇▆▆▅▄▃▃▃▃▂▂▂▂▂▂▂▂▁▁▂▁▁▁▁▁▁▁▁▁▁▁▂▁▁▂▂▁▂▁▂▁▁▁▁▁▁▁▁ ▃
  576 μs           Histogram: frequency by time         1.18 ms <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> @benchmark test_single_dot_dot(bench_out_array, bench_in_array)
BenchmarkTools.Trial: 7530 samples with 1 evaluation.
 Range (min … max):  598.814 μs …  1.321 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     640.346 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   655.685 μs ± 50.883 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%

    ▁▆██▅▃▁                                                     
  ▁▄███████▇▆▆▆▆▇▆▆▆▅▅▅▅▄▄▄▃▃▃▂▃▂▂▂▂▂▂▂▁▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▃
  599 μs          Histogram: frequency by time          846 μs <

 Memory estimate: 0 bytes, allocs estimate: 0.
isaacsas commented 3 weeks ago

Ok, thanks for checking.