-
Notifications
You must be signed in to change notification settings - Fork 69
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
How to use ChainRules rrules with autodiff? #583
Comments
No that is currently not possible. #172 is the issue to follow, but we are not targeting ChainRules support from the get-go, but rather allowing the user to provide rules in an Enzyme compatible fashion. |
Thanks for the hint & the development work! |
I would suggest reopening this, unless there is some big technical blocker. A lot of work has gone into defining a big set of rules into https://github.com/JuliaDiff/ChainRules.jl, it may take some time to EnzymeRules to catch up. Moreover, if we want to encourage a smooth transition to Enzyme of Flux users and generally of the ML ecosystem (see #805), it would be nice to support the custom rules that people have been writing with ChainRules for years. |
I'm not opposed to this, but there are several challenges/limitations.
I'd earlier written ChainRules to EnzymeRules importers for Forward and Reverse Mode in this PR: https://github.com/EnzymeAD/Enzyme.jl/pull/996/files (see Specifically
I'm potentially okay with it being made into an extension package and marked as deprecated / rules have warnings when run. cc @vchuravy for your thoughts. In any case the PR needs a small amount of rebase work before it could be merged, if you'd be interested in helping |
An opt-in approach like the one in #996 would be valuable already. I understand the performance limitations but slow is better than not working at all. Related to this, it seems to me that writing an enzyme rule is way more difficult than writing a chainrules' one, so I would really appreciate the possibility of a quick translation, and probably in many cases typical of DL the performance hit would be negligible. |
@CarloLucibello go for it, reviving the PR would be a welcome contribution. I'm more skeptical of the negligible performance hit because having to copy and cache a bunch of unnecessary memory would scale with the size of the tensors. |
I'm not familiar with Enzyme's internals (honestly I have little familiarity with Enzyme in general yet), I don't think I can help much. Do you want help with testing it? |
With #996 now in we have macros to import both chainrules frules and rrules, am now closing. |
I couldn't find a better title, so let me explain: I have a function interpolated via BSplineKit, based on some lookup table. BSplineKit provides rrules for differentiation of the interpolated function. Now I want to use this function in some code, that I want to differentiate with Enzyme, because Zygote is too slow. Is that already possible? My first lazy attempts resulted in segfaults :(
The text was updated successfully, but these errors were encountered: