SciML / ExponentialUtilities.jl

Fast and differentiable implementations of matrix exponentials, Krylov exponential matrix-vector multiplications ("expmv"), KIOPS, ExpoKit functions, and more. All your exponential needs in SciML form.

Home Page:https://docs.sciml.ai/ExponentialUtilities/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: exponential! and exp_generic perform scalar indexing on gpu

arthur-bizzi opened this issue · comments

commented

Hey.

This happened as I tried to use the package for GPU-based matrix exponentiation (Base.exp can't do it). In constrast, expv works well. Though my julia-fu is not quite there yet, I would be happy to try and get this working if given some directions.

using CUDA, Flux, ExponentialUtilities

CUDA.allowscalar(false)

M = rand(Float32,10,10) |> gpu
v = rand(10) |> gpu 


ExponentialUtilities.exponential!(M) #ERROR: Scalar indexing is disallowed.
ExponentialUtilities.exp_generic(M) #ERROR: Scalar indexing is disallowed.
ExponentialUtilities.expv(1f0,M,v) #Works

The error message:

Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] assertscalar(op::String)
    @ GPUArraysCore C:\Users\55619\.julia\packages\GPUArraysCore\uOYfN\src\GPUArraysCore.jl:103
  [3] getindex
    @ C:\Users\55619\.julia\packages\GPUArrays\t0LfC\src\host\indexing.jl:9 [inlined]
  [4] iterate
    @ .\abstractarray.jl:1220 [inlined]
  [5] iterate
    @ .\abstractarray.jl:1218 [inlined]
  [6] chkfinite(A::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer})
    @ LinearAlgebra.LAPACK C:\Users\55619\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\LinearAlgebra\src\lapack.jl:84
  [7] gebal_noalloc!(job::Char, A::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, scale::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer})
    @ ExponentialUtilities C:\Users\55619\.julia\packages\ExponentialUtilities\x24Py\src\exp_noalloc.jl:56
  [8] exponential!(A::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, method::ExpMethodHigham2005, _cache::Tuple{Vector{CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}})
    @ ExponentialUtilities C:\Users\55619\.julia\packages\ExponentialUtilities\x24Py\src\exp_noalloc.jl:88
  [9] exponential!
    @ C:\Users\55619\.julia\packages\ExponentialUtilities\x24Py\src\exp_noalloc.jl:81 [inlined]
 [10] exponential!(A::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer})
    @ ExponentialUtilities C:\Users\55619\.julia\packages\ExponentialUtilities\x24Py\src\exp.jl:15
 [11] top-level scope
    @ Untitled-2:10