Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StructArray column access fails on GPU #1521

Open
jariji opened this issue Sep 3, 2024 · 0 comments
Open

StructArray column access fails on GPU #1521

jariji opened this issue Sep 3, 2024 · 0 comments

Comments

@jariji
Copy link

jariji commented Sep 3, 2024

If I use the a vector directly it works but if I reference it via the StructArray with D.a it fails.

using StructArrays, AMDGPU, Zygote
let x = 1,
    D = StructArray(a=ROCArray(rand(10))),
    a = D.a
    Zygote.gradient(x) do x
        sum(x .* a) # OK
        sum(x.* D.a) # FAIL
    end
end


Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] errorscalar(op::String)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:155
  [3] _assertscalar(op::String, behavior::GPUArraysCore.ScalarIndexing)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:128
  [4] assertscalar(op::String)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:116
  [5] getindex
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/indexing.jl:50 [inlined]
  [6] macro expansion
    @ ./none:0 [inlined]
  [7] get_ith
    @ ./none:0 [inlined]
  [8] _getindex
    @ ~/.julia/packages/StructArrays/CjQ4L/src/structarray.jl:348 [inlined]
  [9] getindex
    @ ~/.julia/packages/StructArrays/CjQ4L/src/structarray.jl:343 [inlined]
 [10] iterate
    @ ./abstractarray.jl:1217 [inlined]
 [11] iterate
    @ ./abstractarray.jl:1215 [inlined]
 [12] iterate
    @ ./generator.jl:44 [inlined]
 [13] _collect(c::StructVector{…}, itr::Base.Generator{…}, ::Base.EltypeUnknown, isz::Base.HasShape{…})
    @ Base ./array.jl:854
 [14] collect_similar
    @ ./array.jl:763 [inlined]
 [15] map
    @ ./abstractarray.jl:3285 [inlined]
 [16] ProjectTo
    @ ~/.julia/packages/ChainRulesCore/I1EbV/src/projection.jl:210 [inlined]
 [17] _project
    @ ~/.julia/packages/Zygote/nsBv0/src/compiler/chainrules.jl:189 [inlined]
 [18] back
    @ ~/.julia/packages/Zygote/nsBv0/src/lib/lib.jl:234 [inlined]
 [19] #2180#back
    @ ~/.julia/packages/ZygoteRules/M4xmc/src/adjoint.jl:72 [inlined]
 [20] components
    @ ~/.julia/packages/StructArrays/CjQ4L/src/structarray.jl:318 [inlined]
 [21] component
    @ ~/.julia/packages/StructArrays/CjQ4L/src/structarray.jl:320 [inlined]
 [22] getproperty
    @ ~/.julia/packages/StructArrays/CjQ4L/src/structarray.jl:322 [inlined]
 [23] #130
    @ ~/src/src/tmp.jl:183 [inlined]
 [24] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface2.jl:0
 [25] (::Zygote.var"#75#76"{Zygote.Pullback{Tuple{}, Tuple{}}})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface.jl:91
 [26] gradient(::Function, ::Int64, ::Vararg{Int64})
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface.jl:148
 [27] top-level scope
  [21141c5a] AMDGPU v1.0.1
  [09ab397b] StructArrays v0.6.18
  [e88e6eb3] Zygote v0.6.70
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × AMD Ryzen 9 3900XT 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver2)
Threads: 24 default, 0 interactive, 12 GC (on 24 virtual cores)
Environment:
  LD_LIBRARY_PATH = :/lib:/nix/store/sy1k5jj33a8frbmf3sx1hd1ksx0schqx-clr-6.0.2/lib:/nix/store/7d8yhjypiybk9j3lqa2wk1chdpn8346m-rocm-runtime-6.0.2/lib:/nix/store/yx40lzzcww59nppw2xwakwlnq23sh7av-rocblas-6.0.2/lib:/nix/store/raj03q8wil10103d050d0ngx4k0qfjyc-mesa-24.0.7-drivers/lib
  JULIA_NUM_THREADS = 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant