Skip to content

feat: implement SII.remake_buffer for MTKParameters, fix bugs, add tests #2570

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

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

AayushSabharwal
Copy link
Member

@AayushSabharwal AayushSabharwal commented Mar 25, 2024

Close #2571

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

Add any other context about the problem here.

@ChrisRackauckas
Copy link
Member

Is this supposed to fix #2571? Can we get a direct test on that behavior?

Comment on lines +95 to +103
ps = MTKParameters(sys, ivs)
function loss(value, sys, ps)
@test value isa ForwardDiff.Dual
vals = merge(Dict(parameters(sys) .=> getp(sys, parameters(sys))(ps)), Dict(a => value))
ps = remake_buffer(sys, ps, vals)
getp(sys, a)(ps) + getp(sys, b)(ps)
end

@test ForwardDiff.derivative(x -> loss(x, sys, ps), 1.5) == 3.0
Copy link
Member

Choose a reason for hiding this comment

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

what about a test that actually uses remake?

Copy link
Member Author

Choose a reason for hiding this comment

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

remake doesn't use remake_buffer yet so that would just fail. I've planned refactoring remake for after this since without it remake would fail for all MTK problems

@ChrisRackauckas ChrisRackauckas merged commit 0116cd1 into SciML:master Mar 28, 2024
@AayushSabharwal AayushSabharwal deleted the as/remake-hook branch March 28, 2024 10:18
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.

Error with MTKParameters and Dual Numbers
2 participants