feat: Add AdapterCheckpoint class to run simulations in steps#921
feat: Add AdapterCheckpoint class to run simulations in steps#921
Conversation
There was a problem hiding this comment.
The BSB is in a stable and mature phase now, new features best pass through a phase of technical discussion with a write up of the use-cases and an agreed upon technical proposal before moving to the implementation phase.
@drodarie @filimarc I don't understand the use case or context of this PR so I can't really provide review, can we write up the use case for this in an issue before continuing with this one?
I think it's best in general that we first write an issue for something, tag each other to get each other's input, come up with a proposal we agree on, and then someone can start on implementation.
What I think I can extract from context:
- There are devices that need to run a callback (let's say "flush") at certain times
- The devices need to be able to schedule all their callbacks
- The simulation control should pause and run their callbacks as scheduled
If I have understood the objective correctly I have some issues with the current implementation:
- CMIIW, but it seems like the user has to change the simulation run code in order for this to work? That's not acceptable because devices that depend on this interface might be used without this altered setup, which would break things. This feature would need to work in such a way that as soon as a device is added that uses checkpoints, the simulation control is adjusted.
- The base
DeviceModelis too coupled to this feature. If we add this I think the entire feature should be optional and theDeviceModelclass should be left as-is; at most we can add aget_checkpointnoop placeholder that returns[]. Any other logic should be moved to opt-in mixins, so that each device can implement their own checkpoint logic based on their needs.
Then some implementation details, that we can discuss only after we decide on the proposal:
- The checkpoints are now all known, but then it seems that they are sorted many times, why not sort them once and store them sorted?
- Since all checkpoints are known, what is this
suitable_stepneeded for exactly? - There seems to be a conflation between the simulator timestep
resolutionand this feature. I didn't go into enough detail to figure out the problem, but: theresolutionmatters only for accuracy of the numerical solvers vs. computational load; it shouldn't be tied to how we start-stop pieces of the simulation, like we do here. Theresolutionis simply a setting we set on the underlying simulator; e.g. it's totally fine to set a resolution of0.1ms, and then tell the BSB to simulate1sin pieces of2ms, the underlying simulator will then simulate those many pieces of2ms still with a resolution of0.1ms, returning to the BSB start-stop loop in Python every2ms. They are different things
|
Hi,
|
|
Thanks, this addresses my concerns, and yes I'd prefer this the base DeviceModel implements only an optionally extensible interface whose default behavior is "no checkpoints", and that any logic that lets users add certain specific checkpoint behaviors, be provided as a mixin :) For the remaining 3 points, shall we discuss in the laboratory? Which days are you physically present? |
Describe the work done
For some devices may be necessary to flush the results before simulation ends. Here is proposed a class that managed a list of checkpoints, extracted from devices' configuration. All Device classes now have a checkpoint attribute that AdapterCheckpoint can inspect before simulation start.
Tasks
📚 Documentation preview 📚: https://bsb--921.org.readthedocs.build/en/921/