Skip FWW wrapping in promote_f when already wrapped#3335
Closed
ChrisRackauckas-Claude wants to merge 3 commits intoSciML:masterfrom
Closed
Skip FWW wrapping in promote_f when already wrapped#3335ChrisRackauckas-Claude wants to merge 3 commits intoSciML:masterfrom
ChrisRackauckas-Claude wants to merge 3 commits intoSciML:masterfrom
Conversation
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/ModelingToolkit.jl
that referenced
this pull request
Apr 3, 2026
When AutoSpecialize is active and u0/p/t are available, wrap f with DiffEqBase.wrapfun_iip at ODEFunction construction time. This erases the GeneratedFunctionWrapper type early, before DiffEqBase.promote_f runs at solve time. Requires DiffEqBase >= 6.215.0 (SciML/OrdinaryDiffEq.jl#3335) which guards promote_f against double-wrapping already-wrapped functions. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
When MTK pre-wraps ODEFunction.f with FunctionWrappersWrapper at construction time, promote_f should not double-wrap. Move the already-wrapped check to the top of the condition so it applies to both AutoSpecialize and FunctionWrapperSpecialize paths. Also bump DiffEqBase: 6.214.1 → 6.215.0 Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
The BrownFullBasicInit DAE initialization was passing OrdinaryDiffEqTag to NonlinearSolve via `NewtonRaphson(autodiff=alg_autodiff(...))`, but NonlinearSolveBase's AutoSpecialize wraps functions with NonlinearSolveTag dual signatures. This tag mismatch caused "No matching function wrapper was found!" errors for DAEProblem solves with DFBDF. Fix by routing through `default_nlsolve` (which uses `_tagged_autodiff` with no custom tag) so NonlinearSolveBase's `standardize_forwarddiff_tag` can properly stamp the NonlinearSolveTag. Also bump NonlinearSolveFirstOrder compat in OrdinaryDiffEqNewmark to allow v2.x, and bump OrdinaryDiffEqNonlinearSolve to v1.26.0. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f2a8cb7 to
5f78801
Compare
Contributor
Author
Rebased and updatedRebased on master (TaylorSeries merge already included). Added fixes: Fix DAE initialization tag mismatch (pre-existing bug): Fix routes through Compat updates:
Verified locally: DAE solve with DFBDF (IIP + OOP), ODE solves with Tsit5/Rosenbrock23/FBDF all pass. |
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
promote_fagainst double-wrapping whenf.fis already aFunctionWrappersWrapper!(f.f isa FWW)check to the top of the condition, applying to bothAutoSpecializeandFunctionWrapperSpecializepathsVal{true}) and simple path (Val{false}) are guardedContext
SciML/ModelingToolkit.jl#4426 will pre-wrap
ODEFunction.fwith FWW at construction time (when all types are known), rather than deferring to solve time. Without this guard,promote_fwould wrap the already-wrapped FWW in another FWW.Test plan
f.fis never a FWW beforepromote_ftoday🤖 Generated with Claude Code