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

Inference tests do not catch problems with thunked inputs #214

Closed
mzgubic opened this issue Sep 8, 2021 · 0 comments · Fixed by #215
Closed

Inference tests do not catch problems with thunked inputs #214

mzgubic opened this issue Sep 8, 2021 · 0 comments · Fixed by #215
Labels
bug Something isn't working

Comments

@mzgubic
Copy link
Member

mzgubic commented Sep 8, 2021

Consider:

julia> my_id(x) = x
my_id (generic function with 1 method)

julia> function ChainRulesCore.rrule(::typeof(my_id), x)
           my_id_pb(ȳ) = (NoTangent(), ȳ)
           function my_id_pb::AbstractThunk)
               precision = rand() > 0.5 ? Float64 : Float32
               return (NoTangent(), precision(unthunk(ȳ)))
           end
           return x, my_id_pb
       end

julia> test_rrule(my_id, 2.0)
Test Summary:                | Pass  Total
test_rrule: my_id on Float64 |    7      7
Test.DefaultTestSet("test_rrule: my_id on Float64", Any[], 7, false, false)

while really we should be catching that the thunked cotangents result in type unstable pullbacks. This may seem obscure but is quite relevant because of closures being unstable if they call another method of themselves.

@mzgubic mzgubic added the bug Something isn't working label Sep 8, 2021
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

Successfully merging a pull request may close this issue.

1 participant