variable scope of `@thunk`
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 32/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- julia
调研方向
首先检查 @thunk 宏、_usethunks() 路径和 issue #683,以了解 second-order AD 的预期行为。复现 caller-scope 和 Core.Box 类型不稳定性问题,然后在 NeuralAttentionlib.jl 中验证相关的 rrule 类型稳定性检查,同时确保两个分支中的 thunk 行为正确。
由索引模型根据 Issue 内容生成。
描述
#683 introduces a separate path when creating the thunk (_usethunks() ? Thunk($(esc(func))) : $(esc(body))). However, this would introduce new variables into the caller's scope and create Core.Box thus causing type instability, which breaks some rrule type stability checks in NeuralAttentionlib.jl.
Currently, I have two ways to solve this:
- replace
$(esc(body))with$(esc(func))()which turns the else path into a function call, thus no variable introduction. - mimic how
@asyncand@spawnusing$to interpolate values. so@thunkwould be defined as:
macro thunk(body)
letargs = Base._lift_one_interp!(body)
func = Base.replace_linenums!(:(()->($(esc(body)))), __source__)
return quote
if _usethunks()
let $(letargs...)
Thunk($func)
end
else
let $(letargs...)
$(esc(body))
end
end
end
end
However, I don't understand #683 enough to see what would be better for 2nd order AD. Maybe @pxl-th or @mcabbott would have some thoughts on this.
- 主要语言
- Julia
- 星标
- 267
- 派生
- 66
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 9
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaDiff/ChainRulesCore.jl 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 28/100
JuliaDiff/ChainRulesCore.jl#712 ·
维护者通常 1 天内回复
-
good first issue Structural Tangent
难度 2/5 1-3 小时 新手友好度 55/100
JuliaDiff/ChainRulesCore.jl#669 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
JuliaDiff/ChainRulesCore.jl#668 · 6 条评论 ·
维护者通常 1 天内回复
-
breaking
难度 3/5 1-2 天 新手友好度 35/100
JuliaDiff/ChainRulesCore.jl#665 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
JuliaDiff/ChainRulesCore.jl#664 · 2 条评论 ·
维护者通常 1 天内回复
查看 JuliaDiff/ChainRulesCore.jl 的全部 Issue
相似的 Issue
-
backport 1.14 GC
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
JuliaDiff/TaylorSeries.jl#445 ·
-
难度 2/5 1-3 小时 新手友好度 83/100
SciML/Optimization.jl#1448 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
SciML/PETScDiffEq.jl#362 ·
维护者通常 1 天内回复
-
dependencies
难度 2/5 1-3 小时 新手友好度 65/100
Open-MBEE/OpenSysML#1951 · 3 条评论 · 1 个 reaction ·
维护者通常 1 天内回复