Accumulation
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 28/100
- Issue 类型
- 重构
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- julia
- 领域
- performance
调研方向
首先复现 issue 中的 Julia 基准测试,并检查 Diffractor 在累积过程中如何处理返回的 thunks。将其行为与 ChainRulesCore.add!! 以及所引用的 Zygote 和 ChainRulesCore pull request 进行比较。当累积方法确定下来,并且基准测试结果表明多余的分配是否已得到解决时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
At present Diffractor may return thunks, but doesn't seem use them (or anything else) to accumulate effciently:
julia> @btime gradient(x -> sum(x), $(rand(100, 100))) |> first |> typeof
min 1.829 μs, mean 1.869 μs (8 allocations, 368 bytes)
ChainRulesCore.InplaceableThunk{ChainRulesCore.Thunk...
julia> @btime gradient(x -> sum(x) + sum(x), $(rand(100, 100))) |> first |> typeof
min 8.917 μs, mean 28.032 μs (22 allocations, 235.03 KiB)
Matrix{Float64} (alias for Array{Float64, 2})
julia> @btime copy($(rand(100, 100)));
min 1.262 μs, mean 4.120 μs (2 allocations, 78.17 KiB)
julia> 235.03 / 78.17
3.00665216835103
Should this change, perhaps to use ChainRulesCore.add!!? In which case it might it be easiest to change now, while there is nothing downstream to break.
Note aside that add!! is slower than expected here, 3 copies not 1:
julia> g1 = gradient(x -> sum(x), (rand(100, 100)))[1]; g2 = deepcopy(g1);
julia> @btime ChainRulesCore.add!!($(g1), $(g2));
min 4.719 μs, mean 21.300 μs (8 allocations, 234.55 KiB)
julia> 234.55 / 78.17
3.0005117052577717
julia> @btime ChainRulesCore.add!!($(randn(100, 100)), $(g2));
min 3.318 μs, mean 3.438 μs (0 allocations)
Or do we count on ImmutableArray and compiler improvements?
Xref https://github.com/FluxML/Zygote.jl/pull/981 which retrofits Zygote to accumulate in-place.
Xref also https://github.com/JuliaDiff/ChainRulesCore.jl/pull/539 which alters + on two thunks to be more efficient.
- 主要语言
- Julia
- 星标
- 453
- 派生
- 33
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaDiff/Diffractor.jl 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 25/100
JuliaDiff/Diffractor.jl#302 · 2 条评论 ·
-
难度 3/5 1-2 天 新手友好度 52/100
JuliaDiff/Diffractor.jl#294 ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
JuliaDiff/Diffractor.jl#293 ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
JuliaDiff/Diffractor.jl#290 · 8 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
JuliaDiff/Diffractor.jl#280 · 1 条评论 ·
查看 JuliaDiff/Diffractor.jl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
JuliaGPU/KernelAbstractions.jl#897 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
oscar-system/GAP.jl#1455 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
JuliaAI/MLJTransforms.jl#85 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
SciML/OrdinaryDiffEq.jl#4875 ·
维护者通常 4 天内回复