Skip to content
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

Delays and EventProp #104

Merged
merged 22 commits into from
Aug 30, 2024
Merged

Delays and EventProp #104

merged 22 commits into from
Aug 30, 2024

Conversation

neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Jul 2, 2024

This PR improves handling of delays and allows them to be learned using EventProp (using new functionality from genn-team/genn#629).

However, incorporating delays means that you need to be careful between trials to empty dendritic delay buffers (as well as outPost) and make sure variables accessed with delays (LambdaI) are also reset correctly. This PR modifies the existing reset logic using the new functionality implemented in genn-team/genn#634, namely:

  • The create_reset_custom_update helper now uses VarAccessMode.BROADCAST wherever possible so resets will be applied across all delay slots if necessary (also saves an unnecessary memory read)
  • Added new Compiler.add_out_post_zero_custom_update helper to create custom updates that zero outPost and, if necessary denDelay on device.

This PR also includes fixes for several issues which somehow only came to light when trying to train SSC.

  • Gradients were being optimised and reduced in 1st batch when they are invalid
  • During validation, gradients are still accumulated - this is fine but they weren't being zeroed before the next epoch of training. An additional custom update is now generated to do this.

Also, this PR modifies CompiledTrainingNetwork.train to take a seperate list of validation callbacks, preventing irritating issues around e.g. checkpointing and learning rate schedules which I think Tom, Balazs and everyone else who's tried to use mlGeNN hit!

Fixes #90

@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 26.92308% with 114 lines in your changes missing coverage. Please review.

Project coverage is 65.18%. Comparing base (4e39040) to head (60e2293).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
ml_genn/ml_genn/compilers/event_prop_compiler.py 19.76% 69 Missing ⚠️
ml_genn/ml_genn/compilers/compiler.py 37.03% 17 Missing ⚠️
ml_genn/ml_genn/compilers/eprop_compiler.py 0.00% 9 Missing ⚠️
ml_genn/ml_genn/callbacks/custom_update.py 50.00% 4 Missing ⚠️
...enn/ml_genn/compilers/compiled_training_network.py 20.00% 4 Missing ⚠️
ml_genn/ml_genn/optimisers/adam.py 33.33% 4 Missing ⚠️
...genn/ml_genn/callbacks/optimiser_param_schedule.py 0.00% 3 Missing ⚠️
ml_genn/ml_genn/compilers/inference_compiler.py 50.00% 2 Missing ⚠️
ml_genn/ml_genn/connection.py 50.00% 1 Missing ⚠️
ml_genn/ml_genn/utils/data.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #104      +/-   ##
==========================================
- Coverage   66.11%   65.18%   -0.93%     
==========================================
  Files         101      101              
  Lines        4123     4220      +97     
==========================================
+ Hits         2726     2751      +25     
- Misses       1397     1469      +72     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from mse_regression to master July 8, 2024 13:02
* Do not run optimiser or reduction custom updates after 1st training batch (no backward pass has completed)
* After each validation epoch, zero all gradients
… use BROADCAST mode unless their value is used to reset other variables
* Added helper to Compiler to build a custom update that zeros a Connection's OutPost and DenDelay (if it is delayed)
* Update EventProp and Inference compilers to add these in appropriate places
@neworderofjamie neworderofjamie added bug Something isn't working enhancement New feature or request EventProp labels Aug 21, 2024
@neworderofjamie neworderofjamie added this to the mlGeNN 2.3 milestone Aug 21, 2024
@neworderofjamie neworderofjamie marked this pull request as ready for review August 28, 2024 08:23
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.

I think I was able to follow most of it and it looks ok. Just to confirm, delays are not reset after an epoch, right? Only the gradients either for weights or for delays. (otherwise the reset would be fatal if learning delays, obviously).

@neworderofjamie neworderofjamie merged commit d1940bf into master Aug 30, 2024
1 check passed
@neworderofjamie neworderofjamie deleted the delays branch August 30, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request EventProp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

user callbacks with online validation
3 participants