EnzymeAD / Enzyme.jl

Julia bindings for the Enzyme automatic differentiator
https://enzyme.mit.edu
MIT License
443 stars 62 forks source link

`active_reg_inner` crashes on `Tuple{X} where {X}` #1923

Open mofeing opened 7 hours ago

mofeing commented 7 hours ago

If you run this code:

Enzyme.Compiler.active_reg_inner(Vector{Tuple{Code}} where {Code<:Integer}, (), nothing)

it fails like this:

UndefVarError: `T` not defined

Stacktrace:
 [1] ptreltype(::Type{Array{Tuple{Code}, 1} where Code<:Integer})
   @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:519
 [2] active_reg_inner
   @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:643 [inlined]
 [3] active_reg_inner (repeats 2 times)
   @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:603 [inlined]
 [4] active_reg_inner(::Type{Array{Tuple{Code}, 1} where Code<:Integer}, seen::Tuple{}, world::Nothing)
   @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:603
 [5] top-level scope
   @ ~/Developer/k-local-gradient-descent/notebooks/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_X53sZmlsZQ
wsmoses commented 6 hours ago
julia> T = (Vector{Tuple{Code}} where {Code<:Integer})
Array{Tuple{Code}, 1} where Code<:Integer

julia> eltype(T)
Any

julia> @inline ptreltype(::Type{Array{T,N}}) where {T,N} = T
ptreltype (generic function with 1 method)

julia> ptreltype(T)
ERROR: UndefVarError: `T` not defined
Stacktrace:
 [1] ptreltype(::Type{Array{Tuple{Code}, 1} where Code<:Integer})
   @ Main ./REPL[6]:1
 [2] top-level scope
   @ REPL[7]:1
wsmoses commented 5 hours ago

seems like a julia issue: https://github.com/JuliaLang/julia/issues/55933