-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfaults/wrong results from matmul!
#193
Comments
On all machines I was able to test the code above results in segfaults, if: julia> Octavian.has_feature(Val(:x86_64_avx512f))
static(true) Overriding the trait Octavian.has_feature(::Val{:x86_64_avx512f}) = Octavian.static(false) before calling the Debugging this lead me to the following Line 20 in 5223531
This is what I get (using julia v1.10.5): julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 16 × 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
julia> Octavian.has_feature(Val(:x86_64_avx512f))
static(true)
julia> Octavian.matmul!(c, a, b, true, false)
((Mblock, Mblock_Mrem, Mremfinal, Mrem, Miter), (Kblock, Kblock_Krem, Krem, Kiter)) = ((24, 24, 10, 0, 0), (3000, 3001, 0, 1))
julia> Octavian.has_feature(::Val{:x86_64_avx512f}) = Octavian.static(false)
julia> Octavian.matmul!(c, a, b, true, false)
((Mblock, Mblock_Mrem, Mremfinal, Mrem, Miter), (Kblock, Kblock_Krem, Krem, Kiter)) = ((0, 0, 10, 0, 1), (600, 601, 0, 5)) The fact that the function versioninfo / has_feature(v.1.11.1) julia> using HostCPUFeatures
julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 128 × AMD EPYC 9374F 32-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver4)
Threads: 1 default, 0 interactive, 1 GC (on 128 virtual cores)
julia> has_feature(Val(:x86_64_avx512f))
static(true) (v.1.10.5) julia> using HostCPUFeatures
julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 128 × AMD EPYC 9374F 32-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 128 virtual cores)
julia> has_feature(Val(:x86_64_avx512f))
static(false) |
Octavian's blocking strategy/algorithm is outright bad/suboptimal. Anyway, why is it even trying to block? The overall size of the arrays is large, but the reduction dimension is so small, that it can fit the answer in registers. You can pick a location and do a size-check a simple hotfix would be to edit this line: Line 570 in 5223531
To also check if W*mᵣ >= M .
|
Thanks! This resolves the initial issue. julia> using Octavian
julia> M, K, N = 25, 3000, 10
(25, 3000, 10)
julia> A = ones(M, K);
julia> B = ones(K, N);
julia> C = zeros(size(A, 1), size(B, 2));
julia> Octavian.matmul!(C, A, B)
((Mblock, Mblock_Mrem, Mremfinal, Mrem, Miter), (Kblock, Kblock_Krem, Krem, Kiter)) = ((24, 24, 1, 0, 1), (3000, 3001, 0, 1))
25×10 Matrix{Float64}:
3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
⋮ ⋮
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
julia> @assert C ≈ A*B
ERROR: AssertionError: C ≈ A * B The printed block-sizes are the ones computed in the following line: Line 22 in 5223531
It seems as if for this case Miter should be Miter+1 .
Again, this only occurs if julia> Octavian.has_feature(Val(:x86_64_avx512f))
static(true) Otherwise, the computed block sizes are different. |
Follow up on LuxDL/Lux.jl#980.
When running the following script I get the wrong results/segfaults:
run/core dump/versioninfo
I was able to reproduce this on julia v1.11.0 and v1.10.5 on my machine and reliably on v1.11.0 on another machine.
run different machine
The text was updated successfully, but these errors were encountered: