Skip to content

Pullback of exponent fails, j not defined in Zygote #1573

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

Open
jClugstor opened this issue May 14, 2025 · 2 comments · May be fixed by JuliaDiff/ChainRules.jl#820
Open

Pullback of exponent fails, j not defined in Zygote #1573

jClugstor opened this issue May 14, 2025 · 2 comments · May be fixed by JuliaDiff/ChainRules.jl#820

Comments

@jClugstor
Copy link

jClugstor commented May 14, 2025

julia> g(p) = exponent(p)
g (generic function with 1 method)

julia> _,back = Zygote._pullback(g, 4.0)
(2, (g))

julia> back(4.0)
ERROR: UndefVarError: `j` not defined in `Zygote`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0 [inlined]
  [2] (::Zygote.Pullback{Tuple{Core.IntrinsicFunction, UInt64, UInt64}, Tuple{Core.IntrinsicFunction}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:100
  [3] <<
    @ ./int.jl:529 [inlined]
  [4] (::Zygote.Pullback{Tuple{typeof(<<), UInt64, UInt64}, Tuple{Zygote.Pullback{Tuple{}, Tuple{}}}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
  [5] >>
    @ ./int.jl:534 [inlined]
  [6] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
  [7] exponent
    @ ./math.jl:950 [inlined]
  [8] (::Zygote.Pullback{Tuple{typeof(exponent), Float64}, Any})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
  [9] g
    @ ./REPL[13]:1 [inlined]
 [10] (::Zygote.Pullback{Tuple{typeof(g), Float64}, Tuple{Zygote.Pullback{Tuple{typeof(exponent), Float64}, Any}}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
 [11] top-level scope
    @ REPL[15]:1
Some type information was truncated. Use `show(err)` to see complete types.
(jl_BfWUbu) pkg> st
Status `/tmp/jl_BfWUbu/Project.toml`
  [e88e6eb3] Zygote v0.7.7
julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 6800U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
@mcabbott
Copy link
Member

Error is from this line

https://github.com/FluxML/Zygote.jl/blob/v0.7.7/src/compiler/interface2.jl#L100

added in #1420

But the solution is probably @non_differentiable exponent(::Any), in this file

@jClugstor
Copy link
Author

Cool thanks: JuliaDiff/ChainRules.jl#820

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

Successfully merging a pull request may close this issue.

2 participants