-
Notifications
You must be signed in to change notification settings - Fork 12
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
Reduce device memory usage for Synapses
objects
#87
Comments
Hmm, yes, this all becomes a bit hackish... In general your ideas sound good, but it seems as if we keep adding special cases and little workarounds. I've long wanted to refactor the code generation process in a way that would make this much more straightforward, e.g. each |
This issue should also include using |
There is a bug with the poinster scheme that needs to be fixed |
There is an implementation of using offsets instead of pointers in a local brunch (has a bug currently). When checking that, also finish the comments and explanations in the synapse init template. |
Update:
|
idea how many more hours than expected you would need to solve the bug? i_j in one hour sounds reasonable! |
I narrowed the bug down functionally a bit. It seems that synaptic effects applied to synaptic variables from synapses with different delays onto the same post neuron are not applied correctly, i.e. synapses in different bundles. But synapses with the same delay from different pre neurons to the same post neuron (meaning within a bundle) are applied correctly. I haven't looked into the CUDA side yet. I feel like this could be done in 2hrs. Or take 4. Or blow up (less likely). I would suggest to spent another 2 hrs on it and reevaluate then? I have already spent the 8 hrs estimated for this issue, so any additional work now is extra. |
I am fine with your suggestion (soft limiting to two hours; if good progressuntil then 4 hours hard limit) |
All points in this issue are fixed by now. It took me ~2hrs to find the bug. But with testing and cleanup etc it was 4hrs. And I ended up doing the I realized there are two more variables that we don't always need on the device. Per synapse we also have |
great that you fixed the bug and implemented i/j for the rest let's see how brian progresses with that |
Variables to remove from device memory when not needed:
delay
lastupdate
i
andj
32bit
integer offsets instead of64bit
pointers for bundlesCurrently for each
Synapses(..., model='...', ...)
object, we allocate device arrays for theVariables
i
(pre ID),j
(post ID),lastupdate
,delay
(in seconds) and for each synaptic variable defined in themodel
keyword. The index of these arrays corresponds to the synapse ID. Now we don't always need all these arrays in device memory and could save a lot of memory for large network simulations (where the number of synapses easily results in reaching available memory limits):delay
[seconds]We don't need the delay value on the device at all (see #83).
lastupdate
We only need
lastupdate
when we have aSynapses
object withevent-driven
dynamics. Or if a user explicitly useslastupdate
in the model equations (which is a rare case I'd assume). For aSynapses
object without synaptic model variables,lastupdate
creates~1/3
of its memory demands. After a quick look, it might be possible to have a check before adding thelastupdate
variable here inSynapses.__init__()
and modifySynapticPathway.update_abstract_code()
in brian2 to get rid oflastupdate
when its not needed. One would need to check for occurrence oflastupdate
in theSynapses.model
'sSingleEquation.expr.identifiers
and theon_pre
,on_post
,on_event
code. And possibly additionalrun_regularly
calls?i
andj
Synapses which don't modify or access presynaptic (postsynaptic) neuron variables, don't need access to
i
(j
) during therun()
call (and therefore we don't need it in device memory). E.g. for a typicalSynapses(group, on_pre='v_post += const')
that would be the case.i
andj
are still needed for constructing the connectivity matrix though, but we don't need to copy it to device memory (and we could also write to disk and delete them on the host as soon as they are not needed anymore, see #84).@mstimberg Could you maybe take a look at this? Is there something that I'm missing here?
lastupdate
? And is it as easy to implement this check as I made it sound?Synapses
object needs access toi
/j
, I would check for_presynaptic_idx
/_postsynaptic_idx
in all read and written variables in asynapses
object (similar to what I'm doing here in theCUDAStandaloneDevice
. Do you see an easier way of doing this?The text was updated successfully, but these errors were encountered: