Skip to content

Unify companion global error estimators into GlobalErrorEstimation - #4492

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:globaldiffeq-unified
Sep 10, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:globaldiffeq-unified

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Ignore until reviewed by @ChrisRackauckas. Draft — not ready for merge.

What changed and why

Unifies the two defect-companion global-error wrappers into a single algorithm.
Previously #3956 (GlobalErrorTransport) and #3957 (GlobalDefectCorrection)
added two separate structs; they share the same machinery (dense forward solve →
companion ODE driven by the defect d(t) = f(P(t)) - P'(t)) and differ only in
the companion equation. This PR replaces both with

GlobalErrorEstimation(alg; equation = DefectCorrection, mode = InterpolatingMode, …)

parameterized by two orthogonal enums:

  • equation (GlobalErrorEquation): DefectCorrection — the nonlinear
    correction ε' = f(P+ε) - P' (no Jacobian); or ErrorTransport — the
    linearized transport ε' = J(P)ε + d (matrix-free JVP via
    DifferentiationInterface). ErrorTransport is the first-order linearization of
    DefectCorrection.
  • mode (GlobalErrorMode): InterpolatingMode — store the dense solution
    and integrate the companion in a second pass (O(n_steps) memory); or
    SimultaneousMode — drive the forward integrator one step at a time and advance
    the companion across each step using that step's live dense output (O(1) extra
    memory, no second solve).

All 2×2 combinations are supported by one implementation. Supersedes #3956 and
#3957
(closing both).

Verification

Run locally from lib/GlobalDiffEq (Julia 1.11).

GROUP=Core:

Basic functionality        |   1      1
Algorithm traits forwarding|   3      3
Companion error estimators |  43     43
GLEE solvers               |  91     91
BigFloat support           |   2      2
     Testing GlobalDiffEq tests passed

The 43 companion tests cover every equation × mode combination for the
estimate accuracy (in-place and out-of-place, est/true_err ≈ 1 rtol=0.1
against a 1e-13 reference), gtol control (endpoint error ≤ gtol),
SimultaneousMode ≈ InterpolatingMode (rtol = 5e-3; see note below), and
argument/dense-output validation.

GROUP=QA (Aqua + ExplicitImports + JET): Testing GlobalDiffEq tests passed.

Runic: clean.

Note for the reviewer

  • SimultaneousMode vs InterpolatingMode agree to ~few×1e-3, not machine
    precision.
    They integrate the same companion ODE, but the streaming mode
    restarts the companion solver at every forward step (resetting its adaptive
    controller), so the accumulated quadrature differs slightly. This is negligible
    next to the ~10% accuracy of the global-error estimate itself; the rtol=5e-3
    match tolerance is set from the observed difference, not to hide a bug — the
    independent gtol control tests confirm both modes produce correct
    error-controlling estimates.
  • Dropped public names. GlobalDefectCorrection / GlobalErrorTransport no
    longer exist. Since neither has been released on master (they lived only in
    the two open PRs this supersedes), this is not a break of any shipped API.
  • New dependencies ADTypes, DifferentiationInterface, ForwardDiff (for the
    ErrorTransport JVP) — all MIT/permissive, matching the host package.

Not verified

Downstream packages, GPU paths, and allowed-to-fail CI jobs were not run locally.

🤖 Generated with Claude Code (model: claude-opus-4-8)
https://claude.ai/code/session_01MfUh8tgp3iBmMv9nkBqoyY

Replace the separate GlobalDefectCorrection and GlobalErrorTransport wrappers
with a single GlobalErrorEstimation(alg; equation, mode) parameterized by two
orthogonal enums:

  - equation (GlobalErrorEquation): DefectCorrection (nonlinear
    ε' = f(P+ε) - P') or ErrorTransport (linearized ε' = J(P)ε + d, matrix-free
    JVP via DifferentiationInterface).
  - mode (GlobalErrorMode): InterpolatingMode (store the dense solution,
    integrate the companion in a second pass) or SimultaneousMode (advance the
    companion inline over each step for O(1) extra memory and no second solve).

Both axes share one defect-companion implementation. Supersedes SciML#3956 and SciML#3957.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code
Agent-Model: claude-opus-4-8
Agent-Session: https://claude.ai/code/session_01MfUh8tgp3iBmMv9nkBqoyY
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 10, 2026 22:59
@ChrisRackauckas
ChrisRackauckas merged commit 5aa78f4 into SciML:master Sep 10, 2026
124 of 133 checks passed
ChrisRackauckas referenced this pull request Sep 11, 2026
Add two orthogonal enum options to GlobalAdjoint:

  - scope (GlobalAdjointScope): EndpointError (default) fills only
    sol.global_error[end]; TrajectoryError estimates the error 2-norm at every
    saved time via a discrete adjoint cost placed at each t_i, filling
    sol.global_error along the whole trajectory.
  - control (GlobalAdjointControl): ToleranceRefinement (default) tightens local
    tolerances and re-solves adaptively; StepGridRefinement re-solves
    non-adaptively on exactly the accepted step grid (adaptive=false, stepping on
    the adjoint-informed dts) for a reproducible fixed-step schedule.

Both keep the autojacvec=false (ForwardDiff Jacobian) path, since the estimator
differentiates a RHS that reads the solution interpolant (SciML/SciMLSensitivity.jl#1649).

Closes #4493 and #4494.



Agent-Harness: Claude Code
Agent-Model: claude-opus-4-8
Agent-Session: https://claude.ai/code/session_01MfUh8tgp3iBmMv9nkBqoyY

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude <[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 11, 2026
- Precompile SDE solves through specialization levels (#4467)
- Add 32-bit InterfaceI CI lane via test_groups.toml (#4480)
- incorporate time/stab filter for larger steps in FBDF (#3878)
- Keep 32-bit CI lane hard-failing. (#4482)
- Correct and validate FBDF time and stability filters (#4484)
- Keep DAE init from overwriting uprev during callback truncation (#4486)
- DiffEqBase: Int64 interp_points range length for 32-bit (#4487)
- 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)



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