-
Notifications
You must be signed in to change notification settings - Fork 33
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
Re-add expansion of Enzyme.@import_{r,f}rule
to BijectorsEnzymeExt
#346
Conversation
f9ee0d5
to
d3eafb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO that's incomprehensible. What's the reason for not just implementing the forward and reverse-mode Enzyme rules? The function and the partial derivatives are very simple, and a direct implementation is likely faster and avoids unnecessary overhead. As also mentioned in the docstrings of @import_rrule
and @import_frule
, these macros most likely do not give you the most performant implementation (and they might lead to broken rules but I assume it's fine in this simple case here).
I agree it is very incomprehensible, but we discussed this previously (on Slack) and none of us really have the time to figure out how to rewrite the rule ourselves. (I definitely don't, I don't know if anyone else's schedule has freed up, though I doubt it.) @wsmoses suggested that we could, in the worst case, run macroexpand, so that's what I've done, and it's only really intended as a stopgap measure until 1.11.2 is released, at which point we can get rid of all of this. |
5729b55
to
3f096f8
Compare
My point is that even when the Pkg issues are fixed, I think ideally you would use neither |
I will pass that on :) |
But maybe @willtebbutt or @mhauru one of you are better placed to do this (at some point in time)? |
Regardless of how we want to implement these rules, Bijectors are only users of the rules defined here. So, it feels more natural for these rules to be hosted as an |
@devmotion, since you wrote the |
Here are the rules for ReverseDiff, which can be adapted for Enzyme: Bijectors.jl/ext/BijectorsReverseDiffExt.jl Lines 246 to 258 in 2ee8a5d
|
ef67dbd
to
e8ef6fe
Compare
Is it sensible to merge this first and keep track of the proper rule-writing in another issue? Right now we have a missing rule and that will make things break. If we'd rather let things sit broken for now, that's fine with me too! Just thought to prod. |
It doesn't matter much since the code is related to normalising flows, which Turing does not use. It is more for users who directly work with Bijectors. I'd strongly encourage that these rules got correctly fixed and moved to an |
Well, one could do that. But that's again too generic for Bijectors IMO. The only interest here is one specific function, so only a rule for this specific function is needed. I assume generally performance of such a specific rule will be better than performance of generic Roots.jl rules. I should have some time this evening, I'll open a draft PR and see how far I can get. |
Since Enzyme now works, but Julia hasn't been fixed, this re-enables the extension. See #339 (comment).
In the process, it aso re-enables tests that are no longer broken.