-
Notifications
You must be signed in to change notification settings - Fork 29
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
Bad interaction with Enzyme? #184
Comments
Forgot to add versioninfo
and pkg status
|
I don't know what to make of this error. The recursive code for scalar reductions is here, and perhaps something about this looks problematic? E.g. the number of recursions depends on an Int, from https://github.com/mcabbott/Tullio.jl/blob/master/src/threads.jl#L217-L256 |
Pinging @wsmoses which is the expert here ... |
Reading the linked issue EnzymeAD/Enzyme.jl#1279 I see that perhaps the suggestion is that Tullio should have Enzyme gradient rules -- as it currently does for Zygote & Tracker. That would be fine, someone just has to write them! I was defeated when last I tried to write Enzyme rules (for some NNlib funcitons), but maybe docs & examples have improved since then. Comments:
|
Folliwng up here since I closed the linked PR (it now works without a rule on present Enzyme). However I do think a tullio rule here is appropriate. Happy to help however I can. The rough semantics required for rules are: Forward Mode: Enzyme will provide x, dx, y, dy, etc but I dont know how to do those ops in tullio. For reverse mode x[i,j,k] = f(y[u,v], z, ...) dy[u,v] += df(dx[i,j,k], y, z, ...)
|
Many thanks for taking a look. I'm really swamped but I believe that adding a simple reverse-mode rule would be quite simple. Tullio already writes functions for computing all the reverse gradients, and uses them for Zygote etc. Adding similar functions for forward mode would not be very hard, but would require some new transformations. Fully exploiting what Enzyme knows about activity would be ideal, but is unlikely. This package always writes all code at macro-expansion time, so it would need to speculatively write code for several possibilities. In some cases, knowing that a particular array is const would change what loops can be parallelised in the gradient. But Tullio really isn't set up to think about multiple such possibilities at once. |
Hi there!
Cross linking here the original issue on Enzyme following the advice of @wsmoses.
Repeating here:
I experience a problem with Enzyme interacting with Tullio. The MWE is the computation of the trace of the product with two matrices$tr(A,B)$ . I wrote a method with loops and one using Tullio.
Then I constructed a wrapper to compute the gradient of the two methods
Test:
As you can see, the loopy version is ok. The Tullio's one fails with this scary stacktrace
Thanks a lot
The text was updated successfully, but these errors were encountered: