From c9767d6de73c4040cc0973c53512eb08f9f38c18 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Sun, 9 Aug 2026 15:07:17 +0200 Subject: [PATCH] Only convert alpha/beta when the element type is an MKL type. `*` calls `generic_matmatmul!` with `alpha::Bool`, so the `Bool` arm of `alpha isa Union{Bool,T}` admits any element type, and `T(alpha)` then errors for types that aren't constructible from a `Bool` (`MethodError: no method matching SVector{2,Float32}(::Bool)`) before we ever reach the `GPUArrays.generic_matmatmul!` fallback at the bottom. Only the BLAS branches consume the converted values, and both already require an MKL element type, so hoisting that requirement into the guard doesn't change which operations take the MKL path. Exposed by the new `linalg/mul!/mixed-eltype` testsuite entry from JuliaGPU/GPUArrays.jl#758. Co-Authored-By: Claude Opus 5 (1M context) --- lib/mkl/linalg.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mkl/linalg.jl b/lib/mkl/linalg.jl index a5ea4429..0a9b38ed 100644 --- a/lib/mkl/linalg.jl +++ b/lib/mkl/linalg.jl @@ -159,7 +159,8 @@ function LinearAlgebra.generic_matmatmul!( T = eltype(C) - if alpha isa Union{Bool,T} && beta isa Union{Bool,T} + if T <: Union{onemklFloat, onemklComplex, onemklHalf} && + alpha isa Union{Bool,T} && beta isa Union{Bool,T} # TODO: should the gemm part above be included in this branch? α, β = T(alpha), T(beta) if (