Skip to content

document ReverseDiff.jl integration's need to opt-in #548

Open
@mzgubic

Description

@mzgubic

From Slack:

[Fredrik Bagge Carlson](https://app.slack.com/team/UJ7DVTVQ8) [Today at 3:48 PM](https://julialang.slack.com/archives/C6G240ENA/p1646063331166529)
I'm looking at
https://juliadiff.org/ChainRulesCore.jl/stable/index.html#ChainRules-roll-out-status
and it seems like ReverseDiff.jl is supposed to work with ChainRules, but i can't seem to figure out how, my rules are never called


4 replies

[Seth Axen](https://app.slack.com/team/UHDQQ4GN6):axe:  [7 minutes ago](https://julialang.slack.com/archives/C6G240ENA/p1646063442894469?thread_ts=1646063331.166529&cid=C6G240ENA)
By default ReverseDiff opts out of all rules for now. Use https://github.com/JuliaDiff/ReverseDiff.jl/blob/df0067465ca436b05377054ac7a184da691db1a3/src/macros.jl#L298-L315 to opt-in on a per-rule basis.

[Fredrik Bagge Carlson](https://app.slack.com/team/UJ7DVTVQ8)  [6 minutes ago](https://julialang.slack.com/archives/C6G240ENA/p1646063506399249?thread_ts=1646063331.166529&cid=C6G240ENA)
ok thanks for answering :slightly_smiling_face: Perhaps that should be made clear in the docs for chain rules? I couldn't find anything in the docs for RD either

[Seth Axen](https://app.slack.com/team/UHDQQ4GN6):axe:  [5 minutes ago](https://julialang.slack.com/archives/C6G240ENA/p1646063571928219?thread_ts=1646063331.166529&cid=C6G240ENA)
Yeah, the CR docs could be made more specific there. RD should document it. Not certain if this is considered an API macro.

[Fredrik Bagge Carlson](https://app.slack.com/team/UJ7DVTVQ8)  [2 minutes ago](https://julialang.slack.com/archives/C6G240ENA/p1646063717720879?thread_ts=1646063331.166529&cid=C6G240ENA)
It looks like the macro has some scoping issue
julia> ControlSystems
ControlSystems

julia> ReverseDiff.@grad_from_chainrules RobustAndOptimalControl.hinfnorm2(T::ControlSystems.StateSpace{Continuous, ReverseDiff.TrackedReal})
ERROR: UndefVarError: ControlSystems not defined
Stacktrace:
 [1] top-level scope
   @ ~/.julia/packages/ReverseDiff/Y5qec/src/macros.jl:324

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions