-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
I have noticed that SVD does not consistently produce correct numerical results with ROCArrays as input. As a result, calculating the condition number of a matrix also fails.
Below is a reproducer. These tests fail more often than not.
using LinearAlgebra
using AMDGPU
cpu = randn(10, 10)
gpu = ROCArray(cpu)
for i in 1:5
cpu_vals = svd(cpu).S
gpu_vals = Vector(svd(gpu).S)
println("Test #$i:")
println("SVD equal? ", cpu_vals ≈ gpu_vals)
println("Cond equal? ", cond(cpu) ≈ cond(gpu))
end
I managed to track it down to the LinearAlgebra.LAPACK.gesdd! function being called under the hood. rocSOLVER only implements the generic gesvd!. If I define the following in my code (or the above test), everything works fine:
function LinearAlgebra.LAPACK.gesdd!(jobz::Char, A::AMDGPU.ROCArray{T}) where {T}
AMDGPU.rocSOLVER.gesvd!(jobz, jobz, A)
end
luraess
Metadata
Metadata
Assignees
Labels
No labels