Storage-level mul! gives wrong results or aborts for SubArray operands
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #724 de @maleadt — fusionado
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 62/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Julia
- Estrellas
- 218
- Forks
- 36
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 54
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de JuliaGPU/oneAPI.jl
-
Make host-to-device uploads non-blocking via a host-USM staging poolPosiblemente ocupada @maleadt la tomó hoy. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Products with a Symmetric/Hermitian oneMKL sparse matrix ignore the wrapperPosiblemente ocupada @maleadt la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
Los mantenedores suelen responder en 1 día
-
performance
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
-
libraries upstream
Dificultad 4/5 1-2 días Aptitud para principiantes 22/100
JuliaGPU/oneAPI.jl#703 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ci
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
JuliaGPU/oneAPI.jl#663 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de JuliaGPU/oneAPI.jl
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
bug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
JuliaGeometry/Meshes.jl#1469 ·
Los mantenedores suelen responder en 1 día
-
distributed 🕸️
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
CliMA/Oceananigans.jl#6295 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
CI: two jobs fail on the new ubuntu-latest (Ubuntu 26.04) runner imagePosiblemente ocupada @bjarthur la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
mojaie/MolecularGraph.jl#151 ·