SciML / SciML/ComponentArrays.jl

`lmul!` fails with Component Array on GPU

Open
#232 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
375
Forks
42
Avg merge
7h 25m
Merged PRs (30d)
17

Description

julia> lmul!(false, ComponentArray((; x=CUDA.ones(2))))
ERROR: Scalar indexing is disallowed.                                                                                                                    
Invocation of getindex resulted in scalar indexing of a GPU array.                                                                                       
This is typically caused by calling an iterating implementation of a method.          
Such implementations *do not* execute on the GPU, but very slowly on the CPU,
and therefore are only permitted from the REPL for prototyping purposes.                                                                                 
If you did intend to index this array, annotate the caller with @allowscalar.
Stacktrace:                                                                                                                                              
 [1] error(s::String)  
   @ Base ./error.jl:35                                                     
 [2] assertscalar(op::String)                                                                                                                            
   @ GPUArraysCore ~/.julia/packages/GPUArraysCore/uOYfN/src/GPUArraysCore.jl:103                                                                        
 [3] getindex                                                                                                                                            
   @ LinearAlgebra ~/.julia/packages/GPUArrays/dAUOE/src/host/indexing.jl:48 [inlined]
 [4] getindex                                                                                                                                            
   @ LinearAlgebra ~/.julia/dev/ComponentArrays/src/array_interface.jl:94 [inlined]
 [5] macro expansion                                                                                                                                     
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:221 [inlined]
 [6] macro expansion
   @ LinearAlgebra ./simdloop.jl:77 [inlined]
 [7] lmul!(s::Bool, X::ComponentVector{Float32, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, Tuple{Axis{(x = 1:2,)}}})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:220
 [8] top-level scope
   @ REPL[16]:1
 [9] top-level scope
   @ ~/.julia/packages/CUDA/nbRJk/src/initialization.jl:205

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failing lmul!(false, ComponentArray((; x=CUDA.ones(2)))) call, then inspect src/array_interface.jl at the getindex entry shown in the stack trace and LinearAlgebra's generic lmul! implementation. Done means this GPU-backed ComponentArray operation completes without triggering scalar indexing.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.