-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
make setup.py win+avx2 compatible #1682
Conversation
f171337
to
3e44344
Compare
3e44344
to
7322705
Compare
ded199e
to
b67bbe2
Compare
The failing test seems to be flaky. |
For this, I'd be more inclined to keep the CMake config as is, and just deal with it in |
Understandable. I'd suggest to keep the changes in |
78a95d9
to
87426b6
Compare
Summary: This patch is to provide log information in case of failing to load the AVX2-enabled lib, and also to log the successful loading of the libraries. Otherwise, the programmatic detection of which library was loaded also needs to take into account which other log statements were executed, if the original import failed due to an exception, cf. the tests in conda-forge/faiss-split-feedstock#27 Finally, this reduces the number of import statements by one - one non-AVX2 fallback is enough. Related to #1600, #1680, #1681, #1682. Pull Request resolved: #1683 Reviewed By: mdouze Differential Revision: D26424333 Pulled By: beauby fbshipit-source-id: 16beddec7e0c098b913a7f5420cbb02d1cf515ad
87426b6
to
5ce2103
Compare
@beauby |
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.
@beauby has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Trying to compile windows for AVX2 in conda-forge/faiss-split-feedstock#27 (after #1600) surfaced a bunch of things (#1680, #1681, #1682), but the most voluminous problem was MSVC being much worse at dealing with operator overloads and casts around `__m128` / `__m256`. This lead to loads of errors that looked as follows: ``` [...]\faiss\utils\distances_simd.cpp(411): error C2676: binary '+=': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(440): error C2676: binary '-': '__m256' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(441): error C2676: binary '*': 'const __m256' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(446): error C2676: binary '+=': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(451): error C2676: binary '-': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(452): error C2676: binary '*': 'const __m128' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(459): error C2676: binary '-': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(460): error C2676: binary '*': '__m128' does not define this operator or a conversion to a type acceptable to the predefined operator [...]\faiss\utils\distances_simd.cpp(471): error C2440: '<function-style-cast>': cannot convert from '__m256i' to '__m256' ``` I've followed https://software.intel.com/sites/landingpage/IntrinsicsGuide/ to try to replace everything correctly, but this will surely require close review, because I'm not sure how well these code-paths are checked by the test suite. In any case, with the commits from #1600 #1666 #1680 #1681 #1682, I was able to build `libfaiss` & `faiss` for AVX2 on windows (while remaining "green" on linux/osx, both with & without AVX2). Sidenote: the issues in the last commit (26fc7cf) were uncovered by adding the `__SSE3__` compat macros in #1681. Pull Request resolved: #1684 Test Plan: buck test //faiss/tests/... Reviewed By: beauby Differential Revision: D26454443 Pulled By: mdouze fbshipit-source-id: 70df0818e357f1ecea6a056d619618df0236e0eb
While working on conda-forge/faiss-split-feedstock#27, it turned out I needed
to patch
setup.py
anyway. In order to unify how the extension of the built lib is set, I fell backto another patch that would/will become necessary if faiss ever wants to support PyPy
(see discussion in conda-forge/faiss-split-feedstock#22).
It would be nice if this was done natively by CMake, but as far as I can tell from
https://gitlab.kitware.com/cmake/cmake/-/issues/21070, cmake is not likely to do that right away.
I didn't particularly expect this patch to be upstreamed (especially if there is no interest for PyPy support, for example),
but @beauby invited
me to post it so here goes (plus necessary adaptations to the conda recipes)
Related to #1600, #1680, #1681
PS. I thought about using
logger.INFO
in case of an import failure for AVX2, but since it's a setup file,I thought
print
would actually be more useful. Happy to change or remove if desired.