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

Add ChainRulesCore RuleConfig? #238

Open
gdalle opened this issue Sep 14, 2023 · 1 comment
Open

Add ChainRulesCore RuleConfig? #238

gdalle opened this issue Sep 14, 2023 · 1 comment

Comments

@gdalle
Copy link
Member

gdalle commented Sep 14, 2023

The macro @grad_from_chainrules contains the following line

output_value, back = ChainRulesCore.rrule($f, map(ReverseDiff.value, args)...; $kwargs...)

which shows that the rrule is used with no optional RuleConfig argument. This is proving cumbersome for ImplicitDifferentiation.jl, where the rrule needs to call back into AD and thus dispatch on the AD backend (aka RuleConfig).

Would you be open to a PR defining the following config?

using ChainRulesCore: RuleConfig, HasReverseMode, NoForwardsMode

struct MyReverseDiffRuleConfig <: RuleConfig{Union{HasReverseMode,NoForwardsMode}} end

I would need advice on how to add it to the macro though.

Pinging @mohamed82008

@mohamed82008
Copy link
Member

We would need a method for rrule_via_ad and the ReverseDiffRuleConfig first, similar to https://github.com/FluxML/Zygote.jl/blob/master/src/compiler/chainrules.jl#L248. Then we can change that line you pointed to.

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