JuliaDiff / JuliaDiff/Diffractor.jl

TypeError: in new, expected DataType, got Type{ZeroBundle{1, B}}

Open
#199 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug forward-mode
Dominant language
Julia
Stars
453
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Simple example of taking the jacobian of the identity function, but the identity function is a comprehension

julia> import AbstractDifferentiation as AD

julia> function identity_comprehension(x)
           return [x[i] for i in eachindex(x)]
       end
identity_comprehension (generic function with 1 method)

julia> AD.jacobian(Diffractor.DiffractorForwardBackend(), identity_comprehension, rand(2))
ERROR: TypeError: in new, expected DataType, got Type{ZeroBundle{1, B}}
Stacktrace:
  [1] _TangentBundle
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/tangent.jl:148 [inlined]
  [2] TangentBundle
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/tangent.jl:251 [inlined]
  [3] (::Diffractor.∂☆internal{1})(args::Vararg{Diffractor.AbstractTangentBundle{1}})
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:149 [inlined]
  [4] (::Diffractor.∂☆{N})(args::Vararg{Diffractor.AbstractTangentBundle{N}}) where N
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:160 [inlined]
  [5] collect
    @ Diffractor ./array.jl:841 [inlined]
  [6] (::Diffractor.∂☆recurse{…})(::ZeroBundle{…}, ::Diffractor.CompositeBundle{…})
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/recurse_fwd.jl:0
  [7] (::Diffractor.∂☆internal{1})(::ZeroBundle{1, typeof(collect)}, ::Vararg{Diffractor.AbstractTangentBundle{1}})
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:121
  [8] (::Diffractor.∂☆{1})(::ZeroBundle{1, typeof(collect)}, ::Vararg{Diffractor.AbstractTangentBundle{1}})
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:160
  [9] identity_comprehension
    @ Diffractor ./REPL[7]:2 [inlined]
 [10] ∂☆internal
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:121 [inlined]
 [11] (::Diffractor.∂☆{N})(args::Vararg{Diffractor.AbstractTangentBundle{N}}) where N
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:160 [inlined]
 [12] (::Diffractor.var"#pushforward#359"{typeof(identity_comprehension), Tuple{Vector{Float64}}})(vs::Tuple{Vector{Float64}})
    @ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/AbstractDifferentiation.jl:13
 [13] (::Diffractor.var"#358#362")(cols::Any)
    @ Diffractor ~/.julia/packages/AbstractDifferentiation/eEkWP/src/AbstractDifferentiation.jl:526 [inlined]
 [14] mapslices(f::Diffractor.var"#358#362"{Diffractor.var"#pushforward#359"{…}}, A::Matrix{Float64}; dims::Int64)
    @ Base ./abstractarray.jl:3179
 [15] jacobian(b::Diffractor.DiffractorForwardBackend, f::Function, args::Vector{Float64})
    @ Diffractor ~/.julia/packages/AbstractDifferentiation/eEkWP/src/AbstractDifferentiation.jl:524

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the identity_comprehension jacobian example first. Then inspect Diffractor's tangent.jl around lines 148 and 251, followed by the forward and recurse_fwd.jl stack-frame locations, to trace the invalid tangent construction. Done means the example computes a jacobian without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.