Skip to content

GlobalDiffEq: fix Julia 1.13 precompilation and InterpolatingMode companion accuracy - #4500

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/globaldiffeq-precompile-format
Sep 11, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/globaldiffeq-precompile-format

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

  • Fix GlobalDiffEq precompilation on Julia 1.13. src/adjoint.jl re-defined _positive_finite_real and _validate_tolerances, which already exist in src/companion.jl as shared machinery (introduced by GlobalAdjoint: every-step trajectory scope and step-grid control (closes #4493, #4494) #4495 on top of Unify companion global error estimators into GlobalErrorEstimation #4492). Method overwriting is a hard error during module precompilation on Julia 1.13, so the package failed to precompile, which also broke GlobalDiffEqSciMLSensitivityExt, Aqua's persistent_tasks check in the QA group, and every downstream test env that loads GlobalDiffEq. The duplicates in adjoint.jl are removed; the single definitions in companion.jl are kept.
  • Fix the SimultaneousMode matches InterpolatingMode test failure (lib/GlobalDiffEq/test/companion_tests.jl:44) by making InterpolatingMode integrate the companion ODE accurately: the defect d(t) = f(P) - P' driving the companion is only piecewise smooth — it has kinks (derivative jumps) at the forward solver's step nodes. A companion step straddling a node smooths over the kink and underestimates its local error, biasing the endpoint estimate. SimultaneousMode implicitly avoids this by restarting the companion on every forward step. Passing the forward step nodes as tstops to the interpolating-mode companion solve confines each companion step to a smooth piece — the modes now agree to ~1e-6 relative (see below) and the interpolating estimate matches the converged companion integral.
  • Runic-format src/companion.jl (the file failing master format-check); runic --check now passes on all of lib/GlobalDiffEq.

Investigation detail (test failure was not borderline)

At the default companion tolerances (companion_abstol=1e-10, companion_reltol=1e-8) on the Lotka–Volterra test problem at tol=1e-6:

companion integration estimate (ErrorTransport)
one adaptive solve over [t0, T] (old InterpolatingMode) 1.2278559e-5
restarted on each forward node (SimultaneousMode) 1.2342406e-5
one solve forced to step on the nodes (tstops) 1.2342414e-5
converged value (restarted, companion tol 1e-12) 1.2342380e-5

The live-integrator and stored-solution interpolants agree to ~1e-13, and restarting the companion on the stored interpolant reproduces the SimultaneousMode value exactly — so the discrepancy came entirely from the one-shot companion solve straddling defect kinks, i.e. the old InterpolatingMode value was the less accurate one. tstops = sol.t fixes that directly rather than loosening the test tolerance.

Test plan

Julia 1.13.0-rc4 (what CI's 1 resolves to), cd lib/GlobalDiffEq, GROUP=Core julia +1.13 --project=. -e 'using Pkg; Pkg.test()'.

Before (master; identical values in CI log and local run — local run needed the precompile fix to load the package at all, companion code unchanged):

WARNING: Method definition _positive_finite_real(Any) in module GlobalDiffEq at .../src/companion.jl:8 overwritten at .../src/adjoint.jl:115.
ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.
...
SimultaneousMode matches InterpolatingMode: Test Failed at .../test/companion_tests.jl:44
  Expression: ≈(stream, interp, rtol = 0.005)
   Evaluated: 1.234240556040866e-5 ≈ 1.2278558976054218e-5 (rtol=0.005)

After (this branch): GlobalDiffEq and GlobalDiffEq → GlobalDiffEqSciMLSensitivityExt precompile cleanly with no method-overwrite warnings, and:

Test Summary:              | Pass  Total   Time
Companion error estimators |   43     43  24.7s
Test Summary:                        | Pass  Total     Time
Adjoint error estimation and control |   35     35  1m01.5s
Test Summary: | Pass  Total   Time
GLEE solvers  |   91     91  32.2s
Test Summary:    | Pass  Total  Time
BigFloat support |    2      2  7.3s
     Testing GlobalDiffEq tests passed

GROUP=QA also passes (QA | 23 passed, 1 broken (pre-existing @test_broken) | Testing GlobalDiffEq tests passed), and runic --check lib/GlobalDiffEq exits 0. Docs build not run — no docstrings or public API changed.

🤖 Generated with Devin (harness: Devin CLI 3000.10.21, model: SWE-2 High). Session: local Devin CLI session (no shareable URL); session db at /home/crackauc/.local/share/devin/cli/sessions.db

- adjoint.jl re-defined _positive_finite_real and _validate_tolerances,
  which already live in companion.jl as shared machinery. Method
  overwriting is an error during module precompilation on Julia 1.13, so
  GlobalDiffEq failed to precompile (and took down the
  GlobalDiffEqSciMLSensitivityExt and every downstream test env with it).
  Remove the duplicates.

- InterpolatingMode integrated the defect-driven companion ODE in one
  adaptive solve over the whole span. The defect is only piecewise
  smooth, with kinks at the forward step nodes; companion steps
  straddling a node smooth over the kink and underestimate the local
  error, so the estimate was biased low relative to SimultaneousMode,
  which restarts the companion on every forward step. Pass the forward
  step nodes as tstops so companion steps land on the kinks. This makes
  the two modes agree to ~1e-6 relative (test tolerance is 5e-3) and the
  interpolating estimate now matches the converged companion integral.

- Runic-format companion.jl.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Agent-Harness: Devin CLI 3000.10.21
Agent-Model: SWE-2 High
Agent-Session: local Devin CLI session (no shareable URL); session db at /home/crackauc/.local/share/devin/cli/sessions.db
@ChrisRackauckas
ChrisRackauckas merged commit 72626cc into SciML:master Sep 11, 2026
129 of 133 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 11, 2026
- Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500)
- Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502)
- Fix BDF step rejection for backward-in-time integration (#4503)



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]>
ChrisRackauckas added a commit that referenced this pull request Sep 11, 2026
- Unify companion global error estimators into GlobalErrorEstimation (#4492)
- Add adjoint-based global error control as a SciMLSensitivity extension (#3953)
- ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497)
- Mark discrete time-grid search helpers as Enzyme inactive (#4496)
- GlobalAdjoint: every-step trajectory scope and step-grid control (#4495)
- GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498)
- Release GlobalDiffEq 1.7.1 (#4501)
- Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500)
- Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502)
- Fix BDF step rejection for backward-in-time integration (#4503)



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]>
ChrisRackauckas added a commit that referenced this pull request Sep 12, 2026
- Release OrdinaryDiffEqBDF 2.4.7 (#4490)
- Unify companion global error estimators into GlobalErrorEstimation (#4492)
- Add adjoint-based global error control as a SciMLSensitivity extension (#3953)
- ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497)
- Mark discrete time-grid search helpers as Enzyme inactive (#4496)
- GlobalAdjoint: every-step trajectory scope and step-grid control (#4495)
- GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498)
- Release GlobalDiffEq 1.7.1 (#4501)
- Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500)
- Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502)



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]>
ChrisRackauckas added a commit that referenced this pull request Sep 13, 2026
- Unify companion global error estimators into GlobalErrorEstimation (#4492)
- Add adjoint-based global error control as a SciMLSensitivity extension (#3953)
- ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497)
- Mark discrete time-grid search helpers as Enzyme inactive (#4496)
- GlobalAdjoint: every-step trajectory scope and step-grid control (#4495)
- GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498)
- Release GlobalDiffEq 1.7.1 (#4501)
- Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500)
- Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502)
- Fix BDF step rejection for backward-in-time integration (#4503)



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]>
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.

2 participants