-
-
Notifications
You must be signed in to change notification settings - Fork 16
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 = 16Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working