Skip to content
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

Lapack heevd seems to return wrong values on osxarm64_accelerate #85

Open
1 task done
kmnhan opened this issue Mar 1, 2022 · 0 comments
Open
1 task done

Lapack heevd seems to return wrong values on osxarm64_accelerate #85

kmnhan opened this issue Mar 1, 2022 · 0 comments

Comments

@kmnhan
Copy link

kmnhan commented Mar 1, 2022

To reproduce, i ran

conda install -c conda-forge numpy "libblas=*=*accelerate"

in a new environment. Then,

import numpy as np
a = np.array([[5+2j, 9-2j],
              [9+2j, 2-1j]])
np.linalg.eigh(a)

returns

(array([-5.84077085, 12.84077085]), 
 array([[-0.64784785-0.64784785j, -0.76176975-0.34206291j],
        [ 0.57837872+0.90888084j, -0.54137349-0.55025032j]]))

where the eigenvectors are different from those returned by other BLAS implementations. In the case of scipy, which uses evr by default instead of evd, returns the correct eigenvectors; scipy.linalg.eigh(a) returns

(array([-5.84077085, 12.84077085]),
 array([[-0.64784785+0.j        , -0.76176975+0.j        ],
        [ 0.74362978+0.16525106j, -0.63242069-0.14053793j]]))

By specifying the LAPACK driver with scipy.linalg.eigh(a, driver='evd'), I again obtain the same result as numpy.

After some testing with the LAPACK calls scipy.linalg.lapack.zheevr and scipy.linalg.lapack.zheevd, zheevd does not seem to return correct values.


Environment (conda list):
$ conda list
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2021.10.8            h4653dfc_0    conda-forge
libblas                   3.9.0           13_osxarm64_accelerate    conda-forge
libcblas                  3.9.0           13_osxarm64_accelerate    conda-forge
libcxx                    12.0.1               h168391b_1    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgfortran               5.0.0.dev0      11_0_1_hf114ba7_23    conda-forge
libgfortran5              11.0.1.dev0         hf114ba7_23    conda-forge
liblapack                 3.9.0           13_osxarm64_accelerate    conda-forge
libzlib                   1.2.11            hee7b306_1013    conda-forge
llvm-openmp               13.0.1               hf3c4609_0    conda-forge
ncurses                   6.3                  hc470f4d_0    conda-forge
numpy                     1.22.2          py310h567df17_0    conda-forge
openssl                   3.0.0                h3422bc3_2    conda-forge
pip                       22.0.3             pyhd8ed1ab_0    conda-forge
python                    3.10.2          h38ef502_3_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge
readline                  8.1                  hedafd6a_0    conda-forge
scipy                     1.8.0           py310h6ecf4ae_1    conda-forge
setuptools                60.9.3          py310hbe9552e_0    conda-forge
sqlite                    3.37.0               h72a2b83_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.2.5                h642e427_1    conda-forge
zlib                      1.2.11            hee7b306_1013    conda-forge

Details about conda and system ( conda info ):
$ conda info
     active environment : np_test
    active env location : /Users/khan/miniforge3/envs/np_test
            shell level : 4
       user config file : /Users/khan/.condarc
 populated config files : /Users/khan/miniforge3/.condarc
                          /Users/khan/.condarc
          conda version : 4.11.0
    conda-build version : not installed
         python version : 3.9.7.final.0
       virtual packages : __osx=12.2.1=0
                          __unix=0=0
                          __archspec=1=arm64
       base environment : /Users/khan/miniforge3  (writable)
      conda av data dir : /Users/khan/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/khan/miniforge3/pkgs
                          /Users/khan/.conda/pkgs
       envs directories : /Users/khan/miniforge3/envs
                          /Users/khan/.conda/envs
               platform : osx-arm64
             user-agent : conda/4.11.0 requests/2.26.0 CPython/3.9.7 Darwin/21.3.0 OSX/12.2.1
                UID:GID : 501:20
             netrc file : None
           offline mode : False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant