Only convert alpha/beta when the element type is an MKL type. - #608
Merged
Conversation
`*` 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>
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. 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 ( |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
*callsgeneric_matmatmul!withalpha::Bool, so theBoolarm ofalpha isa Union{Bool,T}admits any element type, andT(alpha)then errors for types that aren't constructible from aBool(MethodError: no method matching SVector{2,Float32}(::Bool)) before we ever reach theGPUArrays.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-eltypetestsuite entry from JuliaGPU/GPUArrays.jl#758.