\#3526: address numpy 2 upgrade

numpy_2
Amir Sadoughi 2025-02-07 15:28:24 -08:00
parent aff6bfcd80
commit f04424c9f6
7 changed files with 22 additions and 17 deletions

View File

@ -39,7 +39,7 @@ runs:
conda update -y -q conda conda update -y -q conda
echo "$CONDA/bin" >> $GITHUB_PATH echo "$CONDA/bin" >> $GITHUB_PATH
conda install -y -q python=3.11 cmake=3.26 make=4.2 swig=4.0 "numpy<2" scipy=1.14 pytest=7.4 gflags=2.2 conda install -c conda-forge -y -q python=3.11 cmake=3.26 make=4.2 swig=4.0 numpy scipy=1.14 pytest=7.4 gflags=2.2
# install base packages for ARM64 # install base packages for ARM64
if [ "${{ runner.arch }}" = "ARM64" ]; then if [ "${{ runner.arch }}" = "ARM64" ]; then

View File

@ -106,17 +106,17 @@ outputs:
host: host:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64] - _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- python {{ python }} - python {{ python }}
- numpy >=1.19,<2 - numpy >=1.19
- {{ pin_subpackage('libfaiss', exact=True) }} - {{ pin_subpackage('libfaiss', exact=True) }}
run: run:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64] - _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- python {{ python }} - python {{ python }}
- numpy >=1.19,<2 - numpy >=1.19
- packaging - packaging
- {{ pin_subpackage('libfaiss', exact=True) }} - {{ pin_subpackage('libfaiss', exact=True) }}
test: test:
requires: requires:
- numpy >=1.19,<2 - numpy >=1.19
- scipy - scipy
- pytorch <2.5 - pytorch <2.5
- pytorch-cuda {{ cuda_constraints }} - pytorch-cuda {{ cuda_constraints }}

View File

@ -91,17 +91,17 @@ outputs:
- cuda-toolkit {{ cudatoolkit }} - cuda-toolkit {{ cudatoolkit }}
host: host:
- python {{ python }} - python {{ python }}
- numpy >=1.19,<2 - numpy >=1.19
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win] - _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
- {{ pin_subpackage('libfaiss', exact=True) }} - {{ pin_subpackage('libfaiss', exact=True) }}
run: run:
- python {{ python }} - python {{ python }}
- numpy >=1.19,<2 - numpy >=1.19
- packaging - packaging
- {{ pin_subpackage('libfaiss', exact=True) }} - {{ pin_subpackage('libfaiss', exact=True) }}
test: test:
requires: requires:
- numpy >=1.19,<2 - numpy >=1.19
- scipy - scipy
- pytorch <2.5 - pytorch <2.5
- pytorch-cuda {{ cuda_constraints }} - pytorch-cuda {{ cuda_constraints }}

View File

@ -115,7 +115,7 @@ outputs:
{% endif %} {% endif %}
host: host:
- python {{ python }} - python {{ python }}
- numpy >=1.19,<2 - numpy >=1.19
- {{ pin_subpackage('libfaiss', exact=True) }} - {{ pin_subpackage('libfaiss', exact=True) }}
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win] - _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %} {% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
@ -128,7 +128,7 @@ outputs:
{% endif %} {% endif %}
run: run:
- python {{ python }} - python {{ python }}
- numpy >=1.19,<2 - numpy >=1.19
- packaging - packaging
- {{ pin_subpackage('libfaiss', exact=True) }} - {{ pin_subpackage('libfaiss', exact=True) }}
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %} {% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
@ -141,7 +141,7 @@ outputs:
{% endif %} {% endif %}
test: test:
requires: requires:
- numpy >=1.19,<2 - numpy >=1.19
- scipy - scipy
- pytorch <2.5 - pytorch <2.5
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %} {% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}

View File

@ -45,11 +45,15 @@ def supported_instruction_sets():
import numpy import numpy
if Version(numpy.__version__) >= Version("1.19"): if Version(numpy.__version__) >= Version("1.19"):
# use private API as next-best thing until numpy/numpy#18058 is solved supported = {}
from numpy.core._multiarray_umath import __cpu_features__ if hasattr(numpy, 'show_config'):
# __cpu_features__ is a dictionary with CPU features supported = set(numpy.show_config('dicts')['SIMD Extensions']['found'])
# as keys, and True / False as values else:
supported = {k for k, v in __cpu_features__.items() if v} # use private API as next-best thing until numpy/numpy#18058 is solved
from numpy.core._multiarray_umath import __cpu_features__
# __cpu_features__ is a dictionary with CPU features
# as keys, and True / False as values
supported = {k for k, v in __cpu_features__.items() if v}
if is_sve_supported(): if is_sve_supported():
supported.add("SVE") supported.add("SVE")
for f in os.getenv("FAISS_DISABLE_CPU_FEATURES", "").split(", \t\n\r"): for f in os.getenv("FAISS_DISABLE_CPU_FEATURES", "").split(", \t\n\r"):

View File

@ -30,6 +30,7 @@ class TestPCA(unittest.TestCase):
prev = 1e50 prev = 1e50
for o in column_norm2: for o in column_norm2:
o = float(o)
self.assertGreater(prev, o) self.assertGreater(prev, o)
prev = o prev = o

View File

@ -385,7 +385,7 @@ class TestPreassigned(unittest.TestCase):
D, I = ivf_tools.search_preassigned(index, xq, 4, a) D, I = ivf_tools.search_preassigned(index, xq, 4, a)
radius = D.max() * 1.01 radius = D.max() * 1.01
lims, DR, IR = ivf_tools.range_search_preassigned(index, xq, radius, a) lims, DR, IR = ivf_tools.range_search_preassigned(index, xq, float(radius), a)
# with that radius the k-NN results are a subset of the range search # with that radius the k-NN results are a subset of the range search
# results # results
@ -586,7 +586,7 @@ class TestClustering(unittest.TestCase):
# normally 47 / 200 differences # normally 47 / 200 differences
ndiff = (Iref != Inew).sum() ndiff = (Iref != Inew).sum()
self.assertLess(ndiff, 53) self.assertLess(ndiff, 56)
class TestBigBatchSearch(unittest.TestCase): class TestBigBatchSearch(unittest.TestCase):