My model can't be transfered to gpu. Adapt.jl problem?

Thanks!

The issue is that Adapt.jl/base.jl at v3.4.0 · JuliaGPU/Adapt.jl · GitHub doesn’t account for the case where a closure type has more fields than it does type parameters. To my knowledge, this is usually not the case because each captured variable will get a type parameter. However, it will happen if your code runs into Performance Tips · The Julia Language (explained further in https://github.com/JuliaLang/julia/issues/15276). We can demonstrate this quite easily:

julia> function outer(a, c)
           b = 1
           inner(x) = x + a + b + c
           b = 2
           return inner
       end
outer (generic function with 1 method)

julia> clos = outer(1, 3)
(::var"#inner#1"{Int64, Int64}) (generic function with 1 method)

julia> dump(clos)
inner (function of type var"#inner#1"{Int64, Int64})
  a: Int64 1
  c: Int64 3
  b: Core.Box
    contents: Int64 2

You can check this yourself by finding the closure object in your model which corresponds to (I presume) an inner function called coce and dumping it. I think this is also worth an issue on the Adapt.jl side to see if there’s an easy fix.