-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Upgrade Faiss OSS side to numpy2 #4523
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
Conversation
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
f86a838
to
c73e917
Compare
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
c73e917
to
a012c95
Compare
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
a012c95
to
4e82dc8
Compare
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
4e82dc8
to
a8d5ae6
Compare
This pull request was exported from Phabricator. Differential Revision: D79900113 |
a8d5ae6
to
d5a2a0f
Compare
Summary: Rollback Plan: Differential Revision: D79900113
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
d5a2a0f
to
36ce062
Compare
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
36ce062
to
e2034e1
Compare
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
e2034e1
to
240591c
Compare
This pull request was exported from Phabricator. Differential Revision: D79900113 |
Summary: Rollback Plan: Differential Revision: D79900113
240591c
to
d424a18
Compare
bb0d0af
to
4280ec5
Compare
Summary: Pull Request resolved: facebookresearch#4523 Differential Revision: D79900113
4280ec5
to
b5ac665
Compare
Summary: Pull Request resolved: facebookresearch#4523 Differential Revision: D79900113
117f461
to
5d35899
Compare
Summary: This upgrades OSS Faiss to numpy 2.3.3. I tried to fix issues based on https://numpy.org/devdocs/numpy_2_0_migration_guide.html. There are some issues: - Differential Revision: D79900113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Michael! 🙏
Had a few suggestions on how to build with NumPy 2, which will make the packages more flexible for users installing them
Also these conda-forge NumPy docs may provide additional context
conda/faiss-gpu-cuvs/meta.yaml
Outdated
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64] | ||
- python {{ python }} | ||
- numpy >=1.19,<2 | ||
- numpy =2.3.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be relaxed to just ensure NumPy 2 is picked up
- numpy =2.3.3 | |
- numpy >=2,<3.0a0 |
Though if you need a particular NumPy version, the lower bound could be updated
- numpy =2.3.3 | |
- numpy >=2.3,<3.0a0 |
conda/faiss-gpu-cuvs/meta.yaml
Outdated
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64] | ||
- python {{ python }} | ||
- numpy >=1.19,<2 | ||
- numpy =2.3.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The numpy
package already specifies run_exports
that constrains the numpy
version used at runtime (both in conda-forge and in defaults
)
So this can just be either...
- numpy =2.3.3 | |
- numpy |
...or dropped entirely...
- numpy =2.3.3 |
conda/faiss-gpu-cuvs/meta.yaml
Outdated
test: | ||
requires: | ||
- numpy >=1.19,<2 | ||
- numpy =2.3.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to constrain to NumPy 2 in tests, this could be done like so...
- numpy =2.3.3 | |
- numpy >=2,<3.0a0 |
If you need the lower bound, then you could add it like so
- numpy =2.3.3 | |
- numpy >=2.3,<3.0a0 |
conda/faiss-gpu/meta.yaml
Outdated
- mkl =2023.0 # [x86_64] | ||
- python {{ python }} | ||
- numpy >=1.19,<2 | ||
- numpy =2.3.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would recommend the same changes in this and other files
The NumPy changes also look reasonable to my eyes. Though cc-ing @seberg in case I've missed anything Also NumPy has a migration guide for NumPy 2. Additionally |
Thanks @jakirkham for the review! |
Summary: This upgrades OSS Faiss to numpy 2.3.3. I tried to fix issues based on https://numpy.org/devdocs/numpy_2_0_migration_guide.html. Overall, numpy2 causes some test issues on various platforms/optimization levels. Test changes that are OK: - test_contrib.py: test_float: changing to use item(): this is just the new way of getting the value, like recommended in the migration guide. Test changes that indicate some problem: - test_contrib.py: test_ivf_train_2level: This fails on many platforms (avx2, conda installs). I could not find what the issue was. I had to increase the bounds slightly. - test_index_accuracy.py: test_OIVFPQ: This fails just on AVX512. I had to increase the iterations from 10 to 12. - test_local_search_quantizer.py and test_standalone_codec.py: Some of these break on Windows. Others needed lighter tolerances. Debugging attempts: Especially for test_ivf_train_2level, I tried to unsuccessfully track down what might have changed. I suspected the type promotion change from numpy1 to 2. ``` - np.float32(3) + 3. now returns a float32 when it previously returned a float64. - np.array([3], dtype=np.float32) + np.float64(3) will now return a float64 array. (The higher precision of the scalar is not ignored.) ``` I changed all datasets to be explicitly float64s, and checked for any constants in the code path. No luck. Devmate was less than useless, it was actively a waste of time (as usual...) Differential Revision: D79900113
5d35899
to
0d88108
Compare
Summary: This upgrades OSS Faiss to numpy 2.3.3. I tried to fix issues based on https://numpy.org/devdocs/numpy_2_0_migration_guide.html. Overall, numpy2 causes some test issues on various platforms/optimization levels. Test changes that are OK: - test_contrib.py: test_float: changing to use item(): this is just the new way of getting the value, like recommended in the migration guide. Test changes that indicate some problem: - test_contrib.py: test_ivf_train_2level: This fails on many platforms (avx2, conda installs). I could not find what the issue was. I had to increase the bounds slightly. - test_index_accuracy.py: test_OIVFPQ: This fails just on AVX512. I had to increase the iterations from 10 to 12. - test_local_search_quantizer.py and test_standalone_codec.py: Some of these break on Windows. Others needed lighter tolerances. Debugging attempts: Especially for test_ivf_train_2level, I tried to unsuccessfully track down what might have changed. I suspected the type promotion change from numpy1 to 2. ``` - np.float32(3) + 3. now returns a float32 when it previously returned a float64. - np.array([3], dtype=np.float32) + np.float64(3) will now return a float64 array. (The higher precision of the scalar is not ignored.) ``` I changed all datasets to be explicitly float64s, and checked for any constants in the code path. No luck. Devmate was less than useless, it was actively a waste of time (as usual...) Differential Revision: D79900113
05a9e2f
to
5ee5802
Compare
@mnorris11 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D79900113. |
Summary: This upgrades OSS Faiss to numpy 2.3.3. I tried to fix issues based on https://numpy.org/devdocs/numpy_2_0_migration_guide.html. Overall, numpy2 causes some test issues on various platforms/optimization levels. Test changes that are OK: - test_contrib.py: test_float: changing to use item(): this is just the new way of getting the value, like recommended in the migration guide. Test changes that indicate some problem: - test_contrib.py: test_ivf_train_2level: This fails on many platforms (avx2, conda installs). I could not find what the issue was. I had to increase the bounds slightly. - test_index_accuracy.py: test_OIVFPQ: This fails just on AVX512. I had to increase the iterations from 10 to 12. - test_local_search_quantizer.py and test_standalone_codec.py: Some of these break on Windows. Others needed lighter tolerances. Debugging attempts: Especially for test_ivf_train_2level, I tried to unsuccessfully track down what might have changed. I suspected the type promotion change from numpy1 to 2. ``` - np.float32(3) + 3. now returns a float32 when it previously returned a float64. - np.array([3], dtype=np.float32) + np.float64(3) will now return a float64 array. (The higher precision of the scalar is not ignored.) ``` I changed all datasets to be explicitly float64s, and checked for any constants in the code path. No luck. Devmate was less than useless, it was actively a waste of time (as usual...) Differential Revision: D79900113
5ee5802
to
ef1b1a7
Compare
Summary: This upgrades OSS Faiss to numpy 2.3.3. I tried to fix issues based on https://numpy.org/devdocs/numpy_2_0_migration_guide.html. Overall, numpy2 causes some test issues on various platforms/optimization levels. Test changes that are OK: - test_contrib.py: test_float: changing to use item(): this is just the new way of getting the value, like recommended in the migration guide. Test changes that indicate some problem: - test_contrib.py: test_ivf_train_2level: This fails on many platforms (avx2, conda installs). I could not find what the issue was. I had to increase the bounds slightly. - test_index_accuracy.py: test_OIVFPQ: This fails just on AVX512. I had to increase the iterations from 10 to 12. - test_local_search_quantizer.py and test_standalone_codec.py: Some of these break on Windows. Others needed lighter tolerances. Debugging attempts: Especially for test_ivf_train_2level, I tried to unsuccessfully track down what might have changed. I suspected the type promotion change from numpy1 to 2. ``` - np.float32(3) + 3. now returns a float32 when it previously returned a float64. - np.array([3], dtype=np.float32) + np.float64(3) will now return a float64 array. (The higher precision of the scalar is not ignored.) ``` I changed all datasets to be explicitly float64s, and checked for any constants in the code path. No luck. Devmate was less than useless, it was actively a waste of time (as usual...) Differential Revision: D79900113
ef1b1a7
to
afda341
Compare
Looks fine, cannot say quickly why the item calls are needed, but probably OK. Tolerance changes may mean that some internal computation previously went to float64 and now stay at float32, I guess. But that is presumably also fine. |
This pull request has been merged in 4fab13c. |
Happy to help 🙂 Thanks Michael! 🙏 If you run into issues, please let me know. Would be interested in taking a look at those when they come up |
# Ensure starting packages are from conda-forge. | ||
conda list --show-channel-urls | ||
conda update -y -q conda | ||
conda install -y -q "conda<=25.07" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing this is due to an issue with conda
version 25.09
, do you have more details on the issue seen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, seems like it just surfaced. Prior runs used 25.07 so I just pinned there.
https://github.com/facebookresearch/faiss/actions/runs/18175470029/job/51741940955
The last logs are:
Error while loading conda entry point: conda-libmamba-solver (cannot import name 'Spinner' from 'conda.common.io' (/home/runner/miniconda3/lib/python3.12/site-packages/conda/common/io.py))
CondaValueError: You have chosen a non-default solver backend (libmamba) but it was not recognized. Choose one of: classic
Error: Process completed with exit code 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Michael! 🙏
Think I can see what is going on. Have filed an upstream issue: conda/conda#15287
Also to help with debugging future Conda or conda-forge issues, have suggested a few commands we can add to CI in issue: #4599
This would help in providing additional detail when debugging. Additionally this would help in upstream bug reports
Differential Revision: D79900113
This upgrades OSS Faiss to numpy 2.3.3. I tried to fix issues based on https://numpy.org/devdocs/numpy_2_0_migration_guide.html.
Overall, numpy2 causes some test issues on various platforms/optimization levels.
Test changes that are OK:
Test changes that indicate some problem:
Debugging attempts: Especially for test_ivf_train_2level, I tried to unsuccessfully track down what might have changed. I suspected the type promotion change from numpy1 to 2.
I changed all datasets to be explicitly float64s, and checked for any constants in the code path. No luck.