LIF Process models fail/hang with use_graded_spike=True
Objective of issue: Fix LIF ProcessModels so that graded spike work.
Lava version:
- [ ] 0.5.0 (feature release)
- [ ] 0.4.1 (bug fixes)
- [x] 0.4.0 (current version)
- [ ] 0.3.0
- [ ] 0.1.2
I'm submitting a ...
- [x] bug report
- [ ] feature request
- [ ] documentation request
Current behavior:
- using the LIF process with use_graded_spike=True fails, system crashes or hangs at runtime
Expected behavior:
- not failing...
Steps to reproduce:
from lava.proc.io import sink, source from lava.proc.lif.process import LIF from lava.proc.dense.process import Dense
from lava.magma.core.run_configs import Loihi1SimCfg from lava.magma.core.run_conditions import RunSteps vec = np.array([5, 100, 0, 20]) weights = np.zeros((3,4)) weights[:, 0] = [10, 5, 0] weights[:, 1] = [5, 5, 10] weights[:, 2] = [0, 10, 5] weights[:, 3] = [5, 50, 5]
inport_plug = source.RingBuffer(data=vec) dense_weights = Dense(shape=weights.shape, weights=weights, use_graded_spike=True) lif_layer = LIF(shape=(3,), vth=10, du=1, dv=1, use_graded_spike=True)
outport_plug = sink.RingBuffer(shape=(3,), buffer=10)
inport_plug.s_out.connect(dense_weights.s_in) dense_weights.a_out.connect(lif_layer.a_in) lif_layer.s_out.connect(outport_plug.a_in)
lif_layer.run(condition=RunSteps(num_steps=3), run_cfg=Loihi1SimCfg())
Related code:
I have fixed this. There are two problems in the LIF Process model. First the variable "vth_effective" is not defined at the process, but this variable is not needed and can be replaced with "vth". Second, the function reset_voltage is failing when use_grarded_spike=True because the variable "spike_vector" is no longer a boolean numpy array. This can be fixed by changing reset_voltage to force spike_vector to be boolean, for instance:
def reset_voltage(self, spike_vector: np.ndarray):
"""Voltage reset behaviour. This can differ for different neuron
models."""
self.v[spike_vector > 0] = 0
# perhaps like this is more appropriate:
# self.v[spike_vector ~= 0] = 0
insert short code snippets here
Other information:
insert the output from lava debug here