JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.61k stars 5.48k forks source link

Regression: Eigenvalue computation returns empty results for large symmetric matrices in Julia 1.11.0-beta1 #54517

Closed singularitti closed 5 months ago

singularitti commented 5 months ago

I encountered an issue when computing the eigenvalues and eigenvectors of a large matrix using Julia 1.11.0-beta1. The same code works fine in Julia 1.10.3 but returns empty results in the beta version. This appears to be a regression introduced in the beta version.

Steps to reproduce

Here is the simplified code that sets up the Hamiltonian matrix and attempts to compute its eigenvalues and eigenvectors:

using LinearAlgebra

function setup(N, a=0.01)
    A = zeros(Float64, N, N)
    for i in 1:N
        for j in 1:N
            A[i, j] = exp(-a * (i - j)^2)
        end
    end
    return A
end

N = 1600
A = setup(N)

# Compute the eigenvalues and eigenvectors
eigen(A)

This issue does not only occur when N = 1600. On my computer, this happens when N >= 790.

Expected behavior

The code should return a non-empty list of eigenvalues and a corresponding matrix of eigenvectors.

Actual behavior

julia> eigen(A)
Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}}
values:
Float64[]
vectors:
1600×0 Matrix{Float64}

Additional information

julia> versioninfo()
Julia Version 1.11.0-beta1
Commit 08e1fc0abb9 (2024-04-10 08:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
singularitti commented 5 months ago

Probably related to https://github.com/JuliaLang/julia/issues/54412, but not limited to Hermitian matrices.

dkarrasch commented 5 months ago

I can't reproduce:

julia> versioninfo()
Julia Version 1.11.0-beta1
Commit 08e1fc0abb9 (2024-04-10 08:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × 13th Gen Intel(R) Core(TM) i5-1340P
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, goldmont)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
singularitti commented 5 months ago

I suppose it is a macOS Julia problem? It's not only me who has this problem: https://julialang.slack.com/archives/C6A044SQH/p1716231131622339?thread_ts=1716230793.618259

gbaraldi commented 5 months ago

This seems to have gotten fixed in https://github.com/JuliaLang/julia/pull/54237. Which means it's a backport away of being in fine in 1.11