Repository navigation
Resolve default ODE tolerances before specialized init (TTFX) - #4618
Merged
ChrisRackauckas merged 13 commits intoOct 31, 2026
Merged
Conversation
Passing abstol/reltol used to specialize DiffEqBase solve and OrdinaryDiffEqCore _ode_init on Float64 instead of Nothing, recompiling the heavy init path (~0.7–1.9 s) even when MTK workloads already covered solve without tolerances. Resolve nothing to the same concrete defaults in DiffEqBase.solve/init and before _ode_init_impl so both call sites share MethodInstances without changing numerical defaults. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.23-86fc751 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
Drop the DiffEqBase solve/init inject so third-party ODE/DAE/discrete solvers keep their own defaults. Resolve nothing tolerances only in OrdinaryDiffEqCore._ode_init (internal helper, not public), with SDE/RODE callers still passing their concrete 1e-2 defaults through. Expand equality coverage for unitful, Float32 DAE, prob.kwargs, and StochasticDiffEq SOSRI/EM/SRIW1. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.23-86fc751 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
_ode_init always resolves abstol/reltol before calling _ode_init_impl, so the nothing/discrete/unitful default formula inside the impl was unreachable and duplicated resolve_ode_tolerances. Assign the already- resolved values directly and document that expectation. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.23-86fc751 Agent-Model: unknown Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
Require resolved abstol/reltol on _ode_init_impl (no nothing defaults), fix the comment that misstated the SDE path, hardcode master unitful defaults in the equality test, and assert a with-tol solve does not add an _ode_init_impl keyword-body specialization after a default solve. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.23-86fc751 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
The thin _ode_init wrapper that forwarded kwargs into _ode_init_impl made @inferred solve(... EM) return Any. Resolve nothing tolerances in SciMLBase.__init instead, and keep _ode_init as the single heavy body that SDE calls directly with already-concrete abstol/reltol. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.23-86fc751 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
Round-4 blockers: public _ode_init again accepts optional/nothing tolerances (resolve then call _ode_init_impl), and StochasticDiffEqCore applies real.(abstol/reltol) before calling _ode_init_impl so complex user tolerances stay Float64 without breaking @inferred SDE solve. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
Fold the heavy init body back into public _ode_init (optional abstol/reltol + resolve) so SDE uses only the public API. SciMLBase.__init still pre-resolves for TTFX; SDE keeps real.() then a single kwcall layer so @inferred EM solve stays concrete. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
Round-7 non-blocking cleanups only: drop retrospective "master"/prior- behavior wording from docstrings and comments, and count specializations via methods(fn) iteration instead of .ms. No behavior change. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tol/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.11.3 (conflict resolution), Claude Code 2.1.285 (orchestration) Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium Agent-Session: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master); Devin log /Users/chrisrackauckas/sandbox/master/fusion-fixes/SciML_OrdinaryDiffEq.jl-4618/log.txt
Member
Merged the default branch into this PR (clean merge, no conflicts; head 11e4522) so CI runs on current master. Its earlier failures in SciMLSensitivity Core1 and the downgrade jobs were fixed on master after this PR's last CI run. 🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (merge), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
resolve_ode_tolerances dispatches on Nothing and returns the same 1e-6 and 1e-3 defaults an empty Float64 state produces, without allocating that vector. StochasticDiffEqCore treats a nothing state as Float64 when it builds tolerance eltypes. Tests check equality with the empty-state result, zero allocation, and the Nothing method. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Grok <[email protected]> Agent-Harness: Grok Build 1.0.70 Agent-Model: grok-4.7 Agent-Session: local fixer job SciML__OrdinaryDiffEq.jl__4618 (no session URL)
The OrdinaryDiffEqCore workload resolves nothing abstol/reltol for a vector state and for a nothing state, so those method instances exist after loading. A test counts the Nothing specializations without calling the method. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Grok <[email protected]> Agent-Harness: Grok Build 1.0.70 Agent-Model: grok-4.7 Agent-Session: local fixer job SciML__OrdinaryDiffEq.jl__4618 (no session URL)
The two `@allocated(...) == 0` assertions on resolve_ode_tolerances fail
under `Pkg.test(coverage=true)` on Julia 1.10 (`Evaluated: 32 == 0`):
coverage instrumentation allocates. They also did not distinguish the old
from the new code: the Float64[] path and the nothing path both measure
0 bytes without coverage and 32 bytes with it, because the compiler elides
the empty vector in a type-stable microbenchmark. The method-dispatch
check already in the file separates old from new.
Assert the inferred return type (Tuple{Float64, Float64}) instead, which
coverage does not affect.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Agent-Harness: Claude Code 2.1.316
Agent-Model: claude-sonnet-5-5
Agent-Session: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74
ChrisRackauckas
marked this pull request as ready for review
October 31, 2026 10:19
ChrisRackauckas
referenced
this pull request
Nov 28, 2026
Bump version to 2.2.6 Bump version to 2.2.6 Bump version to 2.2.6 Bump version to 2.2.6 Bump version to 2.2.6 Bump version to 2.2.6 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: AI agent <[email protected]> Agent-Harness: hourly_releases Agent-Model: none (deterministic) Agent-Session: local job hourly-release-74dba2e6-d998-45b2-acda-764f0cc7c3c4 (no session URL) Agent-Session: local job hourly-release-3fa5fb01-9edb-4207-a008-f3e965ad262a (no session URL) Agent-Session: local job hourly-release-12159859-e451-418a-b40a-03a35d145353 (no session URL) Agent-Session: local job hourly-release-1f090ad0-9f29-4772-9a87-f993ebb136a2 (no session URL) Agent-Session: local job hourly-release-399633b3-4944-4d57-9c31-97c7a8620b97 (no session URL) Agent-Session: local job hourly-release-bac847af-5e64-4a93-b113-bf0e92dc91bd (no session URL)
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.
Please ignore until reviewed by @ChrisRackauckas.
What changed and why
solve(prob, alg; abstol, reltol)was specializing OrdinaryDiffEqCore's heavy_ode_initkeyword body onFloat64instead of the workload-precompiledNothingdefaults. This PR resolvesnothingtolerances to concrete defaults inSciMLBase.__initbefore calling public_ode_init, so the heavy keyword body always sees concrete types (TTFX).resolve_ode_tolerances(prob, ::Nothing, abstol, reltol)is a dedicated method for anothingstate. It returns the scalarFloat64defaults (1//10^6,1//10^3;falsefor discrete problems; supplied tolerances go throughreal.(...)), so noFloat64[]is built on the tolerance path.__initand_ode_initpassprob.u0straight through.1//10^2) andreal.(...)on user tolerances, then calls the same public_ode_init(single kwcall layer, required for ExplicitImports and for@inferred solve(... EM()))._sde_inithas a matchingu === nothingbranch withFloat64eltypes.nothingstate (resolve_ode_toleranceswith a vectoru0,nothing, and a null problem). This is a separate commit (2f0973dda) and can be dropped on its own; see the timing note below.@allocated(...) == 0assertions on thenothing-state path are replaced byBase.return_typeschecks (see Verification).Scope: DiffEqBase untouched. No new public names.
Open point for Chris:
lib/OrdinaryDiffEqCore/src/solve.jlstill hasu = Float64[]in_ode_init(state coercion, not tolerances). It is unchanged here pending a decision on whether "noFloat64[]at all" is wanted.Verification
Head
94c978338(previous review head5d0e490;2f0973ddais the precompile-workload commit).Tests (this head)
GROUP=Core, Julia 1.12.7: passes; "Tolerance Default Equality" 110/110.Pkg.test(coverage=true), as CI runs it: passes; "Tolerance Default Equality" 110/110.GROUP=Interface2, Julia 1.12.7: whole group passes; "SDE Default Tolerance Equality" 47/47 (20 + 27), "Element-wise Tolerances Tests" 12/12.--checkandtyposon the changed files: clean.Failing before / passing after (
5d0e490sources with the new test file vs this head)5d0e490: 90 pass, 1 fail, 1 error. The "precompiled" test fails with0 > 0; the nothing-u0testset errors withMethodError: no method matching one(::Nothing).solve.jlwithout the precompile workload lines fails only the "precompiled" test (0 > 0), so that test discriminates the workload.Allocation assertions removed. The earlier
@allocated(...) == 0asserts failed in CI on Julia 1.10 withPkg.test(coverage=true)(Evaluated: 32 == 0; Core 108 passed, 2 failed locally): coverage instrumentation allocates 32 bytes. They also did not distinguish old from new code:resolve_ode_toleranceswithFloat64[](old path) and withnothingboth measure 0 bytes without coverage and 32 bytes with coverage (Julia 1.10.12), because the compiler elides the empty vector in a type-stable microbenchmark. The method-dispatch check (which(resolve_ode_tolerances, (typeof(prob), Nothing, Nothing, Nothing))is the::Nothingmethod) is what separates old from new, and it was already in the file. The replacement assertsBase.return_types(resolve_ode_tolerances, ...) == [Tuple{Float64, Float64}]for the omitted and the supplied tolerance calls; inference is unaffected by coverage.Timing A/B (
5d0e490vs this head, 3 interleaved reps, shared machine under load): first-solve times are identical within noise (workload tolerances about 0.6 s on both; user tolerances about 1.0 s on both). Load time ofusing ModelingToolkit, OrdinaryDiffEq: 10.15-10.89 s before vs 9.92-10.27 s after. The ranges overlap, so the precompile commit has no measurable gain. The TTFX gain against master is already in5d0e490:5d0e490)ode workload tolfirst solve (3 reps)ode user tolfirst solve (3 reps)ode workload nonefirst solve (3 reps)ode user nonefirst solve (3 reps)Specialization property: after
solve(prob, Tsit5()), a with-tolerance solve leaves the#_ode_init#kwbody specializations unchanged on this PR (5 to 5); on the merge-base the heavy#_ode_init#grows (5 to 6).Defaults unchanged. Equality tests, unitful
Quantitydefaults, Float32 DAE, SDE SOSRI/EM/SRIW1, and complex user SDE tolerances (stored as Float64, SOSRI succeeds).@inferred solve(... EM(); dt)passes (Interface1 Inference 2/2); StochasticDiffEqCoreGROUP=QA21/21 (public_ode_initonly, as of the earlier review head).CI failures not caused by this PR
These are red on master as well (push runs on the default branch):
LineSearchExceptioninnewton_tests.jl)OrdinaryDiffEqCore Core (lts) and its Downgrade check failed on the allocation assertions above; the replacement is validated locally and CI on the new head is pending.
Risk assessment
__init/_ode_init/ precompile workload and StochasticDiffEqCore_sde_init; no public API change5d0e490low, high confidence; earlier rounds covered older heads. The two later commits and the test change are not yet independently reviewed.Not verified
Part of the MTK TTFX effort
🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74