-
-
Notifications
You must be signed in to change notification settings - Fork 17
Strange numerical issues with LinearAlgebra, Nan issues on Mac but not Linux #1200
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
Comments
Can you please share the output of julia> using LinearAlgebra
julia> norm(vec)
1.0
julia> any(isnan, vec)
false
julia> norm(real(vec))
1.0
julia> norm(imag(vec))
2.3279903658876797e-15
julia> Q, R = qr(reshape(vec, 2^5, 2^6));
julia> any(isnan, Matrix(Q))
false
julia> norm(Matrix(Q))
5.656854249492382
julia> any(isnan, R)
false
julia> norm(R)
1.0000000000000002
julia> norm(real(R))
1.0000000000000002
julia> norm(imag(R))
1.8145633091651453e-9
julia> versioninfo()
Julia Version 1.13.0-DEV.39
Commit 866c61de6e* (2025-02-11 23:02 UTC)
Platform Info:
OS: macOS (arm64-apple-darwin23.4.0)
CPU: 8 × Apple M1
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, apple-m1)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)
julia> using OpenBLAS_jll
julia> strip(unsafe_string(ccall(((:openblas_get_config64_), libopenblas), Ptr{UInt8}, () )))
"OpenBLAS 0.3.29 USE64BITINT DYNAMIC_ARCH NO_AFFINITY neoversen1 MAX_THREADS=512" |
Assuming you're using Julia v1.11 with OpenBLAS 0.3.27, at a quick glance this may be OpenMathLib/OpenBLAS#4626, fixed by OpenMathLib/OpenBLAS#4631, included in OpenBLAS v0.3.28 |
To verify it's a problem with a buggy OpenBLAS kernel you can fallback to the generic one by exporting the environment variable |
Thanks @giordano! It's good to know the problem and understand the workarounds. |
I ran into an interesting numerical issue in Julia that seems to be related to a bug in LinearAlgebra.
Specifically, I have a vector with norm$\approx 1$ that behaves as expected when using a Linux machine but has various Nan issues on a Mac (Apple Silicon).
I will include a minimal working example below, but there is also more discussion at ITensor/ITensorMPS.jl#110. (I first experienced the issue when using this package but it seems independent of it.)
Here is the vector itself:
Here are some examples of the kinds of things that go wrong on a Mac:
The text was updated successfully, but these errors were encountered: