Skip to content

Strict in-place sparse Jacobians now cause errors when they don't anticipate the mass matrix #2653

Closed
@gdalle

Description

@gdalle

Describe the bug 🐞

In #2567, it seems that the sparsity pattern is modified using the mass_matrix outside of the DI pipeline (see #2567 (comment)). This is an issue because:

  1. during preparation, the sparsity_detector from AutoSparse won't be aware of this change
  2. during preparation, the coloring_algorithm from AutoSparse will compute a coloring for the unmodified sparsity pattern, and prepare decompression accordingly
  3. during execution, the function SparseMatrixColorings.decompress! will either error or return incorrect results because it expected the unmodified sparsity pattern

This problem was detected by Deltares/Ribasim#2201

Expected behavior

Any modification of the sparsity pattern should be done in a way that allows the sparsity_detector to see it.

Minimal Reproducible Example 👇

Not available yet.

Error & Stacktrace ⚠️

The typical stack trace could look something like:

ERROR: DimensionMismatch: all inputs to eachindex must have the same indices, got Base.OneTo(28) and Base.OneTo(26)
Stacktrace:
  [1] throw_eachindex_mismatch_indices(::IndexLinear, ::Base.OneTo{Int64}, ::Vararg{Base.OneTo{Int64}})
    @ Base ./abstractarray.jl:325
  [2] eachindex
    @ ./abstractarray.jl:393 [inlined]
  [3] eachindex
    @ ./abstractarray.jl:382 [inlined]
  [4] decompress!
    @ ~/.julia/packages/SparseMatrixColorings/BED6Y/src/decompression.jl:361 [inlined]
  [5] _sparse_jacobian_aux!(::Tuple{typeof(Ribasim.water_balance!), Vector{Float64}}, 
  [6] jacobian!
    @ ~/.julia/packages/DifferentiationInterface/7eD1K/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl:237 [inlined]

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()

Not available yet

  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)

Not available yet

  • Output of versioninfo()

Not available yet

Additional context

This should only happen for people who have upgraded to OrdinaryDiffEqDifferentiation v1.5.0, released a few hours ago

Ping @jClugstor @oscardssmith @ChrisRackauckas

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions