You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hermitian() wrapper missing a GPU compatible iterator #586
The following reproducer code fails with LoadError: Scalar indexing is disallowed.:
using CUDA
using LinearAlgebra
A = CuArray(ones(Float32, 5, 5))
# This works
any(isnan, Symmetric(A))
# This does not
any(isnan, Hermitian(A))
It seems that some underlying function call tries explicit element access with the Hermitian() wrapper, but not with Symmetric(). I am not 100% sure whether that issue belongs here or in LinearAlgebra.
I get this issue with Julia version 1.10.8 (LTS) and 1.11.3 (current stable).
Seems that the optimized function 'any' cannot resolve Hermitian{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T}.
'any' in mapreduce.jl looks like:
Base.any(f::Function, A::AnyGPUArray) = mapreduce(f, |, A)
But Hermitian or Symmetric is a struct including UP or Down, which cannot go into this optimized function.
If you use the data instead of the whole struct, any will work properly.
using CUDA
using LinearAlgebra
A =CuArray(ones(Float32, 5, 5))
# This works
S =Symmetric(A)
println(any(isnan, S.data))
# This works
H =Hermitian(A)
println(any(isnan, H.data))
B =CuArray(fill(NaN, 5, 5))
# This works
SB =Symmetric(B)
println(any(isnan, SB.data))
# This works
HB =Hermitian(B)
println(any(isnan, HB.data))
Activity
cpmores commentedon Apr 6, 2025
Seems that the optimized function 'any' cannot resolve Hermitian{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T}.
'any' in mapreduce.jl looks like:
Base.any(f::Function, A::AnyGPUArray) = mapreduce(f, |, A)But Hermitian or Symmetric is a struct including UP or Down, which cannot go into this optimized function.
If you use the data instead of the whole struct, any will work properly.
maleadt commentedon Oct 19, 2026
Works on current GPUArrays and CUDA.jl, with correct results for both
uplos: