lava icon indicating copy to clipboard operation
lava copied to clipboard

PyLifModelBitAcc and AbstractPyLifModelFixed do not perform Loihi accurate behavior for du

Open JuliaA369 opened this issue 3 years ago • 0 comments

Objective of issue: Modify lava/proc/lif/models.py to perform Loihi accurate behavior for du

Lava version:

  • [ x ] 0.4.0 (current version)

I'm submitting a ...

  • [ x ] bug report

Current behavior:

  • Currently Loihi current dynamics do NOT match PyLifModelBitAcc and AbstractPyLifModelFixed dynamics. Current decaying differs.

Expected behavior:

  • It is expected that if you plot the current and spiking of a Loihi 1 neuron using NxSDK, the results would be exactly the same for the same du parameter when running a LIF() process with run_cfg = Loihi1SimCfg(select_tag='bit_accurate_loihi')

Steps to reproduce:

  • The bug can be reproduced by doing the following:
  1. running the MNIST example: https://github.com/lava-nc/lava/blob/main/tutorials/end_to_end/tutorial01_mnist_digit_classification.ipynb
  2. Recording spikes_out from the SpikeInput() Process
  3. Recording lif1_u from ImageClassifier() Process
  4. Creating an identical network on Loihi 1 with NxSDK and sending the exact spike train recorded from spikes_out from the SpikeInput()
  5. Plot and compare the lif1_u with Loihi results.

Related code:

Please contact me privately for a example comparison with NxSDK.

Other information:

The source of this issue is that inside lava/proc/lif/model.py bit shifting du appears to be happening incorrectly

  1. Inside of subthr_dynamics() of the AbstractPyLifModelFixed class, on line 128 and 132 are:
decay_const_u = self.du + self.ds_offset
decayed_curr = np.int64(self.u) * (self.decay_unity - decay_const_u)

where from line 82, self.ds_offset = 1

Changing line 82 to self.ds_offset = 0 provides current equivalency between Loihi and Lava

JuliaA369 avatar Aug 25 '22 12:08 JuliaA369