Closed lkeegan closed 3 years ago
@lkeegan : could you add some reference framework / pseudo-code for implementing this one?
@pramodk yes will do
@cattabiani : could you take a look at this ticket and understand overall scope off this ticket by reviewing existing solver implementation and references issues?
The overall idea is that if sympy fails then we need a fallback solver that we can rely on. This is needed to deprecate mod2c completely.
@pramodk do we already have a mod file where sympy fails?
@cattabiani : off the top of my head I don't remember any mod file which was failing with sympy solver. But may be you can build artificial one ? You can also see some motivation in #55 and #85.
I am still reading literature about the latest methods around. Looks like numerical/automatic differentiation is used extensively in deep learning and there are already many tools available. Automatic differentiation looks superior (for a computer program) than the numerical one and avoids a lot of the pitfalls. Now the question is: what tool do we want to use?
A summary of what I have found:
if you have experience on the topic I am happy to hear your ideas @ferdonline @pramodk
if you have experience on the topic
no...not much! I wonder if @ohm314 remember anything on this topic because IIRC he had discussions.
tensorflow, pytorch quite big projects. Do we need cannons?
certainly not!
@lkeegan : could I ask you if you remember what were were planning and possible ways to implement this? (of course if you remember)
After some research (thx @ohm314 ) here are a few notes.
For these reasons, I am going to check how AD in eigen works exactly and, then, try to use it in case of control flow blocks and nonlinear system, which, by its structure, is already "in shape" to have eigen AD plugged in (I think)
@pramodk the idea was to have a version of the newton solver that used a simple numerical differentiation approximation to the jacobian as a fall back for the cases where sympy could not be used to provide the analytic jacobian (e.g. verbatim blocks), which was implemented here: https://github.com/BlueBrain/nmodl/blob/master/src/solver/newton/newton.hpp#L80-L152 I think if the sympy pass fails nmodl should use this version of the newton solver instead, although I can't remember if this was fully implemented - I remember getting lots of help from @ohm314 on this so maybe he remembers.. But if it would be possible to replace this with an AD method that would definitely be an improvement!
I checked and I did not find any practical case where sympy analytic can fail. AD is better in case of "equation swelling". However, for hand-written equations that problem is minor/non-existant. Thus, I close this issue. If there are any real case scenario appearing I will reinvestigate this issue