You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect result and non-deterministic hardware specific result with threaded OpenBLAS on Intel Xeon 8488C for matrix with sparse column #5267
Summary
We are observing incorrect and non-deterministic results when performing matrix multiplication of the form t(X) %*% X in R when using OpenBLAS on Intel Xeon 8488C CPUs. The issue appears only when multi-threading. The bug does not occur on other CPU architectures (e.g., AMD EPYC, Intel 8259CL) and is not present when limiting OpenBLAS to a single thread or using R’s internal matrix multiplication routines.
System Information:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8488C
CPU family: 6
Model: 143
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Stepping: 8
BogoMIPS: 4800.00
Only on affected hardware (Intel 8488C), when using more than 1 thread, we see an incorrect value (~0.00229). Setting OPENBLAS_NUM_THREADS=1 makes the issue go away.
We have only reproduced the issue so far with the attached matrix. Note this matrix is ill-conditioned. However, this should not affect the result to this magnitude.
Here is a chart of the result we get for element [2448,2449] with respect to the OPENBLAS_NUM_THREADS setting:
Observations
The issue does not appear on AMD EPYC 7R13 or Intel 8259CL.
Only observed with multithreaded OpenBLAS on AVX-512 capable hardware.
Dot products involving entirely zero columns behave unexpectedly under multithreading.
Manual dot product confirms result should be exactly 0.
Disabling threading (OPENBLAS_NUM_THREADS=1) makes the issue disappear.
Hypothesis
This appears to be a bug in the multithreaded dgemm implementation when using AVX-512. Potential contributing factors include:
Accumulation errors across SIMD lanes when computing many dot products in parallel.
Internal tiling and block accumulation strategies may be introducing rounding errors even when one operand is all zero.
The result (~0.0023) is too large to be explained by standard floating-point noise, suggesting a flaw in reduction logic.
All the jobs are running on the same docker image, and I've compared all the session/environment info between them. AVX was just a hypothesis. Could it be related to Cascade lake vs Saphire rapids?
Same DGEMM kernel code and parameters between the two Intel systems (the main difference is in BFLOAT16). But given that you seem to be using version 0.3.20 from three years ago (did not notice this initially, sorry), it is possible that it may not have identified either cpu correctly, potentially falling back to much older code. I wonder if you could rerun with environment variable OPENBLAS_VERBOSE=2 to have it print out what set of kernels it is using ?
Unfortunately I cannot reproduce this (with R-4.5.0) on any system I have access to (which sadly does not include 8488C specifically), and I do not see what would single out that particular cpu.
I wonder if you could install the current OpenBLAS in your docker container to check ? The libblas.so.3 and libopenblas... in your sessioninfo output are (or should be) links to the same shared library, it is just that stock R has them as libblas.so.3 and liblapack.so.3 (and corresponding to the respective unoptimized library from the Reference-LAPACK/BLAS by default)
In the project semicolon-lapack, I have been translating LAPACK to C on top of any CBLAS interface (but assuming OpenBLAS CBLAS as the default vendor).
Similar to above, I've been using CBLAS interface with MSYS2 + LLVM-MINGW worker on the GitHub runners
GitHub runner machine selection oscillates between two machines essentially; Intel Xeon and AMD EPYC.
=== CPU ===
model name : Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
Cores: 4
=== Compiler ===
clang version 21.1.8
=== OpenBLAS ===
mingw-w64-clang-x86_64-openblas 0.3.31-1
This one goes fundamentally wrong with almost all tests, but passes with bit-parity on the LAPACK tests if it falls onto AMD EPYC 7763 64-Core. And since I wrote and verified the LAPACK Translations on other platforms, this gives me more confidence to speculate that this is somehow an optimization selection issue on Ice Lake or similar platforms. In fact when forced to have Haswell as the Coretype then all tests pass with no error.
I compiled all the real valued failures (note that the tests are ported from Reference LAPACK) and sparred with an LLM and it spat out the following, it rings true but not sure if it is accurate enough to take action
153 pass, 131 fail. Both precisions affected, single much worse.
Smoking Gun: Blocked vs Unblocked
The clearest signal is in dchkge (double LU):
nb=1 (unblocked dgetf2): ALL sizes, ALL matrix types fail nb=3 and nb=20 (blocked dgetrf): mostly pass
Yet in single precision it's the opposite — sgetrf (blocked, uses sgemm) fails with residuals of 4.1e+05 to 6.7e+08, while dgetrf passes. And spotrf returns info=13,14,16,26,31 claiming the matrix is non-positive-definite on matrices that ARE positive definite — because ssyrk corrupts the panel update.
Level
Examples
Residual
Crash
schkpo (SIGFPE), sdrvpo (signal 16)
N/A — division by corrupted zero diagonal
Garbage
dchktr triangular inverse
8.9e+307 (near DBL_MAX)
No significant digits
dgeqrf Q orthogonality
4.8e+17 (~1/DBL_EPSILON)
Completely wrong
sgetrfn=50
6.7e+08 (~1/FLT_EPSILON)
What's NOT broken
All tridiagonal tests pass (no BLAS-3). All eigenvalue routines using only level-1/2 BLAS pass (dsterf, dsteqr, dstebz). Packed/banded with custom loops pass (dchksp). ddot, daxpy, idamax, dscal appear fine.
Corrupted kernels
Definite: sgemm, ssyrk, strsm (single-precision BLAS-3 — totally broken)
Partial: dgemm (works for triangular panel updates in dgetrf, but broken for Householder reflector patterns in dlarfb)
Partial: dgemv/dger (unblocked dgetf2 path corrupted)
Bottom line
The OpenBLAS Ice Lake AVX-512 kernels seem to be the culprit — not a precision issue but a "reading/writing wrong memory" issue producing results with zero significant digits. OPENBLAS_CORETYPE=Haswell forces AVX2 kernels and that's why the failures are gone.
Some more information, I changed the run to have MSYS2 + GCC and tested for auto-select vs. specifically choosing Prescott, again forcing the summary via the LLM but this time I manually edited the output and verified
UCRT64 Failure Analysis
Machine: AMD EPYC 7763 (same for all 3 jobs this run)
OpenBLAS: 0.3.31 DYNAMIC_ARCH, selects Zen kernel
Three distinct failure categories:
ddrgev/ddrgev3/sdrgev/sdrgev3 test5 — Default Zen kernel (4 failures)
These fail ONLY on Zen, pass on Prescott. Test5 is a bitwise eigenvalue comparison between DGGEV("V","V") (with eigenvectors) vs DGGEV("N","N") (without). The original Fortran test (ddrgev.f:780-783) also uses .NE. (bitwise). The idea is the QZ algorithm path should be identical regardless of eigenvector computation.
The diffs reveal the mechanism — from the log:
j=7: alphar diff=7.120e-307 alphai diff=5.340e-307 beta diff=6.924e+274
These are near the deflation boundary: alpha0, betahuge. FMA instructions cause micro-rounding differences that push the QZ deflation criterion slightly differently in the two calls, producing different bit patterns for numerically-identical eigenvalues. Haswell kernel (what CLANG64 forces) doesn't trigger this because its FMA usage pattern is consistent across both code paths.
ddrges/ddrges3 N=16_type=19 — Prescott only (2 failures)
test(7)=4.5036e+15 (=1/ulp, catastrophic). Passes on Zen but fails on Prescott. The SSE2-only Prescott kernel has slightly worse accuracy that tips this specific edge case.
sdrvrf4 n2_k50 — Prescott only (2 subcases)
SSFRK vs cblas_ssyrk mismatch in single precision. Only 2/3136 subcases — another Prescott numerical edge case.
Why CLANG64 differs
CLANG64 is on the same machine (AMD EPYC 7763, Zen kernel detected), but we force OPENBLAS_CORETYPE=Haswell → 284/284 pass. The Haswell kernel produces consistent bitwise eigenvalues across DGGEV variants.
Key question
The default UCRT64 test uses the native Zen kernel. The simplest fix would be to also force Haswell on UCRT64's main test, like CLANG64. But this would hide a real FMA-related inconsistency. Alternatively, we could accept these 4 test 5 failures as known kernel-dependent behavior — the Fortran LAPACK test suite itself would likely show the same failures on a Zen mach
Can't really look now but pretty sure "ZEN" (for AMD hardware without AVX512) uses exact same GEMM kernels as Haswell. Ice Lake uses AVX512 kernels originally written for Sky Lake.
Not sure I buy the catastrophic GEMM failures seen with AVX512 kernels - unless perhaps it is a Windows-specific issue with CLANG (or with the code making dangerous assumptions about register availability or similar - at least some versions of LLVM were prone to erroring out on these kernels with "inline assembly requires more registers than available"). IMO completely broken kernels accessing the wrong parts of memory should have shown up as catastrophic errors in CI or real-world use long ago
Activity
martin-frbg commentedon May 16, 2025
Both Intel systems would be using the same (AVX-512) DDOT kernel - are you sure you are using the same software versions on them ?
jwasteneys-ccl commentedon May 16, 2025
All the jobs are running on the same docker image, and I've compared all the session/environment info between them. AVX was just a hypothesis. Could it be related to Cascade lake vs Saphire rapids?
martin-frbg commentedon May 17, 2025
Same DGEMM kernel code and parameters between the two Intel systems (the main difference is in BFLOAT16). But given that you seem to be using version 0.3.20 from three years ago (did not notice this initially, sorry), it is possible that it may not have identified either cpu correctly, potentially falling back to much older code. I wonder if you could rerun with environment variable OPENBLAS_VERBOSE=2 to have it print out what set of kernels it is using ?
jwasteneys-ccl commentedon May 20, 2025
When I turn on that variable I get:
Core: Cooperlake
I also tried setting OPENBLAS_CORETYPE=haswell, and I got the same (incorrect) results as on cooperlake
jwasteneys-ccl commentedon May 20, 2025
Actually I take that back, with multiple threads it looks like the results are different on Haswell vs Cooperlake:
Core: Haswell
[1] -2.660589e-10
Core: Cooperlake
[1] 0.002292634
martin-frbg commentedon May 20, 2025
Unfortunately I cannot reproduce this (with R-4.5.0) on any system I have access to (which sadly does not include 8488C specifically), and I do not see what would single out that particular cpu.
jwasteneys-ccl commentedon May 21, 2025
Is there any other information that I could provide that would help to narrow it down?
martin-frbg commentedon May 21, 2025
Just to be sure - are
both pointing to the same library ?
jwasteneys-ccl commentedon May 21, 2025
This is what I currently have set up (reproduces issue):
Core: Cooperlake
jwasteneys-ccl commentedon May 21, 2025
Sorry I made a mistake for coretype=Haswell, the issue goes away.
I had a piece of test code that set Xsmall[,2449] <- 1e-10 to see if a small number behaved differently than zero which gave me this result:
When really the result should be:
And for Cooperlake:
I also rebuilt my docker container to be sure:
I'm not sure what the difference between libblas.so.3 and libopenblasp-r0.3.20.so and why it switched from before.
So it seems like it is related to Cooperlake in particular.
I also tried with Skylake:
So it seems like the issue is might be what you originally thought, and it's identifying the wrong kernel?
martin-frbg commentedon May 21, 2025
I wonder if you could install the current OpenBLAS in your docker container to check ? The libblas.so.3 and libopenblas... in your sessioninfo output are (or should be) links to the same shared library, it is just that stock R has them as libblas.so.3 and liblapack.so.3 (and corresponding to the respective unoptimized library from the Reference-LAPACK/BLAS by default)
jwasteneys-ccl commentedon May 22, 2025
I think the version of ubuntu I'm using (ubuntu:jammy-20240125) pins the blas version, so I haven't been able to easily update it
ilayn commentedon Feb 27, 2026
In the project
semicolon-lapack, I have been translating LAPACK to C on top of any CBLAS interface (but assuming OpenBLAS CBLAS as the default vendor).Similar to above, I've been using CBLAS interface with MSYS2 + LLVM-MINGW worker on the GitHub runners
GitHub runner machine selection oscillates between two machines essentially; Intel Xeon and AMD EPYC.
This one goes fundamentally wrong with almost all tests, but passes with bit-parity on the LAPACK tests if it falls onto AMD EPYC 7763 64-Core. And since I wrote and verified the LAPACK Translations on other platforms, this gives me more confidence to speculate that this is somehow an optimization selection issue on Ice Lake or similar platforms. In fact when forced to have Haswell as the Coretype then all tests pass with no error.
A passing test run when coretype is Haswell and a failing run with auto-select
I compiled all the real valued failures (note that the tests are ported from Reference LAPACK) and sparred with an LLM and it spat out the following, it rings true but not sure if it is accurate enough to take action
CLANG64 Failure Analysis — Intel Xeon 8370C (Ice Lake) + OpenBLAS 0.3.31
153 pass, 131 fail. Both precisions affected, single much worse.
Smoking Gun: Blocked vs Unblocked
The clearest signal is in dchkge (double LU):
nb=1(unblocked dgetf2): ALL sizes, ALL matrix types failnb=3andnb=20(blocked dgetrf): mostly passYet in single precision it's the opposite — sgetrf (blocked, uses sgemm) fails with residuals of 4.1e+05 to 6.7e+08, while
dgetrfpasses. Andspotrfreturns info=13,14,16,26,31 claiming the matrix is non-positive-definite on matrices that ARE positive definite — becausessyrkcorrupts the panel update.schkpo(SIGFPE),sdrvpo(signal 16)dchktrtriangular inversedgeqrfQ orthogonalitysgetrfn=50What's NOT broken
All tridiagonal tests pass (no BLAS-3). All eigenvalue routines using only level-1/2 BLAS pass (dsterf, dsteqr, dstebz). Packed/banded with custom loops pass (dchksp). ddot, daxpy, idamax, dscal appear fine.
Corrupted kernels
Definite: sgemm, ssyrk, strsm (single-precision BLAS-3 — totally broken)
Partial: dgemm (works for triangular panel updates in dgetrf, but broken for Householder reflector patterns in dlarfb)
Partial: dgemv/dger (unblocked dgetf2 path corrupted)
Bottom line
The OpenBLAS Ice Lake AVX-512 kernels seem to be the culprit — not a precision issue but a "reading/writing wrong memory" issue producing results with zero significant digits. OPENBLAS_CORETYPE=Haswell forces AVX2 kernels and that's why the failures are gone.
ilayn commentedon Feb 27, 2026
Some more information, I changed the run to have MSYS2 + GCC and tested for auto-select vs. specifically choosing Prescott, again forcing the summary via the LLM but this time I manually edited the output and verified
UCRT64 Failure Analysis
Machine: AMD EPYC 7763 (same for all 3 jobs this run)
OpenBLAS: 0.3.31 DYNAMIC_ARCH, selects Zen kernel
Three distinct failure categories:
These fail ONLY on Zen, pass on Prescott. Test5 is a bitwise eigenvalue comparison between DGGEV("V","V") (with eigenvectors) vs DGGEV("N","N") (without). The original Fortran test (ddrgev.f:780-783) also uses .NE. (bitwise). The idea is the QZ algorithm path should be identical regardless of eigenvector computation.
The diffs reveal the mechanism — from the log:
j=7: alphar diff=7.120e-307 alphai diff=5.340e-307 beta diff=6.924e+274
These are near the deflation boundary: alpha0, betahuge. FMA instructions cause micro-rounding differences that push the QZ deflation criterion slightly differently in the two calls, producing different bit patterns for numerically-identical eigenvalues. Haswell kernel (what CLANG64 forces) doesn't trigger this because its FMA usage pattern is consistent across both code paths.
test(7)=4.5036e+15 (=1/ulp, catastrophic). Passes on Zen but fails on Prescott. The SSE2-only Prescott kernel has slightly worse accuracy that tips this specific edge case.
SSFRK vs cblas_ssyrk mismatch in single precision. Only 2/3136 subcases — another Prescott numerical edge case.
Why CLANG64 differs
CLANG64 is on the same machine (AMD EPYC 7763, Zen kernel detected), but we force OPENBLAS_CORETYPE=Haswell → 284/284 pass. The Haswell kernel produces consistent bitwise eigenvalues across DGGEV variants.
Key question
The default UCRT64 test uses the native Zen kernel. The simplest fix would be to also force Haswell on UCRT64's main test, like CLANG64. But this would hide a real FMA-related inconsistency. Alternatively, we could accept these 4 test 5 failures as known kernel-dependent behavior — the Fortran LAPACK test suite itself would likely show the same failures on a Zen mach
martin-frbg commentedon Feb 27, 2026
Can't really look now but pretty sure "ZEN" (for AMD hardware without AVX512) uses exact same GEMM kernels as Haswell. Ice Lake uses AVX512 kernels originally written for Sky Lake.
martin-frbg commentedon Mar 2, 2026
Not sure I buy the catastrophic GEMM failures seen with AVX512 kernels - unless perhaps it is a Windows-specific issue with CLANG (or with the code making dangerous assumptions about register availability or similar - at least some versions of LLVM were prone to erroring out on these kernels with "inline assembly requires more registers than available"). IMO completely broken kernels accessing the wrong parts of memory should have shown up as catastrophic errors in CI or real-world use long ago