Skip to content

Prevent callbacks from saving before and after - #10

Merged
bradcarman merged 3 commits into
bradcarman:mainfrom
jClugstor:callback_fixes
Feb 19, 2026
Merged

bradcarman merged 3 commits into
bradcarman:mainfrom
jClugstor:callback_fixes

Conversation

@jClugstor

Copy link
Copy Markdown
Collaborator

This should fix #9

@jClugstor

Copy link
Copy Markdown
Collaborator Author

@bradcarman This fixes the solve_density problem. We just need to make sure that the callbacks don't save before and after each time they are triggered. Essentially each callback was saving the same time steps, so you got a bunch of the same timepoints in the solution. I think turning saving off should be fine since we don't modify u.

There may be some performance implication to using separate callbacks, so I do want to try making a version that just uses one big callback and doing some benchmarking, but it might not even matter.

@jClugstor

Copy link
Copy Markdown
Collaborator Author

It looks like having one large callback that updates all of the parameters at once is the way to go here, at least for the size of the problem I tested, I got:

With many small callbacks: 577.576 μs (5390 allocs: 328.375 KiB)
With one big callback: 337.963 μs (3651 allocs: 194.172 KiB)

@bradcarman
bradcarman merged commit c4fa60c into bradcarman:main Feb 19, 2026
3 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.

Using a separate callback for each input causes adaptive time steppers to take many steps

2 participants