From b29994f9346e4bb1b3c4eb607792ac44e3b89720 Mon Sep 17 00:00:00 2001 From: Tamme Claus Date: Tue, 4 Nov 2025 10:41:07 +0100 Subject: [PATCH 1/4] workaround rmul!( , true/false) --- lib/cublas/linalg.jl | 6 ++++++ test/libraries/cublas/level1.jl | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/cublas/linalg.jl b/lib/cublas/linalg.jl index 949f8621c6..1ada8cfc4b 100644 --- a/lib/cublas/linalg.jl +++ b/lib/cublas/linalg.jl @@ -9,6 +9,12 @@ end # BLAS 1 # +function LinearAlgebra.rmul!(x::CuArray{<:CublasFloat}, k::Bool) + # explicitly fill x with zero to comply with julias "false = strong zero" + !k && fill!(x, zero(eltype(x))) + return x +end + LinearAlgebra.rmul!(x::StridedCuArray{<:CublasFloat}, k::Number) = scal!(length(x), k, x) diff --git a/test/libraries/cublas/level1.jl b/test/libraries/cublas/level1.jl index 4fd7aa1006..d551e2ff8e 100644 --- a/test/libraries/cublas/level1.jl +++ b/test/libraries/cublas/level1.jl @@ -41,6 +41,12 @@ k = 13 @test dz ≈ z end + @testset "rmul! strong zero" begin + @test testf(rmul!, fill(NaN, 3), false) + @test testf(rmul!, rand(3), false) + @test testf(rmul!, rand(3), true) + end + @testset "rotate!" begin @test testf(rotate!, rand(T, m), rand(T, m), rand(real(T)), rand(real(T))) @test testf(rotate!, rand(T, m), rand(T, m), rand(real(T)), rand(T)) From 3af405d5e3a2db12417fdf9cab005f78d0640756 Mon Sep 17 00:00:00 2001 From: Tamme Claus Date: Tue, 4 Nov 2025 10:42:44 +0100 Subject: [PATCH 2/4] fix matmatmul --- lib/cublas/linalg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cublas/linalg.jl b/lib/cublas/linalg.jl index 1ada8cfc4b..1e5d4b8ef2 100644 --- a/lib/cublas/linalg.jl +++ b/lib/cublas/linalg.jl @@ -362,7 +362,7 @@ function LinearAlgebra.generic_matmatmul!(C::StridedCuVecOrMat, tA, tB, A::Strid if size(C) != (mA, nB) throw(DimensionMismatch("C has dimensions $(size(C)), should have ($mA,$nB)")) end - return LinearAlgebra.rmul!(C, 0) + return LinearAlgebra.rmul!(C, beta) end if all(in(('N', 'T', 'C')), (tA, tB)) From ae71976f977f3fa947981f7eb4414791b35f3ffd Mon Sep 17 00:00:00 2001 From: Tamme Claus Date: Tue, 4 Nov 2025 10:50:49 +0100 Subject: [PATCH 3/4] type generic tests --- test/libraries/cublas/level1.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/libraries/cublas/level1.jl b/test/libraries/cublas/level1.jl index d551e2ff8e..2bc8f7b55f 100644 --- a/test/libraries/cublas/level1.jl +++ b/test/libraries/cublas/level1.jl @@ -42,9 +42,9 @@ k = 13 end @testset "rmul! strong zero" begin - @test testf(rmul!, fill(NaN, 3), false) - @test testf(rmul!, rand(3), false) - @test testf(rmul!, rand(3), true) + @test testf(rmul!, fill(T(NaN), 3), false) + @test testf(rmul!, rand(T, 3), false) + @test testf(rmul!, rand(T, 3), true) end @testset "rotate!" begin From 8f8a3da05860324d3144d5665e72045fde78e5b2 Mon Sep 17 00:00:00 2001 From: Tamme Claus Date: Tue, 4 Nov 2025 11:26:24 +0100 Subject: [PATCH 4/4] also matvecmul --- lib/cublas/linalg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cublas/linalg.jl b/lib/cublas/linalg.jl index 1e5d4b8ef2..5e73716c1a 100644 --- a/lib/cublas/linalg.jl +++ b/lib/cublas/linalg.jl @@ -273,7 +273,7 @@ function LinearAlgebra.generic_matvecmul!(Y::StridedCuVector, tA::AbstractChar, end if nA == 0 - return rmul!(Y, 0) + return rmul!(Y, beta) end T = eltype(Y)