JuliaDiff / ChainRulesTestUtils.jl

Utilities for testing custom AD primitives.
MIT License
50 stars 15 forks source link

Appropriate location for Zygote rrule_via_ad example #211

Open willtebbutt opened 3 years ago

willtebbutt commented 3 years ago

Maybe it would make sense to provide a working example of testing Zygote using CRTU? Just working through an example, and having to dig around in Zygote internals. Should Zygote be providing this?

willtebbutt commented 3 years ago

Oh, wait, Zygote already has an example of this implemented here. I got the impression from the docs that we'd have to implement it ourselves. Would be good to highlight that this should just work, even if this is a bit of a circular dependency.

mzgubic commented 3 years ago

There's this sentence in the docs: "For some AD systems (e.g. Zygote) rrule_via_ad already exists"

But indeed we might do well do have a "rollout status" for where this is implemented and where it is not.

willtebbutt commented 3 years ago

Ahh I see. My bad for not reading the docs more thoroughly. Would a working example that users can copy + paste involving Zygote make sense to add? Something like

config = Zygote.ZygoteConfig()
f(x, y) = x * y + 3x + 2y
test_rrule(config, f, 2.3, 6.1; rrule_f=rrule_via_ad)

just so that it's really explicit. For example, I don't believe (again, I could just be missing some docs) that it's obvious that Zygote.ZygoteConfig() is the thing that users need if using Zygote.

CarloLucibello commented 3 years ago

yes please, this is really needed.

PS: ZygoteConfig -> ZygoteRuleConfig in the example

oxinabox commented 3 years ago

Give this it's own page in the docs?

How to Test an AD system using this. And put a subheading Zygote