BlueBrain / BluePyOpt

Blue Brain Python Optimisation Library
https://bluepyopt.readthedocs.io/en/latest/
Other
198 stars 96 forks source link

isolate_protocols=True causing NEURON to reset dt #424

Closed wthun closed 1 year ago

wthun commented 1 year ago

When passing a simulator with a fixed, non-standard time step to ephys.evaluators.CellEvaluator, I receive:

Exception: NrnSimulator: Some process has changed the time step dt of Neuron since the creation of this NrnSimulator object. Not sure this is intended:
current dt: 0.025
init dt: 0.1

This only happens when setting isolate_protocols to True, so I guess this happens due to the dt value not persisting when NEURON is imported onto new threads (i.e. around line 252 in protocols.py)?

I see the same behaviour in a minimal example.

DrTaDa commented 1 year ago

Hello @wthun ,

Thank you for opening this issue.

The error is expected in this case. It happens because you ask both for cvode=True and a specific time step dt of 0.1. These two requirements are incompatible since cvode means varying time step. Therefore if you wish to use cvode you shouldn't pass a dt when initializing the simulator object.

The error message is not very explicit. We will work on it.

wthun commented 1 year ago

Hello,

I seem to get the same error when disabling cvode. There is an example attached in the original post, where passing nrn = ephys.simulators.NrnSimulator(dt=dt, cvode_active=False) and then passing that simulator to the evaluator object results in the same error.

DrTaDa commented 1 year ago

Indeed. I am sorry I misunderstood your example. We will fix that.

wthun commented 1 year ago

No worries and thanks for the help!

AurelienJaquier commented 1 year ago

Hi! I can run your example without any error in linux, but the error shows up when I run under macos. Do you confirm @wthun that you also encountered this error on macos?

It looks like this is out of the scope of BluePyOpt, and should be solved at the NEURON level. I'll open an issue there first, and see if we have to change BluePyOpt once they have acted on it.

Thanks for raising this issue @wthun

wthun commented 1 year ago

Yes, but I originally encountered this on Linux. I receive the same error If I run the same example using Ipyparallel and passing lview.map_sync to the optimiser ((like this). In that case, isolate_protocols doesn't seem to help.

AurelienJaquier commented 1 year ago

Alright, the latest version of BluePyOpt should work fine with custom dt, both when isolate_protocols=True on macos, and when using ipyparallel.

AurelienJaquier commented 1 year ago

I'll close this issue. If you still have problems @wthun do not hesitate to re-open it.