Skip to content

Commit e8a20a1

Browse files
Michael Norrisfacebook-github-bot
Michael Norris
authored andcommitted
Migration off defaults to conda-forge channel (#4126)
Summary: Good resource on overriding channels to make sure we aren't using `defaults`:https://stackoverflow.com/questions/67695893/how-do-i-completely-purge-and-disable-the-default-channel-in-anaconda-and-switch Explanation of changes: - - changed to miniforge from miniconda: this ensures we only pull in from conda-defaults when creating the environment - architecture: ARM64 and aarch64 are the same thing. But there is no miniforge package for ARM64, so we need to make it check for aarch64 instead. However, mac breaks this rule, and does have macOS-arm64! So there is a conditional for mac to use arm64. https://github.com/conda-forge/miniforge/releases/ - mkl 2022.2.1 change: conda-forge and defaults have completely different dependencies. Defaults required intel-openmp, but now on conda-forge, mkl 2023.1 or higher requires llvm-openmp >=14.0.6, but this is incompatible with the pytorch build <2.5 which requires llvm-openmp<14.0. We would need to upgrade Python to 3.12 first, upgrade Pytorch build, then upgrade this mkl. (The meta.yaml changes are the ones that narrow it to 2022.2.1 during `conda build faiss`.) So, this has just been changed to 2022.2.1. - mkl now requires _openmp_mutex of type "llvm" instead of "gnu": prior non-cuVS builds all used gnu, because intel-openmp from anaconda defaults channel does not require llvm-openmp. Now we need to remove the gnu one which is automatically pulled in during miniconda setup, and only keep the llvm version of _openmp_mutex. - liblief: The above changes tried to pull in liblief 0.15. This results in an error like `AttributeError: module 'lief._lief.ELF' has no attribute 'ELF_CLASS'`. When I checked passing PR builds on defaults, they use lief 0.12, so I pinned that one for Python 3.9 3.10 3.11. For Python 3.12, we need lief 0.14 or higher. - gcc_linux-64 =11.2 for faiss-gpu on cudatoolkit-11.2: GPU builds kept trying to reference 11.2 when 14.2 was installed. I couldn't figure out why, or how to point it to the 14.2 installed on the host. Current nightly builds still reference 11.2, so I gave up and pinned 11.2 to keep it the same. Moving to 14.2 will take some more investigation. - - mkl 2023.0 vs 2023.1 with python versions: 3.9, 3.10, and 3.11 pass with 2023.0, but python 3.12 needs mkl 2023.1 or higher. Otherwise we get: ``` INTEL MKL ERROR: $PREFIX/lib/python3.12/site-packages/faiss/../../.././libmkl_def.so.2: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8. Intel MKL FATAL ERROR: Cannot load libmkl_def.so.2. ``` so the solution was to put a bunch of conditions in in faiss/meta.yaml. We should be able to use Jinja macros to reduce duplication but it requires some investigation. It was failing: https://github.com/facebookresearch/faiss/actions/runs/12915187334/job/36016477707?pr=4126 (paste of logs here: P1716887936). This can be a future BE task. Macro example (the `-` signs remove whitespace lines before and after) ``` {% macro inclmkldevel() %} {%- if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' -%} - mkl-devel =2023.0 # [x86_64] - liblief =0.12.3 # [not win] - python_abi <3.12 {%- elif PY_VER == '3.12' %} - mkl-devel >=2023.2.0 # [x86_64] - liblief =0.15.1 # [not win] - python_abi =3.12 {% endif -%} {% endmacro %} ``` Unit test notes: - - GPU residual quantizer: Debugged extensively with Matthijs. The problem is in the C++ -> Python conversion. The C++ side prints the right values, but when getting it back to Python, it is filled with junk data. It is only reproducible on CUDA 11.4.4 after switching channels. It is likely a compiler problem. We discussed, and resolved to create a C++ side unit test (so this diff creates TestGpuResidualQuantizer) to verify the functionality and disable the Python unit test, but leave it in the codebase with a comment. Matthijs made extensive notes in https://docs.google.com/document/d/1MjMdOpPgx-MArdrYJZCaQlRqlrhSj5Y1Z9lTyiab8jc/edit?usp=sharing . - test_mem_leak.cpp seems flaky. It sometimes fails, then passes with rerun. Unfixed issues: - - I noticed sometimes downloads will fail with the text like below. It passes on re-run. ``` libgomp-14.2.0-h77fa898_1.conda extraction failed Warning: error libmamba Error when extracting package: Could not chdir info/recipe/parent/patches/0005-Hardcode-HAVE_ALIGNED_ALLOC-1-in-libstdc-v3-configur.patch error libmamba Error when extracting package: Could not chdir info/recipe/parent/patches/0005-Hardcode-HAVE_ALIGNED_ALLOC-1-in-libstdc-v3-configur.patch Warning: Found incorrect download: libgomp. Aborting Found incorrect download: libgomp. Aborting Warning: ``` Differential Revision: D68043874
1 parent dc8d29a commit e8a20a1

File tree

9 files changed

+332
-19
lines changed

9 files changed

+332
-19
lines changed

.github/actions/build_cmake/action.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ runs:
2323
uses: conda-incubator/setup-miniconda@v3
2424
with:
2525
python-version: '3.11'
26-
miniconda-version: latest
26+
miniforge-version: latest # ensures conda-forge channel is used.
27+
channels: conda-forge
28+
conda-remove-defaults: 'true'
29+
# Set to aarch64 if we're on arm64 because there's no miniforge ARM64 package, just aarch64.
30+
# They are the same thing, just named differently.
31+
architecture: ${{ runner.arch == 'ARM64' && 'aarch64' || runner.arch }}
2732
- name: Configure build environment
2833
shell: bash
2934
run: |
3035
# initialize Conda
3136
conda config --set solver libmamba
37+
# Ensure starting packages are from conda-forge.
38+
conda list --show-channel-urls
3239
conda update -y -q conda
3340
echo "$CONDA/bin" >> $GITHUB_PATH
3441
@@ -43,7 +50,7 @@ runs:
4350
if [ "${{ runner.arch }}" = "X64" ]; then
4451
# TODO: merge this with ARM64
4552
conda install -y -q -c conda-forge gxx_linux-64=14.2 sysroot_linux-64=2.17
46-
conda install -y -q mkl=2023 mkl-devel=2023
53+
conda install -y -q mkl=2022.2.1 mkl-devel=2022.2.1
4754
fi
4855
4956
# no CUDA needed for ROCm so skip this
@@ -56,6 +63,7 @@ runs:
5663
elif [ "${{ inputs.cuvs }}" = "ON" ]; then
5764
conda install -y -q libcuvs=24.12 'cuda-version>=12.0,<=12.5' cuda-toolkit=12.4.1 gxx_linux-64=12.4 -c rapidsai -c conda-forge
5865
fi
66+
5967
# install test packages
6068
if [ "${{ inputs.rocm }}" = "ON" ]; then
6169
: # skip torch install via conda, we need to install via pip to get
@@ -174,3 +182,8 @@ runs:
174182
with:
175183
name: test-results-arch=${{ runner.arch }}-opt=${{ inputs.opt_level }}-gpu=${{ inputs.gpu }}-cuvs=${{ inputs.cuvs }}-rocm=${{ inputs.rocm }}
176184
path: test-results
185+
- name: Check installed packages channel
186+
shell: bash
187+
run: |
188+
# Shows that all installed packages are from conda-forge.
189+
conda list --show-channel-urls

.github/actions/build_conda/action.yml

+16-5
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,22 @@ runs:
3030
uses: conda-incubator/setup-miniconda@v3
3131
with:
3232
python-version: '3.11'
33-
miniconda-version: latest
33+
miniforge-version: latest # ensures conda-forge channel is used.
34+
channels: conda-forge
35+
conda-remove-defaults: 'true'
36+
# Set to runner.arch=aarch64 if we're on arm64 because
37+
# there's no miniforge ARM64 package, just aarch64.
38+
# They are the same thing, just named differently.
39+
# However there is an ARM64 for macOS, so exclude that.
40+
architecture: ${{ (runner.arch == 'ARM64' && runner.os != 'macOS') && 'aarch64' || runner.arch }}
3441
- name: Install conda build tools
3542
shell: ${{ steps.choose_shell.outputs.shell }}
3643
run: |
44+
# Ensure starting packages are from conda-forge.
45+
conda list --show-channel-urls
3746
conda install -y -q "conda!=24.11.0"
3847
conda install -y -q "conda-build!=24.11.0"
39-
- name: Fix CI failure
40-
shell: ${{ steps.choose_shell.outputs.shell }}
41-
if: runner.os != 'Windows'
42-
run: conda remove conda-anaconda-telemetry
48+
conda list --show-channel-urls
4349
- name: Enable anaconda uploads
4450
if: inputs.label != ''
4551
shell: ${{ steps.choose_shell.outputs.shell }}
@@ -94,3 +100,8 @@ runs:
94100
run: |
95101
conda build faiss-gpu-cuvs --variants '{ "cudatoolkit": "${{ inputs.cuda }}" }' \
96102
--user pytorch --label ${{ inputs.label }} -c pytorch -c rapidsai -c rapidsai-nightly -c conda-forge -c nvidia
103+
- name: Check installed packages channel
104+
shell: ${{ steps.choose_shell.outputs.shell }}
105+
run: |
106+
# Shows that all installed packages are from conda-forge.
107+
conda list --show-channel-urls

.github/workflows/build-pull-request.yml

+127
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,130 @@ jobs:
167167
fetch-tags: true
168168
- name: Build and Package (conda)
169169
uses: ./.github/actions/build_conda
170+
linux-x86_64-nightly:
171+
name: Linux x86_64 nightlies
172+
runs-on: 4-core-ubuntu
173+
steps:
174+
- name: Checkout
175+
uses: actions/checkout@v4
176+
with:
177+
fetch-depth: 0
178+
fetch-tags: true
179+
- uses: ./.github/actions/build_conda
180+
env:
181+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
182+
with:
183+
label: nightly
184+
linux-x86_64-GPU-CUDA-11-4-4-nightly:
185+
name: Linux x86_64 GPU nightlies (CUDA 11.4.4)
186+
runs-on: 4-core-ubuntu-gpu-t4
187+
env:
188+
CUDA_ARCHS: "60-real;61-real;62-real;70-real;72-real;75-real;80;86-real"
189+
FAISS_FLATTEN_CONDA_INCLUDES: "1"
190+
steps:
191+
- name: Checkout
192+
uses: actions/checkout@v4
193+
with:
194+
fetch-depth: 0
195+
fetch-tags: true
196+
- uses: ./.github/actions/build_conda
197+
env:
198+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
199+
with:
200+
label: nightly
201+
cuda: "11.4.4"
202+
linux-x86_64-GPU-CUVS-CUDA11-8-0-nightly:
203+
name: Linux x86_64 GPU w/ cuVS nightlies (CUDA 11.8.0)
204+
runs-on: 4-core-ubuntu-gpu-t4
205+
env:
206+
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
207+
steps:
208+
- name: Checkout
209+
uses: actions/checkout@v4
210+
with:
211+
fetch-depth: 0
212+
fetch-tags: true
213+
- uses: ./.github/actions/build_conda
214+
env:
215+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
216+
with:
217+
label: nightly
218+
cuvs: "ON"
219+
cuda: "11.8.0"
220+
linux-x86_64-GPU-CUDA-12-1-1-nightly:
221+
name: Linux x86_64 GPU nightlies (CUDA 12.1.1)
222+
runs-on: 4-core-ubuntu-gpu-t4
223+
env:
224+
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
225+
steps:
226+
- name: Checkout
227+
uses: actions/checkout@v4
228+
with:
229+
fetch-depth: 0
230+
fetch-tags: true
231+
- uses: ./.github/actions/build_conda
232+
env:
233+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
234+
with:
235+
label: nightly
236+
cuda: "12.1.1"
237+
linux-x86_64-GPU-CUVS-CUDA12-4-0-nightly:
238+
name: Linux x86_64 GPU w/ cuVS nightlies (CUDA 12.4.0)
239+
runs-on: 4-core-ubuntu-gpu-t4
240+
env:
241+
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
242+
steps:
243+
- name: Checkout
244+
uses: actions/checkout@v4
245+
with:
246+
fetch-depth: 0
247+
fetch-tags: true
248+
- uses: ./.github/actions/build_conda
249+
env:
250+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
251+
with:
252+
label: nightly
253+
cuvs: "ON"
254+
cuda: "12.4.0"
255+
windows-x86_64-nightly:
256+
name: Windows x86_64 nightlies
257+
runs-on: windows-2019
258+
steps:
259+
- name: Checkout
260+
uses: actions/checkout@v4
261+
with:
262+
fetch-depth: 0
263+
fetch-tags: true
264+
- uses: ./.github/actions/build_conda
265+
env:
266+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
267+
with:
268+
label: nightly
269+
osx-arm64-nightly:
270+
name: OSX arm64 nightlies
271+
runs-on: macos-14
272+
steps:
273+
- name: Checkout
274+
uses: actions/checkout@v4
275+
with:
276+
fetch-depth: 0
277+
fetch-tags: true
278+
- uses: ./.github/actions/build_conda
279+
env:
280+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
281+
with:
282+
label: nightly
283+
linux-arm64-nightly:
284+
name: Linux arm64 nightlies
285+
runs-on: 2-core-ubuntu-arm
286+
steps:
287+
- name: Checkout
288+
uses: actions/checkout@v4
289+
with:
290+
fetch-depth: 0
291+
fetch-tags: true
292+
- uses: ./.github/actions/build_conda
293+
env:
294+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
295+
with:
296+
label: nightly

conda/faiss-gpu/meta.yaml

+10-5
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ outputs:
5050
- sysroot_linux-64 =2.17 # [linux64]
5151
- llvm-openmp # [osx]
5252
- cmake >=3.24.0
53-
- make =4.2 # [not win]
54-
- mkl-devel =2023 # [x86_64]
53+
- make =4.2 # [not win and not (osx and arm64)]
54+
- make =4.4 # [osx and arm64]
55+
- mkl-devel =2023.0 # [x86_64]
5556
- cuda-toolkit {{ cudatoolkit }}
57+
- gcc_linux-64 =11.2 # [cudatoolkit == '11.4.4']
5658
host:
57-
- mkl =2023 # [x86_64]
59+
- mkl =2023.0 # [x86_64]
5860
- openblas =0.3 # [not x86_64]
5961
run:
60-
- mkl =2023 # [x86_64]
62+
- mkl =2023.0 # [x86_64]
6163
- openblas =0.3 # [not x86_64]
6264
- cuda-cudart {{ cuda_constraints }}
6365
- libcublas {{ libcublas_constraints }}
@@ -83,11 +85,14 @@ outputs:
8385
- sysroot_linux-64 =2.17 # [linux64]
8486
- swig =4.0
8587
- cmake >=3.24.0
86-
- make =4.2 # [not win]
88+
- make =4.2 # [not win and not (osx and arm64)]
89+
- make =4.4 # [osx and arm64]
90+
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
8791
- cuda-toolkit {{ cudatoolkit }}
8892
host:
8993
- python {{ python }}
9094
- numpy >=1.19,<2
95+
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
9196
- {{ pin_subpackage('libfaiss', exact=True) }}
9297
run:
9398
- python {{ python }}

conda/faiss/meta.yaml

+74-7
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,53 @@ outputs:
3131
script: build-lib-arm64.sh # [not x86_64]
3232
script: build-lib.bat # [win]
3333
build:
34-
string: "h{{ PKG_HASH }}_{{ number }}_cpu{{ suffix }}"
34+
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cpu{{ suffix }}"
3535
run_exports:
3636
- {{ pin_compatible('libfaiss', exact=True) }}
3737
requirements:
3838
build:
39+
- python {{ python }}
3940
- {{ compiler('cxx') }}
4041
- sysroot_linux-64 =2.17 # [linux64]
41-
- llvm-openmp # [osx]
42+
- llvm-openmp # [osx or linux64]
4243
- cmake >=3.24.0
43-
- make =4.2 # [not win]
44-
- mkl-devel =2023 # [x86_64]
44+
- make =4.2 # [not win and not (osx and arm64)]
45+
- make =4.4 # [osx and arm64]
46+
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
47+
- mkl-devel =2023.0 # [x86_64]
48+
- liblief =0.12.3 # [not win]
49+
- python_abi <3.12
50+
{% elif PY_VER == '3.12' %}
51+
- mkl-devel >=2023.2.0 # [x86_64 and not win]
52+
- mkl-devel =2023.1.0 # [x86_64 and win]
53+
- liblief =0.15.1 # [not win]
54+
- python_abi =3.12
55+
{% endif %}
4556
host:
46-
- mkl =2023 # [x86_64]
57+
- python {{ python }}
58+
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
59+
- mkl =2023.0 # [x86_64]
60+
- liblief =0.12.3 # [not win]
61+
- python_abi <3.12
62+
{% elif PY_VER == '3.12' %}
63+
- mkl >=2023.2.0 # [x86_64 and not win]
64+
- mkl =2023.1.0 # [x86_64 and win]
65+
- liblief =0.15.1 # [not win]
66+
- python_abi =3.12
67+
{% endif %}
4768
- openblas =0.3 # [not x86_64]
4869
run:
49-
- mkl =2023 # [x86_64]
70+
- python {{ python }}
71+
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
72+
- mkl =2023.0 # [x86_64]
73+
- liblief =0.12.3 # [not win]
74+
- python_abi <3.12
75+
{% elif PY_VER == '3.12' %}
76+
- mkl >=2023.2.0 # [x86_64 and not win]
77+
- mkl =2023.1.0 # [x86_64 and win]
78+
- liblief =0.15.1 # [not win]
79+
- python_abi =3.12
80+
{% endif %}
5081
- openblas =0.3 # [not x86_64]
5182
test:
5283
requires:
@@ -66,25 +97,61 @@ outputs:
6697
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cpu{{ suffix }}"
6798
requirements:
6899
build:
100+
- python {{ python }}
69101
- {{ compiler('cxx') }}
70102
- sysroot_linux-64 =2.17 # [linux64]
71103
- swig =4.0
72104
- cmake >=3.24.0
73-
- make =4.2 # [not win]
105+
- make =4.2 # [not win and not (osx and arm64)]
106+
- make =4.4 # [osx and arm64]
107+
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
108+
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
109+
- mkl =2023.0 # [x86_64]
110+
- python_abi <3.12
111+
{% elif PY_VER == '3.12' %}
112+
- mkl >=2023.2.0 # [x86_64 and not win]
113+
- mkl =2023.1.0 # [x86_64 and win]
114+
- python_abi =3.12
115+
{% endif %}
74116
host:
75117
- python {{ python }}
76118
- numpy >=1.19,<2
77119
- {{ pin_subpackage('libfaiss', exact=True) }}
120+
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
121+
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
122+
- mkl =2023.0 # [x86_64]
123+
- python_abi <3.12
124+
{% elif PY_VER == '3.12' %}
125+
- mkl >=2023.2.0 # [x86_64 and not win]
126+
- mkl =2023.1.0 # [x86_64 and win]
127+
- python_abi =3.12
128+
{% endif %}
78129
run:
79130
- python {{ python }}
80131
- numpy >=1.19,<2
81132
- packaging
82133
- {{ pin_subpackage('libfaiss', exact=True) }}
134+
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
135+
- mkl =2023.0 # [x86_64]
136+
- python_abi <3.12
137+
{% elif PY_VER == '3.12' %}
138+
- mkl >=2023.2.0 # [x86_64 and not win]
139+
- mkl =2023.1.0 # [x86_64 and win]
140+
- python_abi =3.12
141+
{% endif %}
83142
test:
84143
requires:
85144
- numpy >=1.19,<2
86145
- scipy
87146
- pytorch <2.5
147+
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
148+
- mkl =2023.0 # [x86_64]
149+
- python_abi <3.12
150+
{% elif PY_VER == '3.12' %}
151+
- mkl >=2023.2.0 # [x86_64 and not win]
152+
- mkl =2023.1.0 # [x86_64 and win]
153+
- python_abi =3.12
154+
{% endif %}
88155
commands:
89156
- python -X faulthandler -m unittest discover -v -s tests/ -p "test_*"
90157
- python -X faulthandler -m unittest discover -v -s tests/ -p "torch_*"

faiss/gpu/test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ faiss_gpu_test(TestGpuIndexBinaryFlat.cpp)
4545
faiss_gpu_test(TestGpuMemoryException.cpp)
4646
faiss_gpu_test(TestGpuIndexIVFPQ.cpp)
4747
faiss_gpu_test(TestGpuIndexIVFScalarQuantizer.cpp)
48+
faiss_gpu_test(TestGpuResidualQuantizer.cpp)
4849
faiss_gpu_test(TestGpuDistance.${GPU_EXT_PREFIX})
4950
faiss_gpu_test(TestGpuSelect.${GPU_EXT_PREFIX})
5051
if(FAISS_ENABLE_CUVS)

0 commit comments

Comments
 (0)