-
Notifications
You must be signed in to change notification settings - Fork 62
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
RuleConfigs (include for calling back into AD) #363
Conversation
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.
Excited to see where this goes.
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.
As far as I understand, this is not a breaking change, right? The rules can still be written in the same way (without the config). The AD packages can still call the rules in the same way (without providing the config).
Correct. At least in its current form. but still WIP |
TODO: check that this works with zygote via makign a PR to use a rule via branching from FluxML/Zygote.jl#987 |
Codecov Report
@@ Coverage Diff @@
## master #363 +/- ##
==========================================
- Coverage 89.26% 87.42% -1.85%
==========================================
Files 12 14 +2
Lines 475 485 +10
==========================================
Hits 424 424
- Misses 51 61 +10
Continue to review full report at Codecov.
|
|
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.
My understanding/opinion is that
- traits are defined in ChainRulesCore
- each AD package defines exactly one config (and no traits)
- rule authors do not define configs nor traits
if AD defines traits, then rule authors have to depend on the AD system to write rules for it. Or the AD system has to depend on the package to define a rule for it. Neither options are great.
Rule authors have no business defining configs. They possibly could define traits, but that would need AD would have to depend on that package. Which seems bad.
On the other hand, defining an OnlyOnZygote
trait inside ChainRulesCore seems bad and an implicit reverse dependency. Possibly this means we should not have OnlyOnZygote
-like traits at all. The traits should only be about properties of AD systems. If that means having a BadWithLoops
trait, then we'll take that over OnlyOnZygote
trait.
Basically, yes. (One use case I can speculate for Rule authors defining traits is resolving type-piracy: if DistributionsAD.jl, and DistributionsDiff.jl both provide rules for Distributions.jl, then they could do so by defining a trait that the rule config needs to have)
Yes, we don't have a |
This breaks ChainRulesOverloadGeneration.jl |
Co-authored-by: Miha Zgubic <[email protected]>
Co-authored-by: Miha Zgubic <[email protected]>
Co-authored-by: Miha Zgubic <[email protected]>
Awesome, I had been looking forward to this (have some cases where I currently have to call back into Zygote explicitly). Thanks! |
Closes #68 and I think another one about adding config obects that I can't find
May prove useful for #350 if we make rules use a special feature to say they don't supprt inplact accumulation and then we use this to disable the copying.