Skip to content

Fix endpoint saving after reinit! with numeric saveat - #4884

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
vera-rubin:fix/reinit-save-end
Nov 2, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
vera-rubin:fix/reinit-save-end

Conversation

@vera-rubin

Copy link
Copy Markdown
Contributor

With numeric saveat and default save_end, changing tf through reinit! can finish at 2.0 while the saved solution stops at 1.875. The documented default includes the final condition for numeric saveat.

using OrdinaryDiffEqTsit5
using SciMLBase: ODEProblem, init, solve!, reinit!
prob = ODEProblem((u, p, t) -> 1.0, 0.0, (0.0, 1.0))
integrator = init(prob, Tsit5(); saveat = 3 / 8)
solve!(integrator)
reinit!(integrator; tf = 2.0)
solve!(integrator).t  # should end at 2.0

We now recognize numeric saveat when deciding whether to save the endpoint, so saving doesn't depend on the original problem's end time. The regression checks both integration directions and explicit save_end settings, and the existing reinitialization, saving, and tstops tests pass.

Tested on upstream commit 59ba40e4b5bbae713d8df7b792f6ea62f033ff78 (Julia 1.12.7).

— ChipLab

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

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

Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a196ac-3249-7f03-bf32-22f9ef01c5f7, reviewed head 18ea56d

  • Verdict: MERGE-WITH-ISSUES
  • Risk: medium-high (MH1: the one-line change affects shared solution finalization rather than only a peripheral solver.)
  • Round / slot: 1 / 1
  • Blocking priorities: none

Review written by the reviewer named above in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.

Summary: The PR restores endpoint saving after reinit! changes tf while numeric saveat and default save_end are retained. Its regression fails on the unfixed base and passes on the reviewed head; an independent probe exposes a separate pre-existing save_end=false inconsistency suitable for follow-up.

Blast radius: solution_endpoint_match_cur_integrator!, postamble!, reinitialized ODE integrators, and callback termination with numeric saveat; the save_end guard remains intact. No integration formula, tolerance, public signature, dependency, or default solver selection changes.

Evidence: Blind assessment was written and SHA-256 sealed before author context. The full reinit file passes 49/49 at head; the identical head file against merge-base 0139bdc produces 45 passes and four failures, all in the added test. The added test specifically passes 18/18 at head and fails 4/18 at base. Independent analytic probes produce 62 passes, two failed comparisons and two consequent dimension errors; the discrepancy is reproduced on the base. GitHub reports no checks on this PR head.

Blocking findings

None.

Non-blocking findings

  1. non-blocking [P3] Follow up on endpoint-aligned save_end=false after reuse — confirmed by running, pre-existing on base and head. At lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl:453, skip_saveat_at_tspan_end compares a save time with the original problem endpoint. For u'=u, u(0)=1, original tspan=(0,1), numeric saveat=3/8 and save_end=false, solving and then reinitializing to tf=2 followed by tf=1.5 saves [0,0.375,0.75,1.125,1.5]; a fresh solve ending at 1.5 saves [0,0.375,0.75,1.125]. Thus the endpoint exclusion differs across equivalent solves. The added branch is bypassed when save_end=false, so this PR does not introduce the discrepancy. In a separate follow-up, compare against the current integration endpoint and extend test/Integrators_I/reinit_test.jl:137 with an endpoint aligned to the saving grid; the present tf=2 case is off-grid.

What I ran

All commands were read-only upstream. Source-directory prefixes and supplied depot/temp locations are represented by relative names or environment variables below to avoid recording machine paths. Julia ran sequentially, at most three processes, with JULIA_NUM_THREADS=4, OPENBLAS_NUM_THREADS=1, JULIA_PKG_PRECOMPILE_AUTO=0, an isolated TMPDIR and the supplied shared depot followed by a colon. No registry update, Pkg.test(), full package suite or upstream write was performed.

Git and metadata commands, with source commands shown relative to the repository root:

gh pr view 4884 --repo SciML/OrdinaryDiffEq.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,statusCheckRollup
git fetch origin '+refs/pull/4884/head:refs/remotes/pr/4884' master
git checkout --detach refs/remotes/pr/4884
git rev-parse HEAD origin/master
git diff --stat origin/master...HEAD
git diff origin/master...HEAD
git merge-base 0139bdc23709266d93ebadf377d63484886d1478 HEAD
gh pr view 4884 --repo SciML/OrdinaryDiffEq.jl --json title,body,commits
git log -1 --no-merges --format=%B
gh pr checks 4884 --repo SciML/OrdinaryDiffEq.jl
gh run list --repo SciML/OrdinaryDiffEq.jl --branch master --event push --limit 5 --json databaseId,headSha,conclusion,url,name

Git inspection/fetch/checkout and metadata-list commands exited 0; the individual gh pr checks exit code was not retained because it was followed by the run-list command, and its output reported no checks. The PR was open and not a draft. HEAD matched the target; the live PR metadata supplied Base above, which is also the merge-base. The fetched origin/master was d035621. The newest non-merge commit contains neither Agent-Harness nor Agent-Model trailers. Root/nested AGENTS.md and CLAUDE.md searches found no repository instructions. Read the complete diff, finalization callers, reinit!, saveat queue construction, saving documentation and test wiring.

Julia version: 1.13.2. Exact Julia command arguments, using local review harness names:

timeout 3600 julia +1.13.2 --startup-file=no --compiled-modules=existing -O1 run-head.jl
timeout 3600 julia +1.13.2 --startup-file=no --compiled-modules=existing -O1 --project=env-head run-head-verify.jl
timeout 3600 julia +1.13.2 --startup-file=no --compiled-modules=existing -O1 --project=env-base run-base-verify.jl

The first process activated a temporary environment, developed the checkout, added DiffEqCallbacks and ODEProblemLibrary, and instantiated without automatic precompilation. It exited 1 before executing tests because the harness attempted to import transitive dependency OrdinaryDiffEqCore directly. The remaining processes accessed it through OrdinaryDiffEq.OrdinaryDiffEqCore; printed source locations confirmed the intended head/base code. Dependencies were identical between environments (including SciMLBase 3.58.0, DiffEqCallbacks 4.19.5 and ODEProblemLibrary 1.5.5); the base environment redirected local package paths to a git archive of the merge-base.

Head process: included the entire test/Integrators_I/reinit_test.jl, including the added test unchanged. Output: PR 4884 full reinit test at head | 49 49; all 18 added assertions passed. Then an independent probe solved u'=u with reference exp(t), both integration directions, save_end=nothing/false/true and sequential tf values of signed 2, 1.5 and 2.5, comparing saved grids and values with fresh solves. It also checked early termination at signed 0.7 for u'=1 with callback saving disabled and analytic u(t)=t. Output: Independent analytic saving probe | 62 2 2 66; exit 1. Both failures are the save_end=false, tf=+/-1.5 grid discrepancies described above; both errors are consequent comparisons of unequal-length value arrays. Analytic value checks and early-termination checks passed. The subsequent saving-schedule transition reports did not execute because the testset raised.

Base process: first printed saving-schedule transitions and reproduced the positive-direction save_end=false discrepancy, then included the identical head reinit file against unfixed base packages. Output: PR 4884 head full reinit test against unfixed base | 45 4 49; added test: 14 4 18; exit 1. Default save_end omitted both signed endpoints: saved time +/-1.875 instead of +/-2, with saved value approximately +/-1.875 instead of +/-2. Explicit true/false cases passed. This establishes failing-before/passing-after for the added regression; no test was weakened or skipped.

CI metadata inspected: no PR checks, hence no failed PR job logs to inspect. Recent master metadata shows failures for CI, Sublibrary CI and IntegrationTest, and success for Downgrade and Documentation. These are metadata observations only; I did not inspect their failed logs or claim that any CI failure is inherited by the PR.

G1: the added regression uses the independent analytic solution u(t)=t, and the probe checks exp(t). G2: the changed numeric-saveat endpoint branch executed locally; this diff introduces no GPU, AD, tracing or MPI implementation. G3: the regression explicitly solves, reinitializes with a new tf and solves again, exercising cache reuse.

What I did not verify

I did not run GPU, AD, Reactant, MPI, stochastic/delay integrators, alternative Julia versions/platforms, heavy downstream suites, the separate saving/tstops test files, or a full package suite. I did not independently reproduce the author's claimed Julia 1.12.7 runs. No PR CI execution is available. The head saving-schedule type-transition reports were not reached after the independent probe failed; only base transition outputs are available. Reverse-direction reproduction of the pre-existing save_end=false discrepancy was observed at head; the base reproduction checked the positive direction only. The new regression and all existing tests in its file were executed unchanged on both versions. No further Julia runs were made after the third process.

🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74

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