Skip to content

Implement LinearAlgebra's storage-specific mul! methods - #3257

Merged
maleadt merged 1 commit into
mainfrom
tb/linalg-mul-1.13
Sep 3, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/linalg-mul-1.13

Conversation

@maleadt

@maleadt maleadt commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Julia 1.13-rc4 bumped LinearAlgebra to a version including JuliaLang/LinearAlgebra.jl#1671, which renamed the storage-level generic_matvecmul!/generic_matmatmul! entry points into 6- and 7-argument mul! methods. LinearAlgebra's strided BlasFloat mul! is more specific than the fallback that still routes to the old names, so our generic_matvecmul! overload was never reached on 1.13 and matrix-vector products ended up in CPU BLAS.

This implements the products as the new mul! methods and keeps the legacy names only as forwarding shims for Julia < 1.13 (one @static block per file, to be dropped when 1.13 becomes the floor). It requires GPUArrays 11.5.14 (JuliaGPU/GPUArrays.jl#775, now registered), whose generic_matmatmul_wrapper! hooks route through mul! on 1.13.

@maleadt
maleadt force-pushed the tb/linalg-mul-1.13 branch 3 times, most recently from 1f0ac8e to 48cc607 Compare September 3, 2026 13:24
@maleadt
maleadt marked this pull request as ready for review September 3, 2026 14:33
Julia 1.13-rc4 bumped LinearAlgebra to a version that includes
JuliaLang/LinearAlgebra.jl#1671, which renamed the storage-level
`generic_matvecmul!`/`generic_matmatmul!` entry points into 6- and
7-argument `mul!` methods, with the old names kept only as a fallback
behind the generic `mul!` method.

For matrix-vector products this breaks cuBLAS dispatch: LinearAlgebra's
strided BlasFloat `mul!` method is more specific than that fallback, so
it wins over our `generic_matvecmul!` overload and calls into CPU BLAS,
failing with

    ArgumentError: Illegal conversion of a CUDACore.DeviceMemory to a Ptr{Float32}

Implement the cuBLAS and cuSPARSE products as the new `mul!` methods,
and keep the legacy names only as forwarding shims for Julia before 1.13
so that they can be dropped together once 1.13 becomes the floor.

Require GPUArrays 11.5.14, whose `generic_matmatmul_wrapper!` hooks
(used for element types cuBLAS does not cover) route through `mul!`
rather than the legacy name, which on 1.13 would bypass these methods.
@maleadt
maleadt merged commit 7ab5356 into main Sep 3, 2026
1 check was pending
@maleadt
maleadt deleted the tb/linalg-mul-1.13 branch September 3, 2026 18:16
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.25%. Comparing base (413be53) to head (6e6c88c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/cusparse/src/interfaces.jl 29.41% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3257      +/-   ##
==========================================
+ Coverage   92.18%   92.25%   +0.06%     
==========================================
  Files         184      184              
  Lines       16291    16289       -2     
==========================================
+ Hits        15018    15027       +9     
+ Misses       1273     1262      -11     

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

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

CUDA.jl Benchmarks

Details
Benchmark suite Current: 6e6c88c Previous: 413be53 Ratio
array/accumulate/Float32/1d 98008 ns 98229 ns 1.00
array/accumulate/Float32/dims=1 71850 ns 72403 ns 0.99
array/accumulate/Float32/dims=1L 1599638 ns 1599427 ns 1.00
array/accumulate/Float32/dims=2 137251 ns 138275 ns 0.99
array/accumulate/Float32/dims=2L 660028 ns 660231 ns 1.00
array/accumulate/Int64/1d 117893 ns 118416 ns 1.00
array/accumulate/Int64/dims=1 75923 ns 75920 ns 1.00
array/accumulate/Int64/dims=1L 1715740 ns 1715471 ns 1.00
array/accumulate/Int64/dims=2 148381 ns 148942 ns 1.00
array/accumulate/Int64/dims=2L 986966 ns 987603 ns 1.00
array/broadcast 18240 ns 17937 ns 1.02
array/broadcast launch 9392 ns 9013 ns 1.04
array/construct 921.1071428571429 ns 884.7551020408164 ns 1.04
array/copy 16511 ns 16497 ns 1.00
array/copyto!/cpu_to_gpu 208227 ns 208624 ns 1.00
array/copyto!/gpu_to_cpu 241868 ns 241688 ns 1.00
array/copyto!/gpu_to_gpu 8914 ns 8784 ns 1.01
array/iteration/findall/bool 132939 ns 133723 ns 0.99
array/iteration/findall/int 148289 ns 147552 ns 1.00
array/iteration/findfirst/bool 69408 ns 69312 ns 1.00
array/iteration/findfirst/int 70256 ns 70611 ns 0.99
array/iteration/findmin/1d 70497 ns 71647 ns 0.98
array/iteration/findmin/2d 99943 ns 99851 ns 1.00
array/iteration/logical 190688 ns 191816 ns 0.99
array/iteration/scalar 63372 ns 63027 ns 1.01
array/permutedims/2d 49063 ns 49063 ns 1
array/permutedims/3d 50797 ns 50390 ns 1.01
array/permutedims/4d 50426 ns 49946 ns 1.01
array/random/rand/Float32 11384 ns 10926 ns 1.04
array/random/rand/Int64 23138 ns 21140 ns 1.09
array/random/rand!/Float32 7982.25 ns 7777.75 ns 1.03
array/random/rand!/Int64 20499 ns 20510 ns 1.00
array/random/randn/Float32 33667 ns 33460 ns 1.01
array/random/randn!/Float32 28844 ns 23484 ns 1.23
array/reductions/mapreduce/Float32/1d 33238 ns 32875 ns 1.01
array/reductions/mapreduce/Float32/dims=1 37500 ns 37986 ns 0.99
array/reductions/mapreduce/Float32/dims=1L 50590 ns 50664 ns 1.00
array/reductions/mapreduce/Float32/dims=2 54979 ns 55130 ns 1.00
array/reductions/mapreduce/Float32/dims=2L 67103 ns 67684 ns 0.99
array/reductions/mapreduce/Int64/1d 40463 ns 40586 ns 1.00
array/reductions/mapreduce/Int64/dims=1 40529 ns 40894 ns 0.99
array/reductions/mapreduce/Int64/dims=1L 88568 ns 88686 ns 1.00
array/reductions/mapreduce/Int64/dims=2 57559 ns 57559 ns 1
array/reductions/mapreduce/Int64/dims=2L 83732 ns 83485 ns 1.00
array/reductions/reduce/Float32/1d 32752 ns 33402 ns 0.98
array/reductions/reduce/Float32/dims=1 37599 ns 37970 ns 0.99
array/reductions/reduce/Float32/dims=1L 50413 ns 50711 ns 0.99
array/reductions/reduce/Float32/dims=2 54980 ns 55262 ns 0.99
array/reductions/reduce/Float32/dims=2L 68481 ns 69402 ns 0.99
array/reductions/reduce/Int64/1d 39979 ns 40219 ns 0.99
array/reductions/reduce/Int64/dims=1 40330 ns 40569 ns 0.99
array/reductions/reduce/Int64/dims=1L 88549 ns 88630 ns 1.00
array/reductions/reduce/Int64/dims=2 57115 ns 57679 ns 0.99
array/reductions/reduce/Int64/dims=2L 83091 ns 83192 ns 1.00
array/reverse/1d 16999 ns 17277 ns 0.98
array/reverse/1dL 69739 ns 70117 ns 0.99
array/reverse/1dL_inplace 67570 ns 67420 ns 1.00
array/reverse/1d_inplace 8630 ns 8525.666666666666 ns 1.01
array/reverse/2d 20172 ns 20268 ns 1.00
array/reverse/2dL 73600 ns 73702 ns 1.00
array/reverse/2dL_inplace 67299 ns 67234 ns 1.00
array/reverse/2d_inplace 9957 ns 9987 ns 1.00
array/sorting/1d 2647684 ns 2658165 ns 1.00
array/sorting/2d 1028673 ns 1029672 ns 1.00
array/sorting/by 3182607 ns 3182246 ns 1.00
cuda/synchronization/context/auto 1008.1 ns 1024.7 ns 0.98
cuda/synchronization/context/blocking 771.1509433962265 ns 780.2424242424242 ns 0.99
cuda/synchronization/context/nonblocking 5967.833333333333 ns 5857 ns 1.02
cuda/synchronization/stream/auto 863.7719298245614 ns 874.9387755102041 ns 0.99
cuda/synchronization/stream/blocking 665.1132075471698 ns 674.7012987012987 ns 0.99
cuda/synchronization/stream/nonblocking 5857.428571428572 ns 5722.857142857143 ns 1.02
integration/byval/reference 147877 ns 147920 ns 1.00
integration/byval/slices=1 149120 ns 148937 ns 1.00
integration/byval/slices=2 291726 ns 292148 ns 1.00
integration/byval/slices=3 434777 ns 434674 ns 1.00
integration/cudadevrt 105280 ns 105237 ns 1.00
integration/volumerhs 9139844 ns 9139215 ns 1.00
kernel/indexing 13009 ns 13092 ns 0.99
kernel/indexing_checked 13732 ns 13675 ns 1.00
kernel/launch 2204.777777777778 ns 2261.3333333333335 ns 0.97
kernel/occupancy 716.2785714285715 ns 792.40625 ns 0.90
kernel/rand 14940 ns 17535 ns 0.85
latency/import 4229849868 ns 4118475955 ns 1.03
latency/precompile 4986576090 ns 4881109694 ns 1.02
latency/ttfp 4671639575 ns 4573842559 ns 1.02

This comment was automatically generated by workflow using github-action-benchmark.

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