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

Zygote.gradient returns nothing instead of `NotImplemented #1227

Open
simonmandlik opened this issue May 13, 2022 · 3 comments
Open

Zygote.gradient returns nothing instead of `NotImplemented #1227

simonmandlik opened this issue May 13, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@simonmandlik
Copy link

using ChainRulesCore, Zygote

f(x) = 2x
ChainRulesCore.rrule(::typeof(f), x) = 2x, d -> (NoTangent(), @not_implemented(""), )

Zygote.gradient(f, 1)

The last line returns (nothing, ) from v0.6.38 onwards but used to return ChainRulesCore.NotImplemented in the previous versions.

Is this intended?

@ToucheSir
Copy link
Member

Yes: #1205. As an alternative, you could try using rrule_via_ad(ZygoteRuleConfig(), f, 1). That won't help if a NotImplemented is generated in the process of running AD, but it will short-circuit if it finds a rrule.

If anyone has any ideas on how to refactor the internals such that rrule_via_ad doesn't have to go through an unwrapping/re-wrapping step (i.e. AD uses ChainRules types all the way through), let me know and I'd be happy to discuss + assist in implementation.

@simonmandlik
Copy link
Author

Ok, thanks!

@ToucheSir
Copy link
Member

Re-opening as a tracker for JuliaDiff/ChainRules.jl#521 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants