# Forcing CUArray for tType and IType in ODESolution

**URL:** <https://discourse.julialang.org/t/forcing-cuarray-for-ttype-and-itype-in-odesolution/67531>\
**Category:** Numerics\
**Tags:** diffeq, cuda, zygote\
**Created:** [September 1, 2021, 8:35pm UTC](https://discourse.julialang.org/t/forcing-cuarray-for-ttype-and-itype-in-odesolution/67531 "2021-09-01T20:35:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivak](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@shivak](https://discourse.julialang.org/u/shivak)\
**Post date:** [September 1, 2021, 8:35pm UTC](https://discourse.julialang.org/t/forcing-cuarray-for-ttype-and-itype-in-odesolution/67531/1 "2021-09-01T20:35:00Z")

</div>

I’m trying to use OrdinaryDiffEq, Zygote, and CUDA to reverse-mode differentiate an ODE running on GPU. My code works on CPU, but hits this error on GPU:

`GPU compilation of kernel broadcast_kernel(CUDA.CuKernelContext, CuDeviceVector{Float32, 1}, Base.Broadcast.Broadcasted{Nothing, Tuple{Base.OneTo{Int64}}, typeof(identity), Tuple{Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}}}}, Int64) failed KernelError: passing and using non-bitstype argument Argument 4 to your kernel function is of type Base.Broadcast.Broadcasted{Nothing, Tuple{Base.OneTo{Int64}}, typeof(identity), Tuple{Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}}}}, which is not isbits: .args is of type Tuple{Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}}} which is not isbits. .1 is of type Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}} which is not isbits. .x is of type Vector{Float32} which is not isbits.`

The problem seems to be that the `tType` and `IType` in `ODESolution` are CPU Arrays rather than CUDA ones. This is `typeof(solve(..))` - note the presence of `Vector{Float32}`:

`ODESolution{Float32, 2, Vector{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, Nothing, Nothing, Vector{Float32}, Nothing, ODEProblem{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, Tuple{Float32, Float32}, true, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, ODEFunction{true, typeof(ċȧ_primal!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Symbol, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, Tuple{Symbol}, NamedTuple{(:saveat,), Tuple{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}}, SciMLBase.StandardODEProblem}, Tsit5, SciMLBase.SensitivityInterpolation{Vector{Float32}, Vector{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}, DiffEqBase.DEStats}`

How do I make those CUDA arrays? All the arrays passed to `ODEProblem` have been converted with `gpu`. I don’t need the interpolation `sol.u(t)`, and I’m using `BacksolveAdjoint` to differentiate.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 1, 2021, 10:47pm UTC](https://discourse.julialang.org/t/forcing-cuarray-for-ttype-and-itype-in-odesolution/67531/2 "2021-09-01T22:47:20Z")

</div>

Share the code.

---

<div class="post-metadata">

**Author:** ![shivak](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@shivak](https://discourse.julialang.org/u/shivak)\
**Post date:** [September 1, 2021, 11:35pm UTC](https://discourse.julialang.org/t/forcing-cuarray-for-ttype-and-itype-in-odesolution/67531/3 "2021-09-01T23:35:26Z")

</div>

Will do - mind if we discuss the specific ODE offline first?
