mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-11 22:50:00 +00:00
Summary:
This PR adds RISC-V Vector Extension SIMD support for Faiss scalar quantizer.
The implementation introduces runtime vector-length aware RVV kernels using the m8 vector configuration, instead of assuming a fixed vector width. This matches the variable-length nature of RVV hardware and allows the implementation to scale across different RISC-V vector implementations.
## Changes
- Add RVV implementations for scalar quantizer codecs:
- 8-bit codec decoding
- 4-bit codec decoding
- (6-bit stays scalar: the RVV gather decoder measured 12-22% slower
than the scalar path, so QT_6bit falls back until a faster decoder
exists)
- Add RVV quantizer reconstruction support for:
- Uniform quantizers
- Non-uniform quantizers
- FP16 (Zvfhmin is the enforced minimum ISA of the RISCV_RVV level; a
build without it fails compilation rather than silently falling back)
- BF16
- Direct 8-bit quantization
- Signed 8-bit quantization
- LloydMax quantizers (1/2/3/4/8-bit)
- Add RVV optimized similarity implementations:
- L2 distance
- Inner product
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5535
Reviewed By: mnorris11
Differential Revision: D116996553
Pulled By: juancarpio27
fbshipit-source-id: dc726948fa602a04a757d8f9cab8eea41ac1979a
49 lines
1.7 KiB
CMake
49 lines
1.7 KiB
CMake
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
# Cross-compilation toolchain for RISC-V 64-bit (lp64d ABI) on Ubuntu 24.04.
|
|
#
|
|
# Requires:
|
|
# gcc-14-riscv64-linux-gnu
|
|
# g++-14-riscv64-linux-gnu
|
|
#
|
|
# Target libraries:
|
|
# libopenblas-dev:riscv64
|
|
#
|
|
# Ubuntu multiarch installs target libraries into:
|
|
# /usr/lib/riscv64-linux-gnu
|
|
#
|
|
# The CI creates:
|
|
# /usr/riscv64-linux-gnu/usr/lib/riscv64-linux-gnu
|
|
# -> /usr/lib/riscv64-linux-gnu
|
|
#
|
|
# so CMake can locate target libraries while using ONLY root mode.
|
|
|
|
set(CMAKE_SYSTEM_NAME Linux)
|
|
set(CMAKE_SYSTEM_PROCESSOR riscv64)
|
|
|
|
# GCC 14+: the RVV SQ kernels rely on tuple types (vuint8m1x3_t) and
|
|
# zvfhmin f16 intrinsics that GCC 13's <riscv_vector.h> does not export.
|
|
set(CMAKE_C_COMPILER riscv64-linux-gnu-gcc-14)
|
|
set(CMAKE_CXX_COMPILER riscv64-linux-gnu-g++-14)
|
|
|
|
# Do NOT set CMAKE_SYSROOT here. Ubuntu's cross toolchain resolves target
|
|
# libraries through its built-in paths (/usr/riscv64-linux-gnu/lib). Passing
|
|
# --sysroot=/usr/riscv64-linux-gnu makes ld prepend the sysroot to the
|
|
# absolute paths inside libc6-dev-riscv64-cross's libc.so linker script,
|
|
# producing doubled paths such as
|
|
# /usr/riscv64-linux-gnu/usr/riscv64-linux-gnu/lib/libc.so.6
|
|
# and failing the CMake compiler check at link time.
|
|
|
|
set(CMAKE_FIND_ROOT_PATH /usr/riscv64-linux-gnu)
|
|
|
|
# Never search host binaries inside sysroot.
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
# Target libraries/headers/packages only.
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|