JuliaDiff / JuliaDiff/Diffractor.jl
Failure with ComposedFunction `∘`
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 453
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
I'm pretty confident this worked in September, but have no idea whether changes here or in ChainRules broke it: Edit -- the change is https://github.com/JuliaDiff/ChainRulesCore.jl/pull/495, discussed there.
julia> Diffractor.gradient(cbrt, 1.23)
(0.29036348772107673,)
julia> Diffractor.gradient(identity∘cbrt, 1.23)
ERROR: ArgumentError: Tangent for the primal Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}} should be backed by a AbstractDict type, not by NamedTuple{(:data,), Tuple{ChainRulesCore.ZeroTangent}}.
Stacktrace:
[1] _backing_error(P::Type, G::Type, E::Type)
@ ChainRulesCore ~/.julia/packages/ChainRulesCore/qzYOG/src/tangent_types/tangent.jl:62
[2] ChainRulesCore.Tangent{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, NamedTuple{(:data,), Tuple{ChainRulesCore.ZeroTangent}}}(backing::NamedTuple{(:data,), Tuple{ChainRulesCore.ZeroTangent}})
@ ChainRulesCore ~/.julia/packages/ChainRulesCore/qzYOG/src/tangent_types/tangent.jl:33
[3] (::Diffractor.var"#162#164"{Symbol, DataType})(Δ::ChainRulesCore.ZeroTangent)
@ Diffractor ~/.julia/packages/Diffractor/HYuxt/src/stage1/generated.jl:308
[4] (::Diffractor.EvenOddOdd{1, 1, Diffractor.var"#162#164"{Symbol, DataType}, Diffractor.var"#163#165"{Symbol}})(Δ::ChainRulesCore.ZeroTangent)
@ Diffractor ~/.julia/packages/Diffractor/HYuxt/src/stage1/generated.jl:288
[5] ∂⃖¹₁merge
@ ./none:1
[6] ∂⃖¹₁
@ ./none:1
[7] (::Diffractor.ApplyOdd{1, 1})(Δ::Float64)
@ Diffractor ~/.julia/packages/Diffractor/HYuxt/src/stage1/generated.jl:371
[8] ∂⃖¹₁ComposedFunction
@ ./none:1
[9] (::Diffractor.∇{ComposedFunction{typeof(identity), typeof(cbrt)}})(args::Float64)
@ Diffractor ~/.julia/packages/Diffractor/HYuxt/src/interface.jl:122
[10] Diffractor.∇(::Function, ::Float64)
@ Diffractor ~/.julia/packages/Diffractor/HYuxt/src/interface.jl:128
[11] top-level scope
@ REPL[3]:1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the two Diffractor.gradient calls shown in the issue. Start with src/stage1/generated.jl around lines 288-308 and src/interface.jl around lines 122-128, then review the linked ChainRulesCore pull request. Done means gradient(identity∘cbrt, 1.23) completes without the Tangent backing error and preserves the working direct cbrt result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100