Storage-level mul! gives wrong results or aborts for SubArray operands
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
Start by running the four snippets in the issue to confirm the wrong results and the abort. The storage-level mul! methods are in lib/mkl/linalg.jl and call the wrappers in lib/mkl/wrappers_blas.jl, which compute lda and incx without checking layout. Add the layout guard in the mul! methods for gemm, gemv, symm, hemm, symv and hemv, with a fallback to GPUArrays.generic_matmatmul! for the other cases. Also make onemklSgemm in deps/src/onemkl.cpp return an error code instead of letting oneMKL exceptions escape. Done when the snippets match the reference products and the reversed-column case no longer aborts.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The storage-level mul! methods in lib/mkl/linalg.jl pass any strided SubArray of a oneArray to oneMKL, and the wrappers in lib/mkl/wrappers_blas.jl use lda = max(1, stride(A, 2)) and incx = stride(x, 1) without checking the layout. Depending on the view, that gives silently wrong results or aborts the process:
using oneAPI, LinearAlgebra
A = oneArray(rand(Float32, 8, 4)); B = oneArray(rand(Float32, 4, 5)); x = oneArray(rand(Float32, 4))
# row-stepping view: wrong result, for gemm and gemv alike
C = mul!(oneArray(zeros(Float32, 4, 5)), 'N', 'N', view(A, 1:2:8, :), B, true, false)
Array(C) ≈ Array(A)[1:2:8, :] * Array(B) # false
y = mul!(oneArray(zeros(Float32, 4)), 'N', view(A, 1:2:8, :), x, true, false)
Array(y) ≈ Array(A)[1:2:8, :] * Array(x) # false
# reversed vector: wrong result (BLAS reads a negative increment from the end of the vector)
y = mul!(oneArray(zeros(Float32, 8)), 'N', A, view(x, 4:-1:1), true, false)
Array(y) ≈ Array(A) * reverse(Array(x)) # false
# reversed columns: the process aborts
mul!(oneArray(zeros(Float32, 8, 5)), 'N', 'N', view(A, :, 4:-1:1), B, true, false)
# terminate called after throwing an instance of 'oneapi::mkl::invalid_argument'
# what(): oneapi::mkl::oneapi::mkl::blas::sgemm: invalid argument: Illegal value supplied for parameter lda
# signal 6 (-6): Aborted
The abort also means onemklSgemm in deps/src/onemkl.cpp lets oneMKL exceptions escape through the C interface instead of turning them into an error code.
The public mul!(C, A, B) isn't affected, because GPUArrays intercepts products with views before they reach these methods. JuliaGPU/GPUArrays.jl#800 starts forwarding matrix-matrix products with views here again, but only N/T/C products where every matrix has a unit row stride and stride(X, 2) >= size(X, 1). Calling the storage-level mul! directly is public API since Julia 1.13 (JuliaLang/LinearAlgebra.jl#1671), though. CUDA.jl added the equivalent guards in JuliaGPU/CUDA.jl#3316:
- only call oneMKL when every matrix has
stride(X, 1) == 1andstride(X, 2) >= max(1, size(X, 1)), and every vector has a positive stride; - otherwise fall back to
GPUArrays.generic_matmatmul!.
That applies to gemm, gemv, symm, hemm, symv and hemv.
Reproduced with oneAPI.jl 2.9.2 on an Iris Xe, Julia 1.12.7. The mul! methods and the gemm/gemv/symm wrappers are unchanged on main.
- Ngôn ngữ chính
- Julia
- Star
- 217
- Fork
- 37
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaGPU/oneAPI.jl
-
libraries upstream
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 22/100
JuliaGPU/oneAPI.jl#703 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
IGC heap corruption compiling findmax's reduction kernel on Julia 1.12 with --check-bounds=yesĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
JuliaGPU/oneAPI.jl#663 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của JuliaGPU/oneAPI.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JuliaGPU/KernelAbstractions.jl#897 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
oscar-system/GAP.jl#1455 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
JuliaAI/MLJTransforms.jl#85 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
SciML/OrdinaryDiffEq.jl#4875 ·
Maintainer thường phản hồi trong vòng 4 ngày