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
np.linalg.eigvals() unexpected results on ARM CPUs #18422
(All values up until the eigvals function call are equal on both machines)
On the ARM based CPU, you will see the following output: [-0.14294258 -0.05014252 -0.06678331 -0.06036967 0.01308302 -0.29849543 0.23065051]
On the x86 based CPU, you will see the following output: [-0.35561591+0.14999412j -0.35561591-0.14999412j -0.10977392+0.35797579j -0.10977392-0.35797579j 0.15723786+0.31047243j 0.15723786-0.31047243j 0.24130395+0.j ]
There is no stack trace or error thrown.
Error:
I believe that the eigenvalues produced on the ARM CPU are incorrect, as they do not include complex conjugate pairs (with real number input). It's been a while since I've studied linear algebra, but I believe this to be the case.
I found this error originally due to an issue I encountered with the numpy_financial package, which calls the np.linalg.eigvals function from the irr function. More information on the issue over there: numpy/numpy-financial#37
NumPy/Python version information:
Both machines running Ubuntu 20.04 LTS, kernel 5.4.0-1047-aws. Python version 3.8.5. Numpy version 1.20.1.
If all has gone well, you should get a result of 0.03603774756546341. If it's been installed incorrectly, you'll get a value of 0.08389095415117676.
How should we best inform the ARM user base of this issue? Should we include some information on the numpy install guide (https://numpy.org/install)? Currently there's no information there about ARM based installations, and installing numpy following the guide there on ARM CPUs is susceptible to reproducing the issue listed above.
I could not reproduce on an ARM64 machine. I used a virtualenv instead of installing via sudo pip3, which is really to be avoided. After deleting line 3 of your script, and then doing
I got the correct complex output. I am confused why updating the system openblas library had any effect: we ship our own OpenBLAS in the wheel. When you do ldd $(venv3/bin/python -c "import numpy; print(numpy.core._multiarray_umath.__file__)") you should see
that it is using numpy from inside the virtualenv
that it links to numpy.libs/libopenblasp-r0-3c76c92e.3.13.dev.so, which is OpenBLAS 0.3.13 with a mangled name.
Are you sure you are using the pip-installed numpy and not the system one?
Graviton is a custom chip from Amazon that AFAIK is only available on AWS. It does however look like pip will install aarch64 manylinux wheels from PyPI. And apparently OpenBLAS has an issue with the Graviton chip.
I'm seeing the same problem with numpy 1.20.3 using GCC 10.3, binutils 2.36.1, Python 3.9.5, OpenBLAS 0.3.15.
I can reproduce the issue with the np.linalg.eigvals test script provided by @millettmb: on Intel and AMD systems I'm getting the correct result ([[-0.35561591...), likewise on POWER9.
On an AWS Graviton2 instance (c6gd.2xlarge), I'm getting the wrong result ([-0.14294258 ...).
54 tests in the numpy test suite fail (see numpy-1.20.3_tests_graviton2.txt), most of them with LinAlgError: Eigenvalues did not converge or LinAlgError: SVD did not converge in Linear Least Squares (not sure if those could have the same underlying cause?).
The output also includes messages like this 51 times:
** On entry to DLASCL parameter number 4 had an illegal value
(sometimes it's parameter number 5)
Thanks to linking numpy with FlexiBLAS I can easily switch to a different BLAS library. When using BLIS 0.8.1, I'm not seeing the problem: the np.linalg.eigvals test case produces the correct result, and the numpy test suite passes fully.
That tells me the problem is in OpenBLAS 0.3.15.
Graviton2 (NEOVERSEN1 target in OpenBLAS) is using the same GEMM kernels as most other supported ARMV8 cpus (originally written for ThunderX2T99 and provided by someone from Cavium in 2017/18). Unfortunately it is not covered by any of the current CI setups, I will need to look into getting AWS instances set up. The DLASCL errors suggest that NaNs are generated somewhere - as the input seems to be valid, perhaps things are getting miscompiled ?
@martin-frbg I can put you in touch with somebody at AWS who may be able to provide some free credits for testing on Graviton2, send me an email if you're interested.
@boegel thx - I belatedly remembered that there is/was Graviton2 access on Travis so if/while that is still avaiable I'll try to reproduce the issue there first. (I do notice that the regular LAPACK testsuite run does not look particularly bad there)
First, the issue appears in (neoverse-n1) processors, while other processors such as (Cortex-A53) do not show any errors. It seems the errors occur if one of the following SIMD features is available (asimdhp asimdrdm asimddp).
Secondly, By testing LAPACKE_dgeev with args (LAPACK_ROW_MAJOR, 'N', 'N', ...) on Cortex-A53 returned zero while neoverse-n1 was returning the number of dimensions.
Third, I tried to rebuild OpenBLAS with option DYNAMIC_ARCH on different versions of GCC but I was not able to reproduce test errors on neoverse-n1 and LAPACKE_dgeev was working just fine on both processors.
Eventually, I think the problem is not general, and it might be specific to the compiler who built it or, with the compiler build options. I wonder if someone could provide me the version of the compiler that built the library and the build log so I could be able to reproduce the errors.
@martin-frbg TravisCI does support Graviton as does CircleCI. There are instructions for using it here. I'm also happy to help get you access to a Graviton instance directly.
Similarly, we're happy to send a PR for enabling testing with one of those CI services on Arm systems.
I was misled by the OpenBLAS Ci job still using travis-ci.org rather than .com (and the "Graviton" job silently running on Intel as a consequence), and I still need Xianyi to make administrative changes to CI setups (like initiating the migration to travis-ci.com) as the github project is still "owned" by him alone.
There is an elusive single failure in REAL on most systems (can't remember right now what it is), usually accompanied by a single failure in the corresponding COMPLEX function - as far as I can tell, these may be actual inaccuracies in the respective tests.
The carnage for GENERIC (I assume ARMV8 ?) looks like something fundamental went wrong - this should be almost all plain C kernels. I'll see if I can reproduce it on local hardware. (Reporting more numerical errors than tests run does not make much sense either, I wonder if the python script just went haywire)
Should be nowhere near as bad (it is not in any of the CI runs, but I do run it semi-regularly locally). And the one in REAL on Graviton should be STFSM I think - if it is what I call the "usual" one... would you happen to have the testing_results.txt available ?
Tried to replicate the issue with TARGET=ARMV8 and they all passed but one. I'm trying to figure out what i did the first time around, but sorry about the noise.
Both ARMV8 and the NEOVERSEN1 target fail on this test.
ARMV8 output:
*** Error(s) or Failure(s) while testing STFSM ***
Failure in STFSM, CFORM='T', SIDE='L', UPLO='U', TRANS='T', DIAG='N', M= 50, N = 50, test= 42.299
STFSM auxiliary routine: 1 out of 7776 tests failed to pass the threshold
Neoverse N1 output:
*** Error(s) or Failure(s) while testing STFSM ***
Failure in STFSM, CFORM='T', SIDE='L', UPLO='U', TRANS='T', DIAG='N', M= 50, N = 50, test= 33.319
STFSM auxiliary routine: 1 out of 7776 tests failed to pass the threshold
Most likely culprit would be a mismatch of gcc and (lib)gfortran, that would usually be blowing up left and right due to ABI mismatch. I can discuss the STFSM thing with the Reference-LAPACK people if you like, but IIIRC from the documentation of the tests and earlier discussions, a serious test failure would be orders of magnitude away from the threshold, not something like 42 instead of an expected 20 (again IIRC)
The original reporter did not update with new information, but another user did confirm the issue is fixed. I will close the issue, please reopen if I am mistaken.
Activity
millettmb commentedon Feb 16, 2021
So after a bit more tinkering, I've found out a way to solve this issue. You'll need to follow along with the guide here: https://github.com/aws/aws-graviton-getting-started/blob/master/python.md.
numpyinstalled throughpip, uninstall it usingpip3 uninstall numpynumpy_financialif you haven't already, this will use thenumpyversion we have just installedIf all has gone well, you should get a result of
0.03603774756546341. If it's been installed incorrectly, you'll get a value of0.08389095415117676.How should we best inform the ARM user base of this issue? Should we include some information on the
numpyinstall guide (https://numpy.org/install)? Currently there's no information there about ARM based installations, and installingnumpyfollowing the guide there on ARM CPUs is susceptible to reproducing the issue listed above.millettmb commentedon Feb 16, 2021
I've found that there is a specific repo for the
numpywebsite, and have since moved the discussion to the issue listed here numpy/numpy.org#401.mattip commentedon Feb 16, 2021
I could not reproduce on an ARM64 machine. I used a virtualenv instead of installing via
sudo pip3, which is really to be avoided. After deleting line 3 of your script, and then doingI got the correct complex output. I am confused why updating the system openblas library had any effect: we ship our own OpenBLAS in the wheel. When you do
ldd $(venv3/bin/python -c "import numpy; print(numpy.core._multiarray_umath.__file__)")you should seenumpy.libs/libopenblasp-r0-3c76c92e.3.13.dev.so, which is OpenBLAS 0.3.13 with a mangled name.Are you sure you are using the pip-installed numpy and not the system one?
rgommers commentedon Apr 5, 2021
Graviton is a custom chip from Amazon that AFAIK is only available on AWS. It does however look like
pipwill installaarch64manylinux wheels from PyPI. And apparently OpenBLAS has an issue with the Graviton chip.I don't think it's reasonable for us to have specific install instructions for an AWS-specific chip on https://numpy.org/install/, especially since our wheels are supposed to just work. There is something really broken here though it looks like.
rgommers commentedon Apr 5, 2021
@millettmb if you could try the following, that'd be helpful:
pip install numpy(use a separate virtualenv if needed to not mess up your working install).python -c "import numpy as np; np.test()"and report the output.boegel commentedon May 24, 2021
I'm seeing the same problem with numpy 1.20.3 using GCC 10.3, binutils 2.36.1, Python 3.9.5, OpenBLAS 0.3.15.
I can reproduce the issue with the
np.linalg.eigvalstest script provided by @millettmb: on Intel and AMD systems I'm getting the correct result ([[-0.35561591...), likewise on POWER9.On an AWS Graviton2 instance (
c6gd.2xlarge), I'm getting the wrong result ([-0.14294258 ...).54 tests in the numpy test suite fail (see numpy-1.20.3_tests_graviton2.txt), most of them with
LinAlgError: Eigenvalues did not convergeorLinAlgError: SVD did not converge in Linear Least Squares(not sure if those could have the same underlying cause?).The output also includes messages like this 51 times:
(sometimes it's
parameter number 5)Thanks to linking numpy with FlexiBLAS I can easily switch to a different BLAS library. When using BLIS 0.8.1, I'm not seeing the problem: the
np.linalg.eigvalstest case produces the correct result, and the numpy test suite passes fully.That tells me the problem is in OpenBLAS 0.3.15.
Maybe @martin-frbg has any ideas here?
martin-frbg commentedon May 24, 2021
Graviton2 (NEOVERSEN1 target in OpenBLAS) is using the same GEMM kernels as most other supported ARMV8 cpus (originally written for ThunderX2T99 and provided by someone from Cavium in 2017/18). Unfortunately it is not covered by any of the current CI setups, I will need to look into getting AWS instances set up. The DLASCL errors suggest that NaNs are generated somewhere - as the input seems to be valid, perhaps things are getting miscompiled ?
mattip commentedon May 24, 2021
@seiko2plus any thoughts?
boegel commentedon May 24, 2021
@martin-frbg I can put you in touch with somebody at AWS who may be able to provide some free credits for testing on Graviton2, send me an email if you're interested.
martin-frbg commentedon May 24, 2021
@boegel thx - I belatedly remembered that there is/was Graviton2 access on Travis so if/while that is still avaiable I'll try to reproduce the issue there first. (I do notice that the regular LAPACK testsuite run does not look particularly bad there)
seiko2plus commentedon May 26, 2021
First, the issue appears in (neoverse-n1) processors, while other processors such as (Cortex-A53) do not show any errors. It seems the errors occur if one of the following SIMD features is available (asimdhp asimdrdm asimddp).
Secondly, By testing
LAPACKE_dgeevwith args (LAPACK_ROW_MAJOR, 'N', 'N', ...) onCortex-A53returned zero whileneoverse-n1was returning the number of dimensions.Third, I tried to rebuild OpenBLAS with option
DYNAMIC_ARCHon different versions of GCC but I was not able to reproduce test errors onneoverse-n1andLAPACKE_dgeevwas working just fine on both processors.Eventually, I think the problem is not general, and it might be specific to the compiler who built it or, with the compiler build options. I wonder if someone could provide me the version of the compiler that built the library and the build log so I could be able to reproduce the errors.
7 remaining items
ggouaillardet commentedon Jun 14, 2021
yeah, I spotted some inline assembly that does not restore a register as it should ...
ggouaillardet commentedon Jun 14, 2021
fixed one bug ... I am now checking if there are some remaining issues
arm64: add the missing d9 register to the clobber list
AGSaidi commentedon Jun 16, 2021
@martin-frbg TravisCI does support Graviton as does CircleCI. There are instructions for using it here. I'm also happy to help get you access to a Graviton instance directly.
Similarly, we're happy to send a PR for enabling testing with one of those CI services on Arm systems.
martin-frbg commentedon Jun 16, 2021
I was misled by the OpenBLAS Ci job still using travis-ci.org rather than .com (and the "Graviton" job silently running on Intel as a consequence), and I still need Xianyi to make administrative changes to CI setups (like initiating the migration to travis-ci.com) as the github project is still "owned" by him alone.
AGSaidi commentedon Jun 16, 2021
I ran
make lapack-testmanually having built both the NEOVERSEN1 target and the ARMV8 generic target on a 64c graviton2 system.For the n1 target there is one failure:
martin-frbg commentedon Jun 16, 2021
There is an elusive single failure in REAL on most systems (can't remember right now what it is), usually accompanied by a single failure in the corresponding COMPLEX function - as far as I can tell, these may be actual inaccuracies in the respective tests.
The carnage for GENERIC (I assume ARMV8 ?) looks like something fundamental went wrong - this should be almost all plain C kernels. I'll see if I can reproduce it on local hardware. (Reporting more numerical errors than tests run does not make much sense either, I wonder if the python script just went haywire)
AGSaidi commentedon Jun 16, 2021
Correct:
martin-frbg commentedon Jun 16, 2021
Should be nowhere near as bad (it is not in any of the CI runs, but I do run it semi-regularly locally). And the one in REAL on Graviton should be STFSM I think - if it is what I call the "usual" one... would you happen to have the testing_results.txt available ?
AGSaidi commentedon Jun 16, 2021
Tried to replicate the issue with
TARGET=ARMV8and they all passed but one. I'm trying to figure out what i did the first time around, but sorry about the noise.Both ARMV8 and the NEOVERSEN1 target fail on this test.
ARMV8 output:
Neoverse N1 output:
martin-frbg commentedon Jun 16, 2021
Most likely culprit would be a mismatch of gcc and (lib)gfortran, that would usually be blowing up left and right due to ABI mismatch. I can discuss the STFSM thing with the Reference-LAPACK people if you like, but IIIRC from the documentation of the tests and earlier discussions, a serious test failure would be orders of magnitude away from the threshold, not something like 42 instead of an expected 20 (again IIRC)
mattip commentedon Jul 27, 2021
@millettmb could you update this issue after trying the latest release 1.21.1 with OpenBLAS v0.3.17?
boegel commentedon Sep 8, 2021
For me the OpenBLAS patch by @ggouaillardet fixed the problems we were seeing with the numpy test suite on
aarch64/Graviton2, cfr. easybuilders/easybuild-easyconfigs#11959mattip commentedon May 7, 2022
The original reporter did not update with new information, but another user did confirm the issue is fixed. I will close the issue, please reopen if I am mistaken.