Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very poor performance on simple taylor function #113

Open
staticfloat opened this issue Feb 27, 2023 · 1 comment
Open

Very poor performance on simple taylor function #113

staticfloat opened this issue Feb 27, 2023 · 1 comment

Comments

@staticfloat
Copy link
Collaborator

staticfloat commented Feb 27, 2023

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.

@ToucheSir
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants