Skip to content

reverse(::JLArray) errors with GPUArrays 12.1.1 and JLArrays 0.4.2 (JLArrays release missing) #817

Open

Description

@devmotion

Since GPUArrays 12.1.1, reverse of a JLArray vector throws with the latest registered JLArrays (0.4.2):

julia> using JLArrays  # JLArrays v0.4.2, GPUArrays v12.1.1, AcceleratedKernels v0.5.6, KernelAbstractions v0.9.45

julia> reverse(JLArray(Float32[1, 2, 3, 4, 5]))
ERROR: This kernel is unavailable for backend CPU

julia> reverse(JLArray(Float32[1, 2, 3, 4, 5]), 2, 4)
ERROR: This kernel is unavailable for backend CPU

Both calls work with GPUArrays 12.1.0. They also work with GPUArrays 12.1.1 if JLArrays is installed from main:

pkg> add GPUArrays@12.1.1
pkg> add https://github.com/JuliaGPU/GPUArrays.jl:lib/JLArrays

I tested this with Julia 1.10.12, 1.11 and 1.13 (macOS aarch64). It also happens on Ubuntu x64 and x86 in CI.

Cause

#815 changed reverse(v::AnyGPUVector, start, stop) to call AK.reverse (or to reverse into a new array with AK.reverse!). AcceleratedKernels' kernels are not available on the JLArrays back-end. The same PR added a ranged Base.reverse(v::AnyJLVector, start, stop) method to lib/JLArrays/src/sorting.jl to avoid that path, but no JLArrays version with that method has been released. lib/JLArrays/Project.toml on main still says 0.4.2, and the registered 0.4.2 does not include the method. In 0.4.2, reverse(v::AnyJLVector) calls invoke(reverse, Tuple{AbstractVector}, v), which goes on to the ranged method from GPUArrays and so reaches AK.reverse.

Suggested fix

Release JLArrays 0.4.3 with the version bump. It may also be worth checking that GPUArrays releases that rely on new JLArrays methods are only released together with a matching JLArrays release.

Impact

ChainRules.jl's mock-GPU tests fail on every CI job: JuliaDiff/ChainRules.jl#848. We are working around it in JuliaDiff/ChainRules.jl#849.

Metadata

Metadata

Assignees

No one assigned

    Labels

    installationToolkit and driver discovery, artifacts, platform support.regressionSomething that used to work, doesn't anymore.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions