Destructuring/iterating a `Tangent` does not unthunk fields, unlike `getindex`/`getproperty`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- devtools
Hướng nghiên cứu
Start in src/tangent_types/structural_tangent.jl, comparing the unthunk calls in getindex and getproperty with the Base.iterate and Base.indexed_iterate forwarding. Reproduce the snippet with collect(t) and first(nt) to see the thunks. Done means the maintainers have chosen between unthunking iteration and documenting indexed access, and the chosen option is implemented or documented with tests. The design choice is still open, so confirm it in the thread before writing code.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Field access on a Tangent unthunks the field, but iteration does not:
julia> using ChainRulesCore
julia> t = Tangent{Tuple{Float64,Vector{Float64}}}(1.0, @thunk([2.0]));
julia> t[2] # Vector{Float64}
julia> _, b = t; b # Thunk
julia> collect(t) # [1.0, Thunk]
julia> nt = Tangent{NamedTuple{(:a,),Tuple{Vector{Float64}}}}(a=@thunk([1.0]));
julia> nt.a # Vector{Float64}
julia> (; a) = nt; a # Vector{Float64}
julia> first(nt) # Thunk
getindex/getproperty call unthunk (src/tangent_types/structural_tangent.jl, since #121), whereas Base.iterate and Base.indexed_iterate forward to the backing without unthunking.
This caused a bug in ChainRules (JuliaDiff/ChainRules.jl#843): the findnz pullbacks did _, _, V̄ = unthunk(Δ). With Zygote, Δ is Tangent{Any}((ZeroTangent(), ZeroTangent(), thunk)), so V̄ was still a thunk and sparse(I, J, V̄, m, n) threw a MethodError.
There are two possible resolutions:
- Make
iterate/indexed_iterateunthunk, for consistency withgetindex/getproperty. This has a downside: positional destructuring would then also compute components the rule discards, e.g. the_in_, _, V̄ = Δ. - Keep the current behaviour, but document that rules should access the fields they need via
getindex/getproperty(or property destructuring(; a) = Δ) and not via positional destructuring or iteration.
Option 2 seems preferable for performance, but the current behaviour is a silent footgun either way. ChainRules.jl#843 now uses indexing (unthunk(Δ)[3]).
- Ngôn ngữ chính
- Julia
- Star
- 267
- Fork
- 66
- Merge trung bình
- 1 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaDiff/ChainRulesCore.jl
-
variable scope of `@thunk`Có thể đã có người làm @chengchingwen đã nhận 621 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
JuliaDiff/ChainRulesCore.jl#684 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue Structural Tangent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
JuliaDiff/ChainRulesCore.jl#669 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
JuliaDiff/ChainRulesCore.jl#668 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
breaking
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
JuliaDiff/ChainRulesCore.jl#665 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
JuliaDiff/ChainRulesCore.jl#664 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của JuliaDiff/ChainRulesCore.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JuliaDiff/TaylorSeries.jl#445 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
SciML/PETScDiffEq.jl#362 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Prescribed ice velocities never get their halos filled, so ice is created at a periodic seamĐang mở🕷️ bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CliMA/ClimaSeaIce.jl#203 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
JuliaPhysics/BeamletOptics.jl#221 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
release preparation spack
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày