Skip to content

OOM on cyclical network #2015

Closed
Closed
@evetion

Description

@evetion

Over at https://github.com/Deltares/Ribasim.jl, we're using MTK to build large hydrological models. What we see is that on some models, especially those that form a cyclic graph (but not on all of them), we run out of memory in the following code:

https://github.com/SciML/ModelingToolkit.jl/blob/a9dc1fc8d26b02e183ce5cc67e7471aae019d14b/src/structural_transformation/codegen.jl#L116...L121

The size of next_assignments keeps growing for each loop, hitting 1e9 for a system with 1290 states. Smaller models, even those with many cyclic parts converge much quicker. This behavior has also improved in the last months, now only running out of memory on the largest models.

With this serialized structurally simplified sim here to deserialize, we have the following MWE for the current MTK master branch, Julia 1.9.

using Serialization
using ModelingToolkit
using DataInterpolations
sim = deserialize("cached_simplified_sim.jls")
tspan = (1.5463008e9, 1.5513984e9)
prob = ODAEProblem(sim, [], tspan; sparse = true)  # OOM

@visr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions