Repository navigation
Precompile ODEProblem construction and DAE initialization in the MTK workloads - #5061
Merged
ChrisRackauckas merged 1 commit intoSep 4, 2026
Merged
Conversation
…loads Add two small model constructors, `precompile_ode_problem` (tunable parameters, an observed variable, trivial initialization) and `precompile_dae_problem` (mass-matrix DAE with a nonlinear algebraic constraint, so `ODEProblem` builds an SCC initialization problem), and use them in every workload. MTK's own workload now runs `mtkcompile` + `ODEProblem` for both; the OrdinaryDiffEq extensions solve them instead of each carrying its own copy of a 2-state ODE. New extensions: `MTKOrdinaryDiffEqTsit5Ext` (explicit-solver path, previously uncovered) and `MTKOrdinaryDiffEqRosenbrockNonlinearSolveExt`, which solves the DAE with `Rodas5P` only once `OrdinaryDiffEqNonlinearSolve` is loaded, since `OverrideInit` has no nonlinear solver without it. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Agent-Harness: Claude Code 2.1.259 Agent-Model: claude-fable-5-1 Agent-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn
ChrisRackauckas
marked this pull request as ready for review
September 4, 2026 12:55
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 4, 2026
Re-cut as a minor. 11.40.1 never registered: its registration PR (JuliaRegistries/General#166107) has been open since 2026-08-26 carrying a failed AutoMerge verdict, and re-triggering updated the tree without producing a fresh evaluation. Moving to a new version leaves that stale PR behind. Contents: precompile ODEProblem construction and DAE initialization in the MTK workloads (#5061). Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R
Merged
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 4, 2026
Re-cut as a minor. 11.40.1 never registered: its registration PR (JuliaRegistries/General#166107) has been open since 2026-08-26 carrying a failed AutoMerge verdict, and re-triggering updated the tree without producing a fresh evaluation. Moving to a new version leaves that stale PR behind. Contents: precompile ODEProblem construction and DAE initialization in the MTK workloads (#5061). Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude <[email protected]>
Member
Author
|
Docs build of the final commit ( Rendered site: 58 HTML pages; 🤖 Claude Code (model: claude-fable-5-1) — https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn |
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 7, 2026
- qa: approve newly exported Symbolics API (#5050) - Update redirected documentation links (#5054) - qa: fix ModelingToolkitBase import checks (#5028) - docs: replace stale Pantelides link (#5056) - Precompile ODEProblem construction and DAE initialization in MTK workloads (#5061) - Release 11.41.0 (#5069) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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
The OrdinaryDiffEq extensions each carried a private copy of a 2-state linear ODE and only solved it; model construction sat in
@setup_workload, outside the compiled block, and nothing exercised a mass-matrix DAE, an initialization problem with unknowns, or an explicit solver. Measured in a fresh session, the first MTK model paid ~12 s inODEProblem(mtkcompile+ codegen), ~3 s ininitwithTsit5, and for a DAE with a real initialization problem 5–13 s ininitand 2–14 s insolve!, none of it model-specific.This PR adds one small model per initialization kind ModelingToolkit emits, built inside ModelingToolkit's own
@compile_workloadand solved from the extensions:precompile_ode_problemNonlinearProblem, no unknowns); tunable parameters, an observed variableprecompile_dae_problemNonlinearProblem(one nonlinear unknown)precompile_scc_dae_problemSCCNonlinearProblemprecompile_nlls_problemNonlinearLeastSquaresProblemprecompile_implicit_dae_problemDAEProblembuilt the way MethodOfLines does (notmtkcompiled,build_initializeprob = false)DFBDF+BrownFullBasicInit(BDF ext)An affine constraint is eliminated by
mtkcompile, so a "linear initialization" model ends up trivial and is covered by the ODE. New extensions:MTKOrdinaryDiffEqTsit5Ext(explicit-solver path) andMTKOrdinaryDiffEqRosenbrockNonlinearSolveExt(triggered byOrdinaryDiffEqRosenbrock+OrdinaryDiffEqNonlinearSolve, becauseOverrideInithas no nonlinear solver until the latter loads andOrdinaryDiffEqRosenbrockdoes not depend on it). The helpers are@publicbecause the QAExplicitImportscheck requires extensions to use public names; they are documented on the internals page. The QA harness now loads the two new trigger packages so the new extensions are actually checked.Verification
All numbers: x86-64, Julia 1.12.7,
--startup-file=no, fresh process per row, OrdinaryDiffEq 7.8.1, master (22cb5b0a21) vs this branchPkg.developed into the same environment. Timings on the branch were taken together with the CommonWorldInvalidations canary PR (SciML/CommonWorldInvalidations.jl#45); without it,using OrdinaryDiffEqinvalidates the construction workload (see the section below) and only theinit/solve!columns improve.First model in a session,
@timedcompile seconds, models that are not the workload models:ODEProblem/init/solve!Tsit5NonlinearProbleminit,Rodas5P/FBDFRodas5PRodas5P/ defaultDAEProblem(MethodOfLines shape),DFBDF*
DFBDFstill recompiles per state size because the chunk size is part of the nonlinear-solver cache type: SciML/OrdinaryDiffEq.jl#4458. Not fixable by a workload.Per-solver
init/solve!compile on the first model of each kind (branch): Tsit5 0.12 / 0.01, Rodas5P 0.1–0.7 / 0.01–0.11, FBDF 0.04–0.12 / 0.01, default algorithm 0.35–1.3 / 0.01. Second and later models in the same session are unchanged (≈1 sODEProblem, ≈0.9 sinitfor an ODE); that is per-model specialization, which no workload can remove.Extension precompile times (
Pkg.precompileoutput, this machine): Rosenbrock 61 → 34 s (it now only solves the ODE), BDF 61 → 59 s, Default 69 → 77 s, new Tsit5 28 s, new RosenbrockNonlinearSolve 48 s.Local checks before pushing:
julia -m Runic --check) andtypos: clean on every touched file.GROUP=QAon the final commit: 41 pass, 1 fail. All six extensions load (Extensions loaded | 6 6) and ExplicitImports/Aqua are clean for the new public names and extensions; the one failure is Aqua's persistent-tasks check, whose own fresh environment resolves AMD 0.5.4, which removed the unexportedSS_Intthat SparseColumnPivotedQR's extension used, so LinearSolve fails to precompile there. That breaks master the same way as of today; fix in Fix AMD extension for AMD.jl 0.5.4 (SS_Int removed) SparseColumnPivotedQR.jl#71. (The first QA run on the first commit failedall_qualified_accesses_are_publicon the helpers, which is why they are@public.)GROUP=InterfaceIon the first commit:InterfaceI | 1491 pass, 3 broken (pre-existing) | 49m21s.docs/make.jlran Doctest, ExpandTemplates, CrossReferences and CheckDocument without errors on the first commit, then aborted atlinkcheckon a GitHub HTTP 429; alinkcheck = falsebuild of the final commit is reported in a comment.What is not fixed here
solve(prob)with the default algorithm on any mass-matrix problem was never despecialized at all: the resolved default isDefaultODEAlgorithm(autodiff = AutoFiniteDiff()), which sends concretization down DiffEqBase's non-ForwardDiffpromote_fpath, and that path refused to wrap problems whose mass matrix is notUniformScaling. Every MTK DAE therefore recompiled the whole composite solve (11–13 s) under the default algorithm regardless of workload. Fixed in DiffEqBase: DiffEqBase: wrap mass-matrix problems on the finite-difference promote_f path (default algorithm was never despecialized) OrdinaryDiffEq.jl#4459. With that, the default-algorithm rows above drop to the Rodas5P-like numbers.NTuple{N}); a 3-block model still pays ~1.2 s ininitwith Rodas5P. Concretize initialization problems once at construction #5062 shares the block types so only the outer tuple specialization remains.using OrdinaryDiffEqafter ModelingToolkit insertsBase.axes(::SparseMatrixColorings.SparsityPatternCSC, ::Integer), which invalidates 2,049 ModelingToolkit/ModelingToolkitBase/Symbolics instances (__mtkcompile,maybe_build_initialization_problem,process_SciMLProblem, …) through abstractly typedaxes(A, d)call sites, so the construction part of this workload only survives with that PR (or with the redundant method removed upstream in SparseMatrixColorings).Not verified
Initialization,Extensions,Downstream,FMI,Optimizationgroups and Julia 1.10 were not run locally.Reviewer notes
Rodas5P+OverrideInitinto a pkgimage;solve(daeprob, Rodas5P())inside the plain Rosenbrock extension throwsOverrideInitMissingAlgorithmat precompile time.Measurements and scripts: https://github.com/ChrisRackauckas/InternalJunk/issues/88
🤖 Generated with Claude Code (model: claude-fable-5-1)
https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn