-
-
Notifications
You must be signed in to change notification settings - Fork 14
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug 🐞
When solving a simple ODE using a ScaledOperator
, I see many memory allocations. If I initialize the operator as a MatrixOperator
, everything is fine. I think this issue might be related to #246. I also have the same problem using dense matrices.
Expected behavior
Just to have the minimum memory allocations required for an ODE. The memory allocations don't have to scale with the integration time.
Minimal Reproducible Example 👇
T = Float64
N = 100
A = -1 * MatrixOperator(sprand(T, N, N, 0.1))
v = rand(T, N)
A = cache_operator(A, rand(T, N))
tspan = (0.0, 2.0)
prob = ODEProblem{true}(A, v, tspan)
@benchmark solve($prob, Tsit5(), saveat=$[tspan[end]])
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 37.844 μs … 12.317 ms ┊ GC (min … max): 0.00% … 99.32%
Time (median): 43.317 μs ┊ GC (median): 0.00%
Time (mean ± σ): 44.688 μs ± 122.845 μs ┊ GC (mean ± σ): 2.74% ± 0.99%
█▃ ▁▁▃▂
▂▆███▇▆▆▆▆▆▆█████▇▆▅▄▄▄▃▃▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ ▃
37.8 μs Histogram: frequency by time 64.8 μs <
Memory estimate: 34.66 KiB, allocs estimate: 425.
And with a simple MatrixOperator
everything is fine
A = MatrixOperator(-1 * sprand(T, N, N, 0.1))
v = rand(T, N)
A = cache_operator(A, rand(T, N))
tspan = (0.0, 2.0)
prob = ODEProblem{true}(A, v, tspan)
@benchmark solve($prob, Tsit5(), saveat=$[tspan[end]])
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 31.964 μs … 224.430 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 36.132 μs ┊ GC (median): 0.00%
Time (mean ± σ): 36.747 μs ± 4.241 μs ┊ GC (mean ± σ): 0.00% ± 0.00%
▁ ▁█▅▂▂▂ ▂
▁▁▆█▆▃▃▂▃▃▅▅▅██████▇▇▇██▇▇▆▆▅▅▄▄▄▃▃▃▃▃▃▂▃▃▂▂▃▃▂▂▂▂▂▂▁▂▁▁▁▁▁▁ ▃
32 μs Histogram: frequency by time 44.8 μs <
Memory estimate: 17.25 KiB, allocs estimate: 54.
Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
Status `~/GitHub/Research/Undef/Benchmark QuantumToolbox Stable/Dev Version/Project.toml`
[6e4b80f9] BenchmarkTools v1.5.0
[f68482b8] Cthulhu v2.15.2
[1dea7af3] OrdinaryDiffEq v6.89.0
[6c2fb7c5] QuantumToolbox v0.18.0 `~/.julia/dev/QuantumToolbox`
[295af30f] Revise v3.6.1
[c0aeaf25] SciMLOperators v0.3.10
- Output of
versioninfo()
Julia Version 1.11.0
Commit 501a4f25c2b (2024-10-07 11:40 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13900KF
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 16 default, 0 interactive, 8 GC (on 32 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS = 16
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working