Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zygote fails to differentiate through Flux.params on julia v0.11 #2497

Closed
CarloLucibello opened this issue Oct 11, 2024 · 2 comments
Closed

Comments

@CarloLucibello
Copy link
Member

CarloLucibello commented Oct 11, 2024

With Zygote v0.6.71 on julia v0.11 I get the following error:

julia> m = Chain(Dense(3 => 3), sum);

julia> gradient(m -> sum(Flux.params(m)[1]), m)
ERROR: Can't differentiate foreigncall expression $(Expr(:foreigncall, :(:jl_idset_put_idx), Any, svec(Any, Any, Int64), 0, :(:ccall), %83, %84, %85, %82)).
You might want to check the Zygote limitations documentation.
https://fluxml.ai/Zygote.jl/latest/limitations

Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] push!
    @ ./idset.jl:62 [inlined]
  [3] (::Zygote.Pullback{Tuple{typeof(push!), IdSet{Any}, typeof(sum)}, Any})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
  [4] params!
    @ ~/.julia/dev/Flux/src/functor.jl:85 [inlined]
  [5] (::Zygote.Pullback{Tuple{typeof(Flux.params!), Params{Zygote.Buffer{}}, typeof(sum), IdSet{Any}}, Any})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
  [6] params!
    @ ~/.julia/dev/Flux/src/functor.jl:87 [inlined]
  [7] (::Zygote.Pullback{Tuple{typeof(Flux.params!), Params{…}, Tuple{…}, IdSet{…}}, Any})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
  [8] params!
    @ ~/.julia/dev/Flux/src/functor.jl:87 [inlined]
  [9] (::Zygote.Pullback{Tuple{typeof(Flux.params!), Params{Zygote.Buffer{}}, Chain{Tuple{}}, IdSet{Any}}, Any})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
 [10] params!
    @ ~/.julia/dev/Flux/src/functor.jl:87 [inlined]
 [11] (::Zygote.Pullback{Tuple{typeof(Flux.params!), Params{Zygote.Buffer{}}, Tuple{Chain{}}, IdSet{Any}}, Any})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
 [12] params!
    @ ~/.julia/dev/Flux/src/functor.jl:79 [inlined]
 [13] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
 [14] params
    @ ~/.julia/dev/Flux/src/functor.jl:127 [inlined]
 [15] (::Zygote.Pullback{Tuple{typeof(Flux.params), Chain{…}}, Tuple{Zygote.Pullback{…}, Zygote.Pullback{…}}})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
 [16] #25
    @ ./REPL[19]:1 [inlined]
 [17] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Float32)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface2.jl:0
 [18] (::Zygote.var"#78#79"{Zygote.Pullback{Tuple{}, Tuple{}}})(Δ::Float32)
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface.jl:91
 [19] gradient(f::Function, args::Chain{Tuple{Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}, typeof(sum)}})
    @ Zygote ~/.julia/packages/Zygote/Tt5Gx/src/compiler/interface.jl:148
 [20] top-level scope
    @ REPL[19]:1
Some type information was truncated. Use `show(err)` to see complete types.

Found in #2492

@ToucheSir
Copy link
Member

That should be fixed by FluxML/Zygote.jl#1494.

@CarloLucibello
Copy link
Member Author

now fixed in Zygote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants