Skip to content

Chasing after what looks like a strange bug in numpy on M1

Notifications You must be signed in to change notification settings

yairchu/numpy-floats-bug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

numpy bug goose-chase

In this repo I investigated a bug in numpy, where the same calculation np.square(vec) performed again produces different results, and generally things didn't make sense!

Reproduced on Python 3.12.4 numpy=1.26.4 on macOS 14.4.1 M1 Pro.

Didn't repro for me with numpy==2.0.0, nor on Linux/Windows!

To test on your environment:

python -m venv venv
venv/bin/python -m pip install -r requirements.txt

venv/bin/python floating_point_determinism_test.py

The common output I get looks like this:

INCONSISTENT!
Difference: [2.5243549e-29+0.j 0.0000000e+00+0.j 0.0000000e+00+0.j]
Using <module 'numpy' from '...'> version 1.26.4

However with numpy==2.0.0 the valid output comes and looks like this:

Results are consistent.
Difference: [0.+0.j 0.+0.j 0.+0.j]
Using <module 'numpy' from '...'> version 2.0.0

About

Chasing after what looks like a strange bug in numpy on M1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published