genn-team / ml_genn

A library for deep learning with Spiking Neural Networks (SNN).
https://ml-genn.readthedocs.io
GNU Lesser General Public License v2.1
24 stars 7 forks source link

Weight quantization #88

Open neworderofjamie opened 8 months ago

neworderofjamie commented 8 months ago

I am going to add support to the e-prop and inference compilers before I merge this but thought I'd open a PR for a sanity check. Basic design is:

Quantisation helpers

Take some percentile (99% of un-quantised weight distribution) and fit a fixed point format to it

Quantisation callbacks

Pulls weights, calculates quantised version using helper and pushes

Event prop compiler

This does assume each synapse group (in GeNN speak) has its own scaling factor - will need to confirm whether this is the case on Loihi. Training with Eventprop, 8-bit weights don't cause any problems with MNIST SHD example goes from XXX to 63.9% accuracy.

Quantised weight distribution (note quantisation artefacts in long tails):

Figure_1

codecov-commenter commented 8 months ago

Codecov Report

Attention: Patch coverage is 37.81513% with 74 lines in your changes are missing coverage. Please review.

Project coverage is 61.48%. Comparing base (8822f90) to head (ab24e11).

Files Patch % Lines
ml_genn/ml_genn/compilers/event_prop_compiler.py 10.34% 26 Missing :warning:
ml_genn/ml_genn/utils/quantisation.py 21.21% 26 Missing :warning:
ml_genn/ml_genn/compilers/weight_quantisation.py 50.00% 13 Missing :warning:
ml_genn/ml_genn/compilers/inference_compiler.py 70.96% 9 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #88 +/- ## ========================================== - Coverage 62.19% 61.48% -0.72% ========================================== Files 100 102 +2 Lines 3896 4011 +115 ========================================== + Hits 2423 2466 +43 - Misses 1473 1545 +72 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.