-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Inaccurate updates when having multiple differential equations in neuron groups #135
Comments
Umm, many thanks for reporting this, this looks indeed like a serious issue! I will look into this in more detail at the end of the week. |
I started looking into this, but I did not yet get completely to the bottom of it. The discrepancy between Brian2GeNN and C++ standalone is partly expected for your model, but I'm still figuring out what is going when you add the monitor (in my simplified example, the monitor does not seem to make any difference anymore, somehow it also seems to require a magic_network.schedule = ['start', 'synapses', 'groups', 'thresholds', 'resets', 'end'] and also move the state update of the S.state_updater.when = 'before_synapses' then you should have the same basic scheduling in Brian as in Brian2GeNN. As I said earlier, there is probably still some bug in Brian2GeNN (I'm suspecting related to moving memory from/to the GPU), since obviously results should not change with the addition of a |
It took me a long time to get back to this, but I finally figured out what is going on. As so often, the issue was very puzzling but the final explanation (and the fix) is quite simple... Here's a quick explanation: Brian2GeNN mostly runs things on the GPU (that's the whole idea, of course), but for simplicity, |
Previously, all variables of the owner were pushed, potentially overwriting existing values on the device. Fixes #135
Hi there! In Brian2GeNN, when having multiple differential equations in a neuron group, some are not updated continually. Probably, for efficiency reasons, they are not constantly updated when not needed in the neurons. However, when they are needed in the synapses, this can be a problem.
Below, you can find a toy script that shows this possible problem. Two equations for two variables ('v' and 'r') are included in a neuron group. The second variable is not needed to calculate the updates in the first one. However, it is needed to update the synapses. If we place a monitor in this second variable, it surprisingly updates correctly (as it is explicitly needed in every time step). When the monitor is removed, it updates wrongly. This behaviour can be tested by trying different values for the variable 'monitor' (True/False) in different executions. Also, it doesn't occur when using Brian2 alone (no GeNN backend). You can test it by changing the value of the variable 'GPU' to False.
I attached some images with the resulting distribution of the synaptic values for these different situations. The values only change when not tracking this second variable (monitor=False) using the GeNN backend (GPU=True). In this toy example, there's only a slight difference. But when using large networks in long simulations, the changes are immense.
ToyExample_Brian2GeNN.zip
The text was updated successfully, but these errors were encountered: