Repository navigation
fix OOP dampen_jacobian!! for scalar damping - #1068
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dampen_jacobian!!has a mutable path (damping written in place) and an out-of-place fallbackfor Jacobians that cannot
setindex!. For scalarDthe fallback was wrong:Needs to be
J + D*Ito actually damp the diagonal.Impact
StaticArrays, CPU. An
SMatrixJacobian takes the fallback, so PseudoTransient andLevenberg-Marquardt have been damping static problems wrong. It fails silently: damping does not
move the fixed point, so the root is still correct, only the iteration degrades. On
f(u) = [u₁²-2, u₂²-3], PseudoTransient took 736 steps with anSVectorvs 387 with aVector.After the fix the two agree exactly.
GPU sparse.
CuSparse*matrices are mutable only throughnonzeros, so they take thefallback too. This line is what made PseudoTransient fail with
Scalar indexing is disallowedon a
CuSparseMatrixCSC/CuSparseMatrixCSRjac_prototype; verified on hardware that it nowconverges for both layouts. (
J + D*Ireturns anSMatrixfor static input and aCuSparseMatrixCSCfor GPU sparse, so one expression covers both.)Test
lib/NonlinearSolveBase/test/dampen_jacobian.jlpins the invariant the comment states: themutable and out-of-place paths must produce the same matrix, for all three damping types
(
Number,Diagonal,AbstractMatrix). Fails 3 assertions with the fix reverted.Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.