Skip to content

Accumulation for ODEProblem - #1036

Closed
DhairyaLGandhi wants to merge 12 commits into
SciML:masterfrom
DhairyaLGandhi:dg/sym_oop
Closed

DhairyaLGandhi wants to merge 12 commits into
SciML:masterfrom
DhairyaLGandhi:dg/sym_oop

Conversation

@DhairyaLGandhi

Copy link
Copy Markdown
Member

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Sister PR for FluxML/Zygote.jl#1574 which would have much narrower dispatch for getfield.

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review May 26, 2025 11:49
Comment thread ext/SciMLBaseZygoteExt.jl Outdated
Comment on lines +309 to +315
error()
dx = (; Zygote.nt_nothing(x)..., pair(Val(f), Δ, x)...)
(_project(x, dx), nothing)
else
dx = Zygote.grad_mut(__context__, x)
dx[] = (; dx[]..., pair(Val(f), Zygote.accum(getfield(dx[], f), Δ))...)
return (dx,nothing)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this block if the first line is error()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in a03bb02

Comment thread ext/SciMLBaseZygoteExt.jl
end
Zygote.unwrap(val), back
end
Zygote.accum(::Tuple{}, ::NamedTuple{}) = ()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this type piracy?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is 😅

@DhairyaLGandhi DhairyaLGandhi May 26, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... FluxML/Zygote.jl#1574 is definitely the safer bet.

Why are problem types mutable? Do they need to be?

Comment thread src/initialization.jl Outdated
nlsol2 = prob.f.initialization_data.initializeprob
if initdata.initializeprobmap !== nothing
u0 = initdata.initializeprobmap(choose_branch(nlsol))
u02 = initdata.initializeprobmap(nlsol2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make sense - we solve initialization, but calculate the new u0 from the unsolved problem?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has contains some of the changes we had made previously to resolve the error. It is possible to remove the changes to initialization.jl, just the Zygote patch should be sufficient.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c85dfa2

@DhairyaLGandhi

Copy link
Copy Markdown
Member Author

Closing in favour of FluxML/Zygote.jl#1574

ChrisRackauckas added a commit that referenced this pull request Jul 24, 2026
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: ChrisRackauckas-Claude <[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.

3 participants