nest / nestml

A domain specific language for neuron and synapse models in spiking neural network simulation
GNU General Public License v2.0
46 stars 45 forks source link

NEST stalling for specific sets of parameters of a NEST ML model #1088

Closed DrTaDa closed 2 months ago

DrTaDa commented 2 months ago

Hello, When running the NEST ML version of the aeif_cond_exp neuron model, NEST "stalls" during the nest.Simulate(100.) command for specific sets of parameters. This does not happen when using the same parameters in the NEST aeif_cond_exp neuron model.

The issue can be reproduced with the following code and the attached NEST ML model (aeif_cond_exp_test_neuron.nestml.zip)

import nest

nest.Install("nestmlmodule")

params = {
        'E_L': -80,
        'V_reset': -60.0,
        'refr_T': 2.0,
        'g_L': 4,
        'C_m': 32,
        'E_exc': 0.0,
        'E_inh': -80.0,
        'tau_syn_exc': 1.5,
        'tau_syn_inh': 4.2,
        'a' : -0.8,
        'b' : 80,
        'Delta_T' : 0.8,
        'tau_w' : 144.0,
        'V_th' : -57.0                          
    }

neuron = nest.Create("aeif_cond_exp_test_neuron", 10)

for param in params:
    neuron.set({param: params[param]})

neuron.set({'v': -54})

nest.Simulate(100.)

Could you let me know if there is a way to debug NEST ML models ? Or If there is something obvious I am missing ?

nest-simulator==3.5 nestml== 7.0.2.post0.dev0 (also tried with 8.0.0rc1.post0.dev0) cmake version 3.16.3

clinssen commented 2 months ago

Hi, thanks for writing in! I am not an expert on the model, but is it okay for the parameter $a$ to take on negative values? In case this makes the system mathematically unstable, it might cause issues with the numerical integrator.

From Izhikevich (2003):

The parameter a describes the time scale of the recovery variable u. Smaller values result in slower recovery. A typical value is a = 0.02

DrTaDa commented 2 months ago

Hello @clinssen, thank you for your answer. Sorry, I left our custom parameter set. It does not work either with the value of 0.02.

I was more curious about why it works when using the NEST model but not the NEST ML model. The equations for both being identical. Is there a way to debug NEST ML models ? Here the model does not even pass the first time step.

clinssen commented 2 months ago

Thank you for the update! I believe this is due to NEST having more stringent solver tolerances than NESTML by default. I have updated the defaults in #1086. Could I ask you to try the code from that PR to see if it solves your issue? Much obliged!

For more debug output, you could uncomment the #define DEBUG flag in the C++ jinja2 template files, and you can also add your own print() statements directly in the NESTML files (or directly in the C++ code using std::cout).

DrTaDa commented 2 months ago

It works ! Thank you for your help, you are a lifesaver.

clinssen commented 2 months ago

Super cool, no prob! Please let us know if you run into any further issues.