Very poor performance on simple taylor function
In Chris' recent SciML video, at this timestamp he showcases a little AD benchmark. Summarizing, differentiating the function:
function taylor(x, N)
sum = 0 * x
for i = 1:N
sum += x^i / i
end
return sum
end
Shows pretty poor performance in Diffractor. I've created a gist that contains a Project, Manifest and test script to showcase the issue. You can increase N to get harder and harder problems. Note that I was unable to get Enzyme working on master (perhaps I need to check out the master branch) and Diffractor dies with a stack overflow if N is too large.
For N=10^4, we get timings of Enzyme's code running in <1ms, and Diffractor taking more than 300ms. Zygote and ForwardDiff are both well under 10ms.
For my own edification, wouldn't Diffractor have to fully inline all pullbacks here and determine that the number of iterations in reverse is bounded by N? Otherwise I'd imagine large loops like this are a worst-case scenario for the linked list of pullbacks approach currently employed.