JuliaDiff / JuliaDiff/ReverseDiff.jl

Add ChainRulesCore RuleConfig?

Open
#238 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
393
Forks
60
Avg merge
18h 24m
Merged PRs (30d)
8

Description

The macro @grad_from_chainrules contains the following line

https://github.com/JuliaDiff/ReverseDiff.jl/blob/6c7b9cfbb06cc1e91d36be12746aaeb55e433ff4/src/macros.jl#L338

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/macros.jl around line 338, where @grad_from_chainrules calls rrule without a RuleConfig. Read the linked ChainRulesCore RuleConfig documentation and inspect the surrounding macro logic before deciding how the proposed MyReverseDiffRuleConfig should be incorporated. Done means the macro supports the requested config for the ImplicitDifferentiation.jl use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.