Skip to content

Accumulation for ODEProblem #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from

Conversation

DhairyaLGandhi
Copy link
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 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
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
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

end
Zygote.unwrap(val), back
end
Zygote.accum(::Tuple{}, ::NamedTuple{}) = ()
Copy link
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
Member

Choose a reason for hiding this comment

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

It is 😅

Copy link
Member Author

@DhairyaLGandhi DhairyaLGandhi May 26, 2025

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?

if initdata.initializeprobmap !== nothing
u0 = initdata.initializeprobmap(choose_branch(nlsol))
u02 = initdata.initializeprobmap(nlsol2)
Copy link
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
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
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
Member Author

Closing in favour of FluxML/Zygote.jl#1574

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