JuliaGPU / JuliaGPU/GPUArrays.jl
Regression mapping over over GPU array and unit range
- Dominant language
- Julia
- Stars
- 450
- Forks
- 104
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 10
Description
On GPUArrays `v10.3.1`, `map((x,y)->x+y, CUDA.zeros(2), 1:2)` used to work without causing a scalar indexing issue. However, with the change in `v11.1.0`, it now throws the following error:
```
julia> map((x,y)->x+y, CUDA.zeros(2), 1: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 should be avoided.
If you want to allow scalar iteration, use `allowscalar` or `@allowscalar`
to enable scalar iteration globally or for the operations in question.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] errorscalar(op::String)
@ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:151
[3] _assertscalar(op::String, behavior::GPUArraysCore.ScalarIndexing)
@ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:124
[4] assertscalar(op::String)
@ GPUArraysCore ~/.julia/packages/GPUArraysCore/aNaXo/src/GPUArraysCore.jl:112
[5] getindex
@ ~/.julia/packages/GPUArrays/sBzM5/src/host/indexing.jl:50 [inlined]
[6] iterate
@ ./abstractarray.jl:1209 [inlined]
[7] iterate
@ ./abstractarray.jl:1207 [inlined]
[8] _zip_iterate_some
@ ./iterators.jl:444 [inlined]
[9] _zip_iterate_all
@ ./iterators.jl:436 [inlined]
[10] iterate
@ ./iterators.jl:426 [inlined]
[11] iterate
@ ./generator.jl:45 [inlined]
[12] collect(itr::Base.Generator{Base.Iterators.Zip{Tuple{CuArray{Float32, 1, CUDA.DeviceMemory}, UnitRange{Int64}}}, Base.var"#4#5"{var"#3#4"}})
@ Base ./array.jl:791
[13] map(f::Function, it::CuArray{Float32, 1, CUDA.DeviceMemory}, iters::UnitRange{Int64})
@ Base ./abstractarray.jl:3495
[14] top-level scope
@ REPL[3]:1
```
I wonder if this was an intended change. `CUDA.zeros(2) .+ (1:2)` still seems to work on CUDA `v5.6` without causing a scalar indexing issue.
cc: @frapac, @amontoison
https://github.com/MadNLP/MadNLP.jl/pull/395
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the map((x,y)->x+y, CUDA.zeros(2), 1:2) reproducer and inspect the GPUArrays host/indexing.jl stack frame alongside Base's abstractarray map implementation. Compare behavior between GPUArrays v10.3.1 and v11.1.0, and check the CUDA broadcast example. Done means the intended behavior is established and the regression is either resolved or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100