Hand BrownFullBasicInit the dense AD backend for a DAEProblem - #4544
Draft
ChrisRackauckas wants to merge 1 commit into
Draft
ChrisRackauckas wants to merge 1 commit into
ChrisRackauckas wants to merge 1 commit into
Conversation
`prepare_alg` wraps the solver's autodiff in `AutoSparse` when the
`DAEFunction` carries a sparse `jac_prototype`. The in-place
`BrownFullBasicInit` path for a `DAEProblem` then built
`NewtonRaphson(autodiff = alg_autodiff(integrator.alg))`, and NonlinearSolve
v4 rejects an `AutoSparse` autodiff outright ("Specifying a sparse AD type
for Nonlinear Problems was removed in v4"), so every sparse-Jacobian DAE with
inconsistent initial conditions errored before the first step. Unwrap with
`ADTypes.dense_ad`, as the mass-matrix `ODEProblem` path already does.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Agent-Harness: Claude Code 2.1.270
Agent-Model: claude-fable-5-1
Agent-Session: local Claude Code session 9b5c3ae5-6a0f-41b8-bd69-03bf3b5e7083
This branch has not been deployed
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.
What changed and why
prepare_algwraps the solver's autodiff choice inAutoSparsewhenever the problem function carries a sparsejac_prototype. The in-placeBrownFullBasicInitpath for aDAEProblem(lib/OrdinaryDiffEqNonlinearSolve/src/initialize_dae.jl) then builtand NonlinearSolve v4 refuses an
AutoSparseautodiff outright, so every fully implicit DAE with a sparsejac_prototypeand inconsistent initial conditions errored inside initialization before the first step. The fix unwraps the backend withADTypes.dense_ad, exactly asDAEResidualJacobianWrapperinutils.jland_isforwarddiff_algalready do.ADTypeswas already a dependency and already imported in the module; noProject.tomlchange. The out-of-placeDAEProblempath goes throughdefault_nlsolveand was not affected.The regression test is appended to
test/sparse_dae_initialization_tests.jl, whichruntests.jlalready runs in the Core group.Relation to #4479
This is the next failure after #4479. A
DAEFunctionwith a sparsejac_prototypeand no userjacfirst dies inprepare_user_sparsity(FieldError: type DAEFunction has no field mass_matrix), which #4479 fixes viamass_matrix_or_I. That PR's own test uses consistent initial conditions, so it never reaches theNewtonRaphsonconstruction here. Once both are merged, thejac = nothingvariant of the test below also passes through this path; today the test supplies a userjacso it is independent of #4479 and discriminates onorigin/masteralone. Local!(f isa DAEFunction)guards for the sparsity-seeding sites were dropped from this PR because #4479 already covers all three sites (and seeding the diagonal, as #4479 does, is the better semantics than skipping it).Evidence
Environment: Julia 1.12.6, aarch64 Linux, a scratch env
Pkg.developinglib/OrdinaryDiffEqCore,lib/OrdinaryDiffEqDifferentiation,lib/OrdinaryDiffEqNonlinearSolve,lib/OrdinaryDiffEqSDIRK,lib/OrdinaryDiffEqBDFfrom this branch; NonlinearSolve v4.29.2.Before (test added, source change not applied) —
julia -e 'using Test; @testset "Sparse DAE Initialization" begin include("lib/OrdinaryDiffEqNonlinearSolve/test/sparse_dae_initialization_tests.jl") end':After (same command, fix applied):
What was run
--check --diff) on both changed files: clean.typos1.50.1 with the repo's.typos.tomlover the diff and both files: clean.Sparse DAE Initialization39/39,DAE Initialization Tests19/19,CheckInit Tests4/4,NonlinearSolveAlg DAEProblem Tests32/32.Pkg.test()oflib/OrdinaryDiffEqNonlinearSolvewithGROUP=Coreis running under a 4-hourtimeoutas this is filed; whatever completes will be posted as a follow-up comment.Not verified
OrdinaryDiffEqNonlinearSolveCore group does not fit in a session here: a previous run on this machine passed 13 of its 27 testsets (including "Sparse DAE Initialization" with an earlier version of this test) and hit an 8-hour timeout inside the remaining ones (Mass Matrix Tests alone took 152 min). CI is the authority for the rest of the group.🤖 Posted by an AI agent — harness: Claude Code 2.1.270 · model: claude-fable-5-1
Conversation: local Claude Code session
9b5c3ae5-6a0f-41b8-bd69-03bf3b5e7083(no shareable URL available)