Repository navigation
Conversation
When `inline_linear_sccs = true`, an algebraic variable solved by an inline linear SCC becomes observed. `contract_variables` recovers the incidence of an eliminated variable from its matched equation, but this variable is solved from the whole block, so equations that used it lost their dependencies. The torn system's jacobian sparsity, which MTK reads off this graph, then dropped nonzero entries, e.g. `D(x) ~ xˍt` with `xˍt` a function of `x` and `y`. Make every other equation incident on such a variable also incident on the variables of the block's solution, as is already done for derivative variables. License: AGPL-3.0-only Copyright: JuliaHub, Inc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ambujone
reviewed
Dec 1, 2026
ambujone
left a comment
There was a problem hiding this comment.
Confirmed that the new testset fails without the change (4/4 S .| iszero.(J) cases) and passes with it, and the full MTKTearing suite passes on 1.13. The invariant (the reported sparsity covers every nonzero of the ForwardDiff Jacobian) is the right one to test.
Two small comments:
- In the algebraic branch the loop also visits the other equations of the same block (they are neighbours of
iv). That only over-approximates the incidence, but it is different from what a reader of the derivative branch above expects. Is that intentional? A short comment would help. - The derivative branch does
rem_edge!(graph, e, iv)and this one deliberately does not, becauseivstays observed. Please say so in the comment, since the two branches now look almost identical.
Nothing blocking from my side; looks right.
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.
When
inline_linear_sccs = true, an algebraic variable solved by an inline linear SCC becomes observed.contract_variablesrecovers the incidence of an eliminated variable from its matched equation, but this variable is solved from the whole block, so equations that used it lost their dependencies. The torn system's jacobian sparsity, which MTK reads off this graph, then dropped nonzero entries, e.g.D(x) ~ xˍtwithxˍta function ofxandy.Make every other equation incident on such a variable also incident on the variables of the block's solution, as is already done for derivative variables.
License: AGPL-3.0-only
Copyright: JuliaHub, Inc.