Skip to content

Add tolerance solves to MTK precompile workloads - #5248

Merged
ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:ttfx-tolerance-workloads
Oct 16, 2026
Merged

ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:ttfx-tolerance-workloads

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Please ignore until reviewed by @ChrisRackauckas.

Adds Float64-tolerance solves to the existing Tsit5 and FBDF precompile workloads for MTK’s ODE and DAE problem shapes, reducing first-solve inference for the covered keyword calls to their no-tolerance counts. This PR helps with or without OrdinaryDiffEq.jl #4618 and does not depend on that PR; it changes only precompile workloads.

Measurements

The original design campaign used MTK c97bfa70 (11.45.3). Its fresh-process SnoopCompile MI counts and minimum of three solve-only wall timings (seconds), comparing #4618 alone with #4618 plus B, are:

Configuration Model Kwargs New MIs Min wall, s
#4618 only workload none 1 0.133
#4618 only workload abstol, reltol 133 0.473
#4618 only chain_ode(4) none 302 1.369
#4618 only chain_ode(4) abstol, reltol 421 1.243
#4618 + B workload none 1 0.141
#4618 + B workload abstol, reltol 1 0.234
#4618 + B chain_ode(4) none 302 1.350
#4618 + B chain_ode(4) abstol, reltol 302 1.154

Round 1 independent review (Claude Code, claude-opus-5-5) measured the PR against its actual master base, including OrdinaryDiffEq without #4618. These are newly inferred MethodInstances during a first solve in a fresh process, with Float64 abstol followed by reltol:

OrdinaryDiffEq configuration Case Base MTK, with tolerances +B, with tolerances +B, no tolerances
Without #4618 workload, Tsit5 158 1 1
Without #4618 chain_ode(4), Tsit5 446 302 302
Without #4618 DAE workload, FBDF 180 23 23
Without #4618 chain_ode(4), FBDF 491 347 347
With #4618 workload, Tsit5 133 1 1
With #4618 chain_ode(4), Tsit5 421 302 302
With #4618 DAE workload, FBDF 155 23 23

The combined native pkgimage growth of the two extensions is about 600 KiB without #4618, versus about 345 KiB with #4618. The review measured one build per configuration: without #4618, Tsit5 grew by 240,352 bytes and BDF by 373,576 bytes (613,928 bytes total); with #4618, the total was 351,232 bytes (about 343 KiB). The design campaign’s median-size delta with #4618 was 353,152 bytes (about 345 KiB, 2.03%).

Precompile-time delta was not measured reliably. The review ran at machine loads of 130–320. Across the design campaign’s three extension-cache rebuilds, the min/median time delta was −1.88/−0.39 s for Tsit5 and +1.10/+1.12 s for BDF; these noisy observations do not establish an overall rebuild-time penalty. Wall-time minima are also noisy and should not be treated as precise speedup estimates.

A DiffEqBase-side alternative (A2) was also prototyped and rejected: it only partially reduced inference and changes the kwargs visible to problem-concretization hooks.

Merge interaction

This PR conflicts with ModelingToolkit.jl #5202 in ext/MTKOrdinaryDiffEqBDFExt.jl: both add calls after solve(daeprob, FBDF()). A real git merge --no-commit --no-ff review/pr5202 into this PR’s committed head in a scratch clone returned exit 1:

CONFLICT (content): Merge conflict in ext/MTKOrdinaryDiffEqBDFExt.jl
Automatic merge failed; fix conflicts and then commit the result.

The trivial resolution is to keep all three added calls: this PR’s two FBDF tolerance solves and #5202’s solve(sccprob, FBDF()). Keeping both sides in the scratch clone removed the unmerged path and passed git diff --cached --check; the trial merge was then aborted without a commit. Whichever PR merges second needs a rebase. The earlier clean-merge claim was incorrect: its trial tree omitted the unstaged B patch, and legacy Git 2.34 merge-tree exits 0 even for conflicts.

Coverage limits

Full coverage is limited to the keyword set and order used in the workloads: abstol followed by reltol, with Float64 values. Round 1 measured the following Tsit5 workload cases with B and without #4618; counts are total newly inferred MIs during the first solve, not differences from the covered count:

Keywords in call order New MIs
abstol, reltol 1
reltol, abstol 117
reltol alone 139
abstol, reltol, saveat=0.1 641

Reordering keywords or adding saveat leaves substantial inference. Tolerances read from Refs reproduced the covered literal-value counts (1 for the workload, 302 for chain_ode(4)). A measured side benefit without #4618 is reduced tolerance-call inference for Rodas5P (158 → 21 MIs) and the default solver (158 → 23 MIs), though their tolerance calls are not explicitly in these workloads.

Verification

  • OrdinaryDiffEq.jl was checked out at PR StackOverflowError during ODEProblem construction #4618 head faf84f7004324080e2dbdf4d5fa3fa5c847ad979; its root package, lib/DiffEqBase, and lib/OrdinaryDiffEqCore were developed in the verification environment. With that environment active, this precompiled MTK and checked both extensions (exit 0):

    export TMPDIR=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/tmp JULIA_MAX_NUM_PRECOMPILE_FILES=100 JULIA_DEPOT_PATH=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/depot:/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolgap/depot JULIA_PKG_PRECOMPILE_AUTO=0
    /home/crackauc/.juliaup/bin/julia +1.12 --startup-file=no --project=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/scratch/verification -e 'using ModelingToolkit, OrdinaryDiffEq; @assert Base.get_extension(ModelingToolkit, :MTKOrdinaryDiffEqTsit5Ext) !== nothing; @assert Base.get_extension(ModelingToolkit, :MTKOrdinaryDiffEqBDFExt) !== nothing; println("Both Tsit5 and BDF extensions loaded after precompilation")'

    Output: Both Tsit5 and BDF extensions loaded after precompilation.

  • These separate fresh-process commands used the design’s measure.jl and both exited 0:

    export TMPDIR=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/tmp JULIA_MAX_NUM_PRECOMPILE_FILES=100 JULIA_DEPOT_PATH=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/depot:/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolgap/depot JULIA_PKG_PRECOMPILE_AUTO=0
    /home/crackauc/.juliaup/bin/julia +1.12 --startup-file=no --project=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/scratch/verification /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolgap/scratch/measure.jl workload tol snoop /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/scratch/inference-tol
    /home/crackauc/.juliaup/bin/julia +1.12 --startup-file=no --project=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/scratch/verification /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolgap/scratch/measure.jl workload none snoop /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/scratch/inference-none

    Outputs: RESULT snoop workload tol nMI=1 and RESULT snoop workload none nMI=1.

  • Runic check mode on both changed files exited 0:

    export JULIA_LOAD_PATH=@runic JULIA_DEPOT_PATH=/home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/depot:/home/crackauc/.julia
    /home/crackauc/.juliaup/bin/julia +1.12 --startup-file=no -e 'using Runic; exit(Runic.main(ARGS))' -- --check --diff ext/MTKOrdinaryDiffEqTsit5Ext.jl ext/MTKOrdinaryDiffEqBDFExt.jl

    typos ext/MTKOrdinaryDiffEqTsit5Ext.jl ext/MTKOrdinaryDiffEqBDFExt.jl also exited 0.

Round 1 also verified Julia 1.10.12 in a fresh environment: both targeted extensions precompiled and loaded, and the Tsit5 ODE and FBDF DAE tolerance solves ran successfully. The reviewer’s scratch/run_lts.sh logged setup exit 0, 1.10.12 exts loaded, and load exit 0. The precompile output reported 27.8 s for Tsit5Ext and 50.1 s for BDFExt; these are individual durations, not a measured time delta.

Review evidence: /home/crackauc/sandbox/agent-jobs/mtk-ttfx/reviews/pr-5248/round1/REVIEW.md; raw measurements and Julia 1.10 results are in its scratch/results/ directory. These reviewer measurements were inspected for this body correction; the author did not rerun the Julia campaign.

Not verified

Neither the author nor the reviewer ran the full ModelingToolkit test groups locally, including InterfaceII. The review measured FBDF/DAE inference counts, but not FBDF/DAE wall-clock TTFX, non-Float64 tolerances, total fresh-install precompile time, a reliable rebuild-time delta, pkgimage sizes on Julia 1.10, or behavior after #4618 and #5202 are merged. Results establish coverage only for the measured cases, not arbitrary user models or keyword combinations.

Risk assessment

  • Risk: low
  • Blast radius: precompile workloads of two MTK extensions only, no runtime code path change
  • Evidence: author and independent-review measurements above show inference reductions with and without StackOverflowError during ODEProblem construction #4618; both extensions precompiled and tolerance solves ran on Julia 1.12 and Julia 1.10.12; real merge conflict reproduced and documented
  • Independent review: Claude Code (claude-opus-5-5), round 1 CHANGES (PR-body accuracy only), risk low. The body corrections address the findings; no subsequent clean review is claimed.
  • Merge: needs human review

Part of the MTK TTFX effort: https://github.com/ChrisRackauckas/InternalJunk/issues/113

🤖 Generated with Codex CLI (model: gpt-6-luna; session transcript: /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/log.txt on amdci2)

Risk assessment (independent review, codex-cli gpt-6.1-sol, reviewed head a5b5325)

  • Risk: low
  • Blast radius: precompile workloads in the Tsit5 and BDF extensions; extra compilation/cache cost for those extensions. No solver implementation, public API, dependency, or license changes.
  • Evidence: reviewed head a5b532557563eb62538f693587f835f67eae8779 (unchanged at completion), the full three-call diff, authorship, the linked TTFX hand-off https://github.com/ChrisRackauckas/InternalJunk/issues/113, and companion Resolve default ODE tolerances before specialized init (TTFX) OrdinaryDiffEq.jl#4618. Locally, with JULIA_NUM_THREADS=4, TMPDIR=$PWD/tmp, JULIA_DEPOT_PATH=$PWD/depot:/home/crackauc/.julia, /home/crackauc/.juliaup/bin/julia +release --startup-file=no --project=env-5248 tmp/test-5248.jl precompiled/loaded both extensions and passed 8/8 assertions (test body 1.5 s after loading). The added Tsit5 ODE, FBDF ODE, and FBDF DAE tolerance calls all returned Success; final states agreed with default-tolerance solves at relative tolerance 1e-3. The DAE tolerance solve ended at [0.7560475128929396, 0.5704325631985844]. CI snapshot: {'SKIPPED': 1, 'QUEUED': 36, 'SUCCESS': 43, 'FAILURE': 2}. Full local output is in evidence/5248.test.log.
  • Independent review: codex-cli 0.163.0 gpt-6.1-sol rated it low, high confidence in correctness and limited performance confidence: the extension workloads load and solve correctly, while the claimed inference/cache deltas were not independently measured in this review.
  • Merge: auto-merge candidate — narrow precompile-only scope and passing local smoke test; pending checks must finish without introduced failures before merging.

🤖 Posted by an AI agent — harness: codex-cli · model: gpt-6.1-sol (independent reviewer; appended by Claude Code 2.1.301 · claude-opus-5-5)
Conversation: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq

codex and others added 2 commits October 2, 2026 16:26
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI
Agent-Model: gpt-6-luna
Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/tolws/log.txt on amdci2
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_ModelingToolkit.jl-5248/log.txt
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Merged the default branch into this PR (clean merge, no conflicts; head 2b29fbf) so CI runs on current master.


🤖 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
Conversation: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master)

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 16, 2026 18:49
@ChrisRackauckas
ChrisRackauckas merged commit 9082f85 into SciML:master Oct 16, 2026
83 of 85 checks passed
ChrisRackauckas referenced this pull request Oct 17, 2026
…5284)

Bump versions: ModelingToolkitBase 1.77.5, ModelingToolkit 11.45.5
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Agent-Harness: Claude Code 2.1.302
Agent-Model: claude-sonnet-5-5
Claude-Session: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants