Skip to content
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

IGNORE: Test PR for AMX build in CI #3615

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/actions/build_cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
description: 'Compile options / optimization level.'
required: false
default: generic
dnnl:
description: 'Enable DNNL support.'
required: false
default: OFF
gpu:
description: 'Enable GPU support.'
required: false
Expand Down Expand Up @@ -53,6 +57,11 @@ runs:
conda install -y -q libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge
fi

if [ "${{ inputs.dnnl }}" = "ON" ]; then
# resurrect
conda install -y -q conda-forge::onednn
fi

# install test packages
conda install -y pytest
if [ "${{ inputs.gpu }}" = "ON" ]; then
Expand All @@ -70,6 +79,7 @@ runs:
cmake -B build \
-DBUILD_TESTING=ON \
-DBUILD_SHARED_LIBS=ON \
-DFAISS_ENABLE_DNNL=${{ inputs.dnnl }} \
-DFAISS_ENABLE_GPU=${{ inputs.gpu }} \
-DFAISS_ENABLE_RAFT=${{ inputs.raft }} \
-DFAISS_OPT_LEVEL=${{ inputs.opt_level }} \
Expand Down
243 changes: 3 additions & 240 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,249 +11,12 @@ env:
OMP_NUM_THREADS: '10'
MKL_THREADING_LAYER: GNU
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install clang-format
run: |
sudo apt-get update -y
sudo apt-get install -y wget
sudo apt install -y lsb-release wget software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh
chmod u+x llvm.sh
sudo ./llvm.sh 18
sudo apt-get install -y git-core clang-format-18
- name: Verify clang-format
run: |
git ls-files | grep -E '\.(cpp|h|cu|cuh)$' | xargs clang-format-18 -i
if git diff --quiet; then
echo "Formatting OK!"
else
echo "Formatting not OK!"
echo "------------------"
git --no-pager diff --color
exit 1
fi
linux-x86_64-cmake:
name: Linux x86_64 (cmake)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/build_cmake
linux-x86_64-AVX2-cmake:
name: Linux x86_64 AVX2 (cmake)
needs: linux-x86_64-cmake
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/build_cmake
with:
opt_level: avx2
linux-x86_64-AVX512-cmake:
name: Linux x86_64 AVX512 (cmake)
continue-on-error: true # non-blocking mode for now
needs: linux-x86_64-cmake
AMX-DNNL-cmake:
name: AMX DNNL (cmake)
runs-on: faiss-aws-m7i.large
steps:
- name: Checkout
continue-on-error: true # non-blocking mode for now
uses: actions/checkout@v4
- uses: ./.github/actions/build_cmake
with:
opt_level: avx512
continue-on-error: true # non-blocking mode for now
linux-x86_64-GPU-cmake:
name: Linux x86_64 GPU (cmake)
needs: linux-x86_64-cmake
runs-on: 4-core-ubuntu-gpu-t4
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/build_cmake
with:
gpu: ON
linux-x86_64-GPU-w-RAFT-cmake:
name: Linux x86_64 GPU w/ RAFT (cmake)
needs: linux-x86_64-cmake
runs-on: 4-core-ubuntu-gpu-t4
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/build_cmake
with:
gpu: ON
raft: ON
linux-arm64-SVE-cmake:
name: Linux arm64 SVE (cmake)
runs-on: faiss-aws-r8g.large
continue-on-error: true # non-blocking mode for now
steps:
- name: Checkout
continue-on-error: true # non-blocking mode for now
uses: actions/checkout@v4
- uses: ./.github/actions/build_cmake
continue-on-error: true # non-blocking mode for now
# TODO(T197096427): uncomment this once SVE PR is merged
# with:
# opt_level: sve
linux-x86_64-conda:
name: Linux x86_64 (conda)
needs: linux-x86_64-cmake
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
windows-x86_64-conda:
name: Windows x86_64 (conda)
needs: linux-x86_64-cmake
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
linux-arm64-conda:
name: Linux arm64 (conda)
needs: linux-x86_64-cmake
runs-on: 2-core-ubuntu-arm
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
linux-x86_64-packages:
name: Linux x86_64 packages
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
linux-x86_64-GPU-packages-CUDA-11-4-4:
name: Linux x86_64 GPU packages (CUDA 11.4.4)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: 4-core-ubuntu-gpu-t4
env:
CUDA_ARCHS: "60-real;61-real;62-real;70-real;72-real;75-real;80;86-real"
FAISS_FLATTEN_CONDA_INCLUDES: "1"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
cuda: "11.4.4"
compiler_version: "11.2"
linux-x86_64-GPU-RAFT-packages-CUDA11-8-0:
name: Linux x86_64 GPU w/ RAFT packages (CUDA 11.8.0)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: 4-core-ubuntu-gpu-t4
env:
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
raft: "ON"
cuda: "11.8.0"
compiler_version: "11.2"
linux-x86_64-GPU-packages-CUDA-12-1-1:
name: Linux x86_64 GPU packages (CUDA 12.1.1)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: 4-core-ubuntu-gpu-t4
env:
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
cuda: "12.1.1"
compiler_version: "11.2"
linux-x86_64-GPU-RAFT-packages-CUDA12-1-1:
name: Linux x86_64 GPU w/ RAFT packages (CUDA 12.1.1)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: 4-core-ubuntu-gpu-t4
env:
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
raft: "ON"
cuda: "12.1.1"
compiler_version: "11.2"
windows-x86_64-packages:
name: Windows x86_64 packages
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
osx-arm64-packages:
name: OSX arm64 packages
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
linux-arm64-packages:
name: Linux arm64 packages
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: 2-core-ubuntu-arm
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/actions/build_conda
with:
label: main
dnnl: ON
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Valid values are "generic", "avx2", "avx512".
option(FAISS_OPT_LEVEL "" "generic")
option(FAISS_ENABLE_DNNL "Enable support for onednn to accelerate indexflat search." OFF)
option(FAISS_ENABLE_GPU "Enable support for GPU indexes." ON)
option(FAISS_ENABLE_RAFT "Enable RAFT for GPU indexes." OFF)
option(FAISS_ENABLE_PYTHON "Build Python extension." ON)
Expand Down Expand Up @@ -80,6 +81,7 @@ if(FAISS_ENABLE_C_API)
add_subdirectory(c_api)
endif()


add_subdirectory(demos)
add_subdirectory(benchs)
add_subdirectory(tutorial/cpp)
Expand Down
5 changes: 5 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ The optional requirements are:
- for GPU indices:
- nvcc,
- the CUDA toolkit,
- for Intel®-AMX/oneDNN acceleration:
- oneDNN,
- 4th+ Gen Intel® Xeon® Scalable processor.
- for the python bindings:
- python 3,
- numpy,
Expand All @@ -108,6 +111,8 @@ Several options can be passed to CMake, among which:
- general options:
- `-DFAISS_ENABLE_GPU=OFF` in order to disable building GPU indices (possible
values are `ON` and `OFF`),
- `-DFAISS_ENABLE_DNNL=OFF` in order to support for Intel®-AMX/oneDNN to accelerate indexflat(inner_product) search (possible
values are `ON` and `OFF`, before invoking CMake and setting this option to `ON`, you can refer to this [link](https://oneapi-src.github.io/oneDNN/dev_guide_build.html) for installing oneDNN),
- `-DFAISS_ENABLE_PYTHON=OFF` in order to disable building python bindings
(possible values are `ON` and `OFF`),
- `-DFAISS_ENABLE_RAFT=ON` in order to enable building the RAFT implementations
Expand Down
8 changes: 8 additions & 0 deletions c_api/utils/distances_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,11 @@ void faiss_set_distance_compute_min_k_reservoir(int value) {
int faiss_get_distance_compute_min_k_reservoir() {
return faiss::distance_compute_min_k_reservoir;
}

void faiss_set_distance_compute_dnnl_query_bs(int value) {
faiss::distance_compute_dnnl_query_bs = value;
}

int faiss_get_distance_compute_dnnl_query_bs() {
return faiss::distance_compute_dnnl_query_bs;
}
12 changes: 12 additions & 0 deletions c_api/utils/distances_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ void faiss_set_distance_compute_min_k_reservoir(int value);
/// rather than a heap
int faiss_get_distance_compute_min_k_reservoir();

/// Setter of block sizes value for oneDNN/AMX distance computations
void faiss_set_distance_compute_dnnl_query_bs(int value);

/// Getter of block sizes value for oneDNN/AMX distance computations
int faiss_get_distance_compute_dnnl_query_bs();

/// Setter of block sizes value for oneDNN/AMX distance computations
void faiss_set_distance_compute_dnnl_database_bs(int value);

/// Getter of block sizes value for oneDNN/AMX distance computations
int faiss_get_distance_compute_dnnl_database_bs();

#ifdef __cplusplus
}
#endif
Expand Down
18 changes: 18 additions & 0 deletions faiss/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ if(NOT WIN32)
list(APPEND FAISS_HEADERS invlists/OnDiskInvertedLists.h)
endif()

if(FAISS_ENABLE_DNNL)
list(APPEND FAISS_HEADERS utils/onednn/onednn_utils.h)
endif()

if(FAISS_ENABLE_DNNL)
add_compile_definitions(ENABLE_DNNL)
endif()


# Export FAISS_HEADERS variable to parent scope.
set(FAISS_HEADERS ${FAISS_HEADERS} PARENT_SCOPE)

Expand Down Expand Up @@ -300,6 +309,15 @@ endif()
target_compile_definitions(faiss_avx2 PRIVATE FINTEGER=int)
target_compile_definitions(faiss_avx512 PRIVATE FINTEGER=int)

if(FAISS_ENABLE_DNNL)
find_library(RT_LIB rt)
find_library(DNNL_LIB dnnl)
message(DNNL_LIB=${DNNL_LIB})
target_link_libraries(faiss PRIVATE ${RT_LIB} ${DNNL_LIB})
target_link_libraries(faiss_avx2 PRIVATE ${RT_LIB} ${DNNL_LIB})
target_link_libraries(faiss_avx512 PRIVATE ${RT_LIB} ${DNNL_LIB})
endif()

find_package(OpenMP REQUIRED)
target_link_libraries(faiss PRIVATE OpenMP::OpenMP_CXX)
target_link_libraries(faiss_avx2 PRIVATE OpenMP::OpenMP_CXX)
Expand Down
Loading
Loading