Skip to content

Only convert alpha/beta when the element type is an MKL type. - #608

Merged
maleadt merged 1 commit into
mainfrom
tb/matmul-mixed-eltype
Aug 9, 2026
Merged

Only convert alpha/beta when the element type is an MKL type.#608
maleadt merged 1 commit into
mainfrom
tb/matmul-mixed-eltype

Conversation

@maleadt

@maleadt maleadt commented Aug 9, 2026

Copy link
Copy Markdown
Member

* 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.

`*` 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) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/lib/mkl/linalg.jl b/lib/mkl/linalg.jl
index 0a9b38e..081ab4e 100644
--- a/lib/mkl/linalg.jl
+++ b/lib/mkl/linalg.jl
@@ -160,7 +160,7 @@ function LinearAlgebra.generic_matmatmul!(
     T = eltype(C)
 
     if T <: Union{onemklFloat, onemklComplex, onemklHalf} &&
-            alpha isa Union{Bool,T} && beta isa Union{Bool,T}
+            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 (

@maleadt
maleadt merged commit 18703ed into main Aug 9, 2026
4 of 5 checks passed
@maleadt
maleadt deleted the tb/matmul-mixed-eltype branch August 9, 2026 14:53
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.33%. Comparing base (1de937a) to head (c9767d6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #608   +/-   ##
=======================================
  Coverage   80.33%   80.33%           
=======================================
  Files          50       50           
  Lines        3488     3488           
=======================================
  Hits         2802     2802           
  Misses        686      686           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant