Skip to content

Conversation

@jClugstor
Copy link
Member

@jClugstor jClugstor commented Apr 3, 2025

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Adds test to make sure that the issues brought up in
#2653 (comment) are taken care of.

This will also need to come with a bump to SparseMatrixColorings to a version that's not out yet, I'll need to add the bump when the new version comes out.

@ChrisRackauckas
Copy link
Member

Fails because of missing import.

This would require a bump to the minimum in order to pass?

@jClugstor
Copy link
Member Author

Yes, it will need to use gdalle/SparseMatrixColorings.jl#224, which hasn't been released yet. I jumped the gun on this one a little bit.

@ChrisRackauckas
Copy link
Member

Okay, update this PR to do all of that when it's out and then ping me or @oscardssmith for review. I'm going to ignore this for now.

@jClugstor jClugstor changed the title Add sparsity pattern mismatch test Fix sparsity pattern mismatch and test Apr 4, 2025
@jClugstor
Copy link
Member Author

Fixes #2653

Comment on lines 175 to 183
f.jac(J, duprev, uprev, p, uf.α * uf.invγdt, t)
# need to do some jank here to account for sparsity pattern of W
# https://github.com/SciML/OrdinaryDiffEq.jl/issues/2653

# we need to set all nzval to a non-zero number
# otherwise in the following line any zero gets interpreted as a structural zero
integrator.f.jac_prototype.nzval .= 1.0
J .= 1.0 .* integrator.f.jac_prototype
J.nzval .= 0.0
f.jac(J, uprev, p, t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the right Jac call. This is the DAE branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the DAE branch not need this as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, just a copy paste error

Comment on lines 206 to 207
MM = integrator.f.mass_matrix isa UniformScaling ? integrator.f.mass_matrix(length(integrator.u)) : integrator.f.mass_matrix
J .= J .+ MM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't go here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this will cause the mass matrix to be applied twice, won't it.

This might need to go in jacobian2W!? Looks like that might slow things down though...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jacobian2W! already does this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, looks like taking away those lines makes it work without applying the MM twice. I thought there would be issues in jacobian2W! if the sparisty pattern of J was still the same as the jac_prototypes, but apparently not.

end
end

# test for https://github.com/SciML/OrdinaryDiffEq.jl/issues/2653#issuecomment-2778430025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use the simpler MWE here, which does not depend on how SMC handles sparse matrices: #2653 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, good idea.

jClugstor and others added 3 commits April 4, 2025 12:06
ChrisRackauckas and others added 2 commits April 4, 2025 15:01
Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com>
Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com>
@ChrisRackauckas
Copy link
Member

The failures are internal ITP shifting by one ulp and enzyme. I'll handle those separately.

@ChrisRackauckas ChrisRackauckas merged commit 869de2f into SciML:master Apr 5, 2025
97 of 147 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants