Skip to content

ForwardDiff scalar indexing with GPU arrays #820

@ChrisRackauckas

Description

@ChrisRackauckas

First noted in SciML/OrdinaryDiffEq.jl#2567, but it never got addressed. The same downstream test case used with SparseDiffTools highlights this:

using OrdinaryDiffEq, CUDA, LinearAlgebra, Test, StaticArrays, ADTypes
function f(du, u, p, t)
    mul!(du, A, u)
end
CUDA.allowscalar(false)
A = cu(-rand(3, 3))
u0 = cu([1.0; 0.0; 0.0])
tspan = (0.0f0, 100.0f0)

prob = ODEProblem(f, u0, tspan)
sol = solve(prob, Tsit5()) # works
solve(prob, Rosenbrock23(autodiff = AutoForwardDiff()));

It can probably be minimized directly to the DI call, but I can't do that right now as I don't have the hardware on-hand to debug offline.

Error message: DIgpuerror.txt

But as noted in https://discourse.julialang.org/t/combining-sparsedifftools-jl-and-ordinarydiffeq-jl/130555/9, it's simply because DI uses ForwardDiff.jacobian which is not GPU compatible because it scalar indexes the partials, and it needs to adopt the SparseDiffTools style of partial filling if it wants to be able to vectorize that operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendRelated to one or more autodiff backends

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions