Skip to content

Invalidate integrator caches after parameter mutation - #1575

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/invalidate-integrator-parameters
Draft

Invalidate integrator caches after parameter mutation#1575
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/invalidate-integrator-parameters

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 31, 2026

Copy link
Copy Markdown
Member

Ignore this PR until it has been reviewed by @ChrisRackauckas.

What changed and why

Symbolic parameter assignment through integrator.ps[...] now marks a DEIntegrator's derivative as discontinuous when SymbolicIndexingInterface finishes the assignment. This makes the next step! refresh method caches instead of advancing with derivative data computed from the previous parameter value.

This supplies the missing integrator specialization of the existing SymbolicIndexingInterface.finalize_parameters_hook! extension point. It enables the single-integrator interactive workflow discussed in SciML/ModelingToolkit.jl#5006 (comment) without repeatedly calling reinit!.

Regression evidence

With the new regression test present and the production change removed:

$ julia --startup-file=no --project=test/downstream test/downstream/integrator_indexing.jl
Parameter mutation invalidates integrator caches: Test Failed at test/downstream/integrator_indexing.jl:97
  Expression: integrator[:x] ≈ 1.0
   Evaluated: 0.9035392331819345 ≈ 1.0
Test Summary:                                    | Fail  Total  Time
Parameter mutation invalidates integrator caches |    1      1  5.6s
ERROR: LoadError: Some tests did not pass: 0 passed, 1 failed, 0 errored, 0 broken.

With this change applied, rerun after rebasing onto the latest upstream/master:

$ julia --startup-file=no --project=test/downstream test/downstream/integrator_indexing.jl
Test Summary:                                    | Pass  Total  Time
Parameter mutation invalidates integrator caches |    1      1  2.5s
Test Summary:   | Pass  Total  Time
Symbolic set_u! |    1      1  2.3s
[exit code 0]

Verification

$ GROUP=Core julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()'
Test Summary:        | Pass  Total
Integrator interface |   14     14
Test Summary: | Pass  Total
Remake        | 4605   4605
Testing SciMLBase tests passed

$ GROUP=Downstream julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()'
Test Summary:     | Pass  Total
Solution Indexing |  277    277
Test Summary:  | Pass  Total
initialization |   83     83
Testing SciMLBase tests passed

$ PIXI_CACHE_DIR=/home/crackauc/sandbox/tmp_20260831_125419_177237/pythoncall-fresh-pixi-cache RATTLER_CACHE_DIR=/home/crackauc/sandbox/tmp_20260831_125419_177237/pythoncall-fresh-pixi-cache TMPDIR=/home/crackauc/sandbox/tmp_20260831_125419_177237/.tmp GROUP=QA julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()'
Test Summary: | Pass  Total     Time
QA            |  123    123  3m22.9s
Testing SciMLBase tests passed

$ TMPDIR=/home/crackauc/sandbox/tmp_20260831_125419_177237/.tmp julia --startup-file=no --project=docs docs/make.jl
[exit code 0; doctests, link checking, and rendering completed]

$ julia --startup-file=no -m Runic --check test/integrator_tests.jl test/downstream/integrator_indexing.jl
[exit code 0]

$ typos docs/src/interfaces/Init_Solve.md src/integrator_interface.jl test/downstream/integrator_indexing.jl test/integrator_tests.jl
[exit code 0]

$ git diff --check upstream/master...HEAD
[exit code 0]

The first QA attempt exposed a corrupted shared Pixi package cache: cached Python standard-library files were zero bytes. The same failure reproduced on a clean master worktree. Re-running against a fresh workspace-local Pixi cache produced the 123/123 result above; no repository change was needed for that machine-state failure.

Review notes and unverified paths

No public API is added; this specializes an existing SII hook for DEIntegrator. Everything, GPU, Julia pre-release, and unrelated sublibrary/downstream jobs were not run locally.

The two failing DownstreamAD CI jobs also fail in the master run at the PR's exact base SHA, 3d95609f7dc1c86a8fded41b9d357bcf25b83ad3: https://github.com/SciML/SciMLBase.jl/actions/runs/33443540855/job/99658026211 and https://github.com/SciML/SciMLBase.jl/actions/runs/33443540855/job/99658026315. The LTS failure is addressed by #1574. The Julia 1.12 Mooncake failure is reduced and tracked separately at #1578.

The new source hunk was formatted with Runic. A whole-file Runic check of src/integrator_interface.jl still detects an unrelated pre-existing formatting hunk, which this behavior-change PR deliberately does not include.

🤖 Generated with Codex CLI 0.151.0 (model: gpt-5.6-sol; session: local session ID 01a057e2-edc7-7342-9835-8122a5c647eb).

Mark DEIntegrator derivatives discontinuous when symbolic parameter assignments finish so solver caches are refreshed before the next step.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.151.0
Agent-Model: gpt-5.6-sol
Agent-Session: local session ID 01a057e2-edc7-7342-9835-8122a5c647eb
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Follow-up plan for the workflow in SciML/ModelingToolkit.jl#5006 (comment):

  1. Land the cache-invalidation hook in this focused PR.
  2. Add a ModelingToolkit guide for a single long-lived integrator with symbolic parameter updates and step!.
  3. Handle automatic history for time-varying @discretes as a separate API/design discussion; ordinary @parameters remain time-invariant.

This PR intentionally covers only step 1.

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