-
Notifications
You must be signed in to change notification settings - Fork 63
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
Disable thunks for 2nd order AD #683
Conversation
src/tangent_types/thunks.jl
Outdated
return quote | ||
$(esc(_usethunks))() ? | ||
Thunk($(esc(func))) : | ||
$(esc(func))() | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments on this approach over :(_usethunks() ? Thunk($(esc(func))) : $(esc(body)))
, from #568? My hope there was that including the body directly, instead of making and calling a function, might be slightly simpler for e.g. Zygote to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this.
CI failures look unrelated
# Basically `:(Thunk(() -> $(esc(body))))` but use the location where it is defined. | ||
# so we get useful stack traces if it errors. | ||
func = Expr(:->, Expr(:tuple), Expr(:block, __source__, body)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could go further and generate a name for the thunk, based on source location, instead of anon. () ->
. I think the name will be seen sometimes where the code line info is not?
But not this PR perhaps...
This was not a patch change. This is a new feature. I recommended being careful about this and biasing towards doing minor releases because it makes it possible to do backports in between releases Not a huge deal as we are unlikely to need to put in patches. |
Fair point. Initially this PR added a hook that users could register that would allow to disable thunking and so the original behavior was not changed, hence the patch version. But then I changed the PR to disable thunking for 2nd order AD unconditionally and forgot to change the version bump from patch to minor. |
That would still have been a new feature and would have been a minor. |
Needed for lazy Zygote:
FluxML/Zygote.jl#966
Also bumped patch version so that we can tag a release afterwards.