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
irr() providing different results on ARM and x86 CPUs #37
Hi all,
I've got two machines set up, my local development machine (i7-10510U), and an AWS EC2 instance (c6g.16xlarge, Arm-based AWS Graviton2). On both machines, the same version of Python (3.8.5) and numpy_financial (1.0.0) are installed. Both machines are running Ubuntu 20.04 LTS, with my local machine running kernel 5.8.0-43-generic and the AWS machine running 5.4.0-1037-aws.
On my local development machine (x86), the result given is 0.03603774756546363, whereas on the AWS EC2 Arm-based instance, the result given is 0.08389095415117676. I've also run the same code on an AWS EC2 t2.medium instance (x86 based) and was given the same result as my local development machine (0.036...)
If I provide the same input into the MS Excel IRR function, the result given is 3.6%, matching the x86 outputs. This leads me to believe that there's an issue occurring with the ARM package.
Bit of a further look into this, I believe it's potentially due to the _roots function, in particular the call to eigenvalues = np.linalg.eigvals(A). With the input of [ 2, 3, 4, 5, 4, 3, 2, -20] into _roots, we get the following outputs on ARM and x86:
It's been a little while since I last looked at eigenvalues, but I believe that the x86 output here is correct, and the ARM output is incorrect due to the non-inclusion of complex conjugate pairs.
Given that this now appears to be an issue with the numpy package itself, I've created an issue at the numpy repo, and am linking it here: numpy/numpy#18422. I'm not too sure on what the etiquette is on listing issues with dependent packages, so I'll leave this issue here for now in case anyone else has the same issue.
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.
I'll mark this as closed, but I'm not too sure how best to inform the ARM user base of this problem. I'll leave the issue in the numpy package open for now, and as for suggestions there.
Activity
millettmb commentedon Feb 16, 2021
Bit of a further look into this, I believe it's potentially due to the
_rootsfunction, in particular the call toeigenvalues = np.linalg.eigvals(A). With the input of[ 2, 3, 4, 5, 4, 3, 2, -20]into_roots, we get the following outputs on ARM and x86:ARM:
x86:
It's been a little while since I last looked at eigenvalues, but I believe that the x86 output here is correct, and the ARM output is incorrect due to the non-inclusion of complex conjugate pairs.
Given that this now appears to be an issue with the
numpypackage itself, I've created an issue at thenumpyrepo, and am linking it here: numpy/numpy#18422. I'm not too sure on what the etiquette is on listing issues with dependent packages, so I'll leave this issue here for now in case anyone else has the same issue.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.I'll mark this as closed, but I'm not too sure how best to inform the ARM user base of this problem. I'll leave the issue in the
numpypackage open for now, and as for suggestions there.