Skip to content

Clarify observed save_idxs rejection (DE #1036) - #1467

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/save-idxs-observed-error
Jul 24, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/save-idxs-observed-error

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

This PR should be ignored until reviewed by @ChrisRackauckas.

Related: SciML/DifferentialEquations.jl#1036 (observed variables in save_idxs).

What this is (and is not)

This is the smallest correct slice for DE #1036: a dedicated error + docs when observed symbols appear in save_idxs. It does not implement observed save columns.

Full support is intentionally out of scope for this PR. Solver save paths (e.g. OrdinaryDiffEqCore) hard-code u[save_idxs] integer indexing. Eval-at-save observed storage needs a multi-package design (SavedSubsystem observed map + save-path evaluation + interpolation policy). Silently expanding observed to full-state save would look like support but would not meet the memory goal and would be a wrong answer.

Change

When is_observed(indp, var) holds for a rejected save_idxs entry, throw:

ArgumentError: Saving observed variables via `save_idxs` is not yet supported (got …).
… workarounds: full sol[obs]; DiffEqCallbacks.SavingCallback; save dependent states.
See SciML/DifferentialEquations.jl#1036.

Generic non-state / non-timeseries-parameter rejection is unchanged.

Docs updated:

  • docs/src/interfaces/Symbolic_SaveIdxs.md — explicit observed limitation
  • docs/src/interfaces/Common_Keywords.md — save_idxs keyword note

Tests (run locally)

Unit (SymbolCache Expr as observed):

save_idxs rejects observed quantities | 13 passed
POST_RUNIC_OK

Downstream MTK + regression:

Saved subsystem subset incl observed rejection | 19 passed
REGRESSION_OK

Including: observed-only and mixed [x, obs] rejection, full-solve sol[obs] still works, symbolic state save_idxs still works, all-states symbolic translation regression from #1460 still works.

Follow-up design (not in this PR)

  1. Extend SavedSubsystem with observed_map (saved column → observed symbolic + callable).
  2. Change integrator save path to evaluate observed at save points when requested.
  3. v1 policy: require saveat / non-dense for observed-only; refuse dense interp unless parent states also saved.
  4. Clear errors if indexing an unsaved, non-reconstructible symbol.

Observed symbols in save_idxs were already rejected, but with a generic
"variables and timeseries parameters" message that did not distinguish
observed quantities from other invalid symbols. Detect is_observed and
raise a dedicated ArgumentError with workarounds and a pointer to
DifferentialEquations.jl#1036. Document the limitation on the symbolic
save_idxs and common-keywords pages. Add unit and MTK downstream tests.

Full observed save_idxs support is intentionally not implemented: solver
save paths are integer u[idxs] indexing, and eval-at-save observed columns
need SavedSubsystem + OrdinaryDiffEqCore design work beyond a small PR.

Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 24, 2026 06:18
@ChrisRackauckas
ChrisRackauckas merged commit 089609e into SciML:master Jul 24, 2026
46 of 63 checks passed
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