Skip to content

Comments

Merge pre and postsynaptic update#461

Merged
neworderofjamie merged 31 commits intomasterfrom
merge_pre_post_update
Oct 25, 2021
Merged

Merge pre and postsynaptic update#461
neworderofjamie merged 31 commits intomasterfrom
merge_pre_post_update

Conversation

@neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Sep 21, 2021

GeNN has supported pre and postsynaptic weight update models variables and associated update code since #152 (with some extra flexibility introduced in #377). This is nice in terms of modularity but, the implementation is very sub-optimal for models with complex connectivity when compared to the hackier approach. If you have a neuron population with multiple incoming or outgoing synapse populations, all with the same learning rule, the variables get duplicated and, in the neuron kernel, they all get read from memory, updated using the same code and written back to memory.

Postsynaptic models suffered from the same problem which I solved in #201. This PR basically does the same for these pre and postsynaptic weight updates. Essentially two outgoing synapse groups with presynaptic update code (incoming with postsynaptic is basically equivalent) will get merged together if:

  1. They have the same weight update model (this could potentially be relaxed a little as most of the model can be ignored)
  2. Any parameters/derived parameters referenced in the presynaptic update code are the same
  3. There are no extra global parameters referenced in the presynaptic update code
  4. All their presynaptic variables are initialised to the same constant value (variables associated with merged groups are not accessible to the user so, when combined with the other constraints, this means they will evolve in the same way)

The previous change for postsynaptic models significantly improved performance on the microcircuit model so I would imagine this change will be similarly beneficial once we start simulating models which combine more complex connectivity and learning.

# Conflicts:
#	tests/unit/synapseGroup.cc
…t have been merged

* Did some renaming to clarify
* Implementations of ``SynapseGroup::getWUPreMergeHashDigest`` and ``SynapseGroup::getWUPostMergeHashDigest``
* All comes together into implementation of ``NeuronGroup::mergePrePostSynapses``
…d outgoing synapse groups with variables and code
@neworderofjamie neworderofjamie added this to the GeNN 4.6.0 milestone Sep 21, 2021
@codecov
Copy link

codecov bot commented Sep 21, 2021

Codecov Report

Merging #461 (05697c5) into master (60f01cf) will increase coverage by 0.26%.
The diff coverage is 97.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #461      +/-   ##
==========================================
+ Coverage   87.25%   87.52%   +0.26%     
==========================================
  Files          78       78              
  Lines       17056    17277     +221     
==========================================
+ Hits        14883    15121     +238     
+ Misses       2173     2156      -17     
Impacted Files Coverage Δ
include/genn/genn/code_generator/groupMerged.h 86.65% <ø> (ø)
include/genn/genn/modelSpec.h 81.16% <0.00%> (-1.07%) ⬇️
include/genn/genn/neuronGroupInternal.h 0.00% <ø> (ø)
include/genn/genn/synapseGroupInternal.h 75.00% <ø> (ø)
src/genn/genn/gennUtils.cc 98.78% <ø> (ø)
src/genn/genn/synapseGroup.cc 85.14% <96.77%> (+2.40%) ⬆️
src/genn/genn/code_generator/groupMerged.cc 90.00% <96.96%> (+1.19%) ⬆️
src/genn/genn/neuronGroup.cc 95.13% <99.03%> (+1.21%) ⬆️
include/genn/genn/neuronGroup.h 73.68% <100.00%> (+0.95%) ⬆️
include/genn/genn/synapseGroup.h 91.83% <100.00%> (+0.92%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60f01cf...05697c5. Read the comment docs.

@tnowotny
Copy link
Member

Looking at the thesaurus, maybe we should call this process "fuse", "fused".
And reserve "merge", "merged" for the kernel merging?
I also think "fused" presynaptic vars has the right sound to it.

@neworderofjamie
Copy link
Contributor Author

I like it - will save that change for when I'm at home and can throw the Visual Studio magic rename tool at it 😄

@neworderofjamie neworderofjamie marked this pull request as ready for review September 22, 2021 12:51
@neworderofjamie
Copy link
Contributor Author

I'm afraid the renaming somewhat dwarves the actual changes but still...The most meaningful new bits are probably the rules which define when updates can be merged and are in SynapseGroup.cc

Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

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

Interesting point about the trade off of "efficient hacky" with "more clean but less efficient" there ...
As for implementation details
a) your list of conditions sounds right
b) I assume you have added a test or two (I can't easily review the detailed code changes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants