Skip to content

Use GPUArrays' BLAS hooks for LinearAlgebra's products, triangular operations and BLAS 1 functions - #779

Open
kshyatt wants to merge 5 commits into
mainfrom
ksh/blas-hooks
Open

kshyatt wants to merge 5 commits into
mainfrom
ksh/blas-hooks

Conversation

@kshyatt

@kshyatt kshyatt commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Implements GPUArrays' BLAS hooks (JuliaGPU/GPUArrays.jl#852) with oneMKL, and removes the LinearAlgebra methods that duplicated GPUArrays' dispatch: matrix and matrix-vector products, triangular multiplication and division, syrk/herk, dgmm, and the BLAS 1 functions. GPUArrays now decides which calls reach oneMKL, with generic kernels for the rest, as with CUDA.jl (JuliaGPU/CUDA.jl#3626) and AMDGPU.jl (JuliaGPU/AMDGPU.jl#1229).

Requires GPUArrays 12.4, which implements dot for every wrapped GPU array, so the dot methods for Symmetric and Hermitian matrices are gone, and whose generic axpy!/axpby! pair operands of different shapes. norm only uses oneMKL's nrm2 for half precision: it loses subnormal Float32 elements, which GPUArrays' generic norm rescales. test/onemkl.jl gains tests for the cases the old methods handled: triangular operations on strided views, false as a strong zero, Diagonal norms, and dot of wrapped arrays and strided views.

…erations and BLAS 1 functions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013b7DCbTAjtfi3JqXU4xZmW
GPUArrays 12.4 implements dot for all wrapped GPU arrays, and returns a
real number for Hermitian matrices, as LinearAlgebra does.
@maleadt

maleadt commented Dec 2, 2026

Copy link
Copy Markdown
Member

With GPUArrays 12.4 (JuliaGPU/GPUArrays.jl#888), the dot methods for Symmetric and Hermitian matrices can go, and the axpy!/axpby! tests with a matrix view and a vector (onemkl.jl:165-167) pass now: GPUArrays' generic fallbacks used to broadcast operands of different shapes. I pushed the dot change as a separate commit (it needs 12.4 to be registered before CI can resolve it). On an A770, four norm tests on subnormal inputs (GPUArrays' testsuite linalg.jl:1018) still fail: the blas_nrm2 hook sends Float32 and Float64 to oneMKL, which loses those elements, while released oneAPI.jl passes them. CUDA.jl only implements that hook for half precision, as cuBLAS has the same problem.

oneMKL's nrm2 loses subnormal Float32 elements, which GPUArrays' generic
norm rescales: the subnormal norm tests of GPUArrays' test suite failed.
CUDA.jl only implements this hook for half precision too.
@maleadt
maleadt marked this pull request as ready for review December 3, 2026 11:13
@maleadt

maleadt commented Dec 3, 2026

Copy link
Copy Markdown
Member

The norm failures on subnormal inputs in GPUArrays' test suite came from the blas_nrm2 hook: oneMKL's nrm2 loses subnormal Float32 elements, which GPUArrays' generic norm rescales. adc364d only uses nrm2 for half precision, as CUDA.jl does; with it, onemkl and GPUArrays' linalg tests pass on an A770. The earlier ALCF and Buildkite failures were GPUArrays 12.4 not being registered yet.

The inverse plans scaled by 1/n, a Float64. oneAPI.jl's rmul! used to convert
that to the array's eltype; GPUArrays' rmul! keeps a wider scalar, as
LinearAlgebra does, which devices without Float64 support can't compile. Use
AbstractFFTs.normalization with the plan's real type, as CUDA.jl's cuFFT does.
Julia 1.10.12 and earlier reject row-skipping views in LinearAlgebra's
triangular solves, and pass strided vectors to trtrs as if they were
contiguous, which made the CPU reference fail on the Aurora 1.10 job. The GPU
side still operates on views.
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.95%. Comparing base (78d070d) to head (0dabf13).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
lib/mkl/fft.jl 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #779      +/-   ##
==========================================
+ Coverage   86.90%   86.95%   +0.04%     
==========================================
  Files          55       55              
  Lines        5103     5007      -96     
==========================================
- Hits         4435     4354      -81     
+ Misses        668      653      -15     

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

This branch has not been deployed

No deployments
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.

2 participants