-
Notifications
You must be signed in to change notification settings - Fork 89
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
Use handwritten rules for zero
and one
#773
Conversation
Appears to have the same failure profile as #774. @oxinabox any thoughts on what we should do? If there's problems in NeuralPDE, there's probably also issues in other parts of the ecosystem. Here's a demo of these methods fixing the problem that NeuralPDE had: SciML/NeuralPDE.jl#792 |
Why is this not: function frule((_, _), ::typeof(zero), x)
return (zero(x), ZeroTangent())
end
function rrule(::typeof(zero), x)
zero_pullback(_) = (NoTangent(), ZeroTangent())
return (zero(x), zero_pullback)
end
# `one`
function frule((_, _), ::typeof(one), x)
return (one(x), ZeroTangent())
end
function rrule(::typeof(one), x)
one_pullback(_) = (NoTangent(), ZeroTangent())
return (one(x), one_pullback)
end This extra stuff with projection and multiplication all should just cancel away for if the tangent is I agree the We should probably add a test for this since it has caused bugs now. Thank you for playing wack-a-mole with this. |
Mostly because I was copy-pasting and then tweaking the output from
can do |
test failures on 1.x are unrelated. |
Attempt to fix the problems raised in SciML/NeuralPDE.jl#791 that was caused by #770
I think this is the right way to generalize the scalar rule to any input type, and always return a
ZeroTangent()
instead of aNoTangent()
like the old@non_differentiable
rule did which was quite mathematically suspect.