Skip to content

Commit

Permalink
Don't create nested thunks when accumulating (#1555)
Browse files Browse the repository at this point in the history
* Don't create nested thunks when accumulating

Otherwise, it's too easy to create massive types that freeze compilation and blow the stack.

* bump version
  • Loading branch information
ToucheSir authored Jan 31, 2025
1 parent 572eb2a commit 12cd77d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Zygote"
uuid = "e88e6eb3-aa80-5325-afca-941959d7151f"
version = "0.7.3"
version = "0.7.4"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
6 changes: 3 additions & 3 deletions src/lib/lib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ accum(x::ChainRulesCore.Tangent, y::NamedTuple) = accum(wrap_chainrules_output(x
accum(x::Nothing, y::AbstractThunk) = y
accum(x::AbstractThunk, y::Nothing) = x

accum(x, y::AbstractThunk) = @thunk(accum(x, unthunk(y)))
accum(x::AbstractThunk, y) = @thunk(accum(unthunk(x), y))
accum(x::AbstractThunk, y::AbstractThunk) = @thunk(accum(unthunk(x), unthunk(y)))
accum(x, y::AbstractThunk) = accum(x, unthunk(y))
accum(x::AbstractThunk, y) = accum(unthunk(x), y)
accum(x::AbstractThunk, y::AbstractThunk) = accum(unthunk(x), unthunk(y))

# Core functions
@_adjoint_keepthunks deepcopy(x) = deepcopy(x), ȳ -> (ȳ,)
Expand Down

2 comments on commit 12cd77d

@ToucheSir
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/124066

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.4 -m "<description of version>" 12cd77d82546674e4951b900e6c8076d94e397b4
git push origin v0.7.4

Please sign in to comment.