-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:dblalock/bolt
- Loading branch information
Showing
15 changed files
with
231 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "third_party/kmc2"] | ||
path = third_party/kmc2 | ||
url = https://github.com/mneilly/kmc2.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
## Building Bolt | ||
|
||
Make sure you have cmake, swig and python 3 installed. This was | ||
tested with cmake 3.18.4, swig 4.0 and python 3.9 on Debian 11. It was | ||
also tested with cmake 3.21.0, swig 4.02 and python 3.9.7 (installed | ||
from Brew) on Mac OS X 10.14.6. Optionally, you can also use the | ||
system Eigen3 if you have it installed. | ||
|
||
### Using Docker | ||
``` | ||
(cd docker && docker build -t bolt .) | ||
docker run -v $PWD:$PWD -w $PWD -it bolt /bin/bash | ||
./build.sh | ||
source venv/bin/activate | ||
python tests/test_encoder.py | ||
./cpp/build-bolt/bolt amm* | ||
``` | ||
|
||
### The Easy Way | ||
|
||
This assumes you have appropriate versions of tools, libraries, | ||
etc. already available on your system. | ||
``` | ||
./build.sh | ||
source venv/bin/activate | ||
pytest tests | ||
cd cpp/build-bolt | ||
./bolt amm* | ||
``` | ||
|
||
|
||
### C++ | ||
|
||
``` | ||
cd cpp | ||
mkdir build-bolt | ||
cd build-bolt | ||
cmake .. | ||
make | ||
./bolt amm* | ||
``` | ||
|
||
### Python | ||
|
||
To build the python package: | ||
|
||
``` | ||
git submodule update --init # for kmc2 | ||
virtualenv -p $(which python3) venv | ||
source venv/bin/activate | ||
pip install -r requirements.txt | ||
pip install ./third_party/kmc2 | ||
python setup.py install | ||
``` | ||
|
||
To build with GCC instead of clang: | ||
|
||
`CC=gcc CXX=g++ python setup.py install` | ||
|
||
If you want to use the system Eigen installation set the appropriate path for your system. E.g. - | ||
|
||
`EIGEN_INCLUDE_DIR=/usr/include/eigen3 python setup.py install` | ||
|
||
To test that it works: | ||
|
||
`pytest tests` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#/usr/bin/env bash | ||
|
||
MYNAME=${0##*/} | ||
MYPATH=$(pwd -P) | ||
|
||
(cd docker && docker build -t bolt .) | ||
|
||
# Create virtual environment | ||
|
||
if [ ! -e venv ]; then | ||
virtualenv -p $(which python3) venv | ||
fi | ||
|
||
. venv/bin/activate | ||
|
||
# Build python package | ||
|
||
git submodule update --init | ||
pip install -r requirements.txt | ||
pip install ./third_party/kmc2 | ||
# pip install --use-feature=in-tree-build -r requirements.txt | ||
# pip install --use-feature=in-tree-build ./third_party/kmc2 | ||
# pip install . # doesn't work due to custom install command | ||
python setup.py install | ||
# python tests/test_encoder.py | ||
#--or-- | ||
# python setup.py build_ext --inplace | ||
# PYTHONPATH=${MYPATH}/python python tests/test_encoder.py | ||
|
||
# Build C++ | ||
|
||
mkdir -p cpp/build-bolt | ||
cd cpp/build-bolt | ||
cmake .. | ||
make -j4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#/usr/bin/env bash | ||
|
||
rm -rf venv | ||
|
||
rm -rf build/ pybolt.egg-info/ | ||
rm -rf python/bolt/bolt.py python/bolt/native_wrap.cpp python/bolt/pybolt.egg-info | ||
|
||
rm -rf cpp/build-bolt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR) | ||
|
||
project(bolt CXX) | ||
|
||
find_package(Eigen3 REQUIRED) | ||
|
||
set(sourceFiles | ||
${CMAKE_SOURCE_DIR}/src/quantize/bolt.cpp | ||
${CMAKE_SOURCE_DIR}/src/quantize/mithral.cpp | ||
${CMAKE_SOURCE_DIR}/src/utils/avx_utils.cpp | ||
${CMAKE_SOURCE_DIR}/test/main.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize | ||
${CMAKE_SOURCE_DIR}/test/test_avx_utils.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_amm.cpp | ||
#${CMAKE_SOURCE_DIR}/test/quantize/profile_amm_old.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_bolt.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_encode.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_lut_creation.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_multicodebook.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_pq.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_scan.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/test_bolt.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/test_mithral.cpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/test_multicodebook.cpp | ||
) | ||
|
||
set(headerFiles | ||
${CMAKE_SOURCE_DIR}/src/include/public.hpp | ||
${CMAKE_SOURCE_DIR}/src/quantize/bolt.hpp | ||
${CMAKE_SOURCE_DIR}/src/quantize/mithral.hpp | ||
${CMAKE_SOURCE_DIR}/src/quantize/mithral_v1.hpp | ||
${CMAKE_SOURCE_DIR}/src/quantize/multi_codebook.hpp | ||
${CMAKE_SOURCE_DIR}/src/quantize/multisplit.hpp | ||
${CMAKE_SOURCE_DIR}/src/quantize/product_quantize.hpp | ||
${CMAKE_SOURCE_DIR}/src/utils/avx_utils.hpp | ||
${CMAKE_SOURCE_DIR}/src/utils/bit_ops.hpp | ||
${CMAKE_SOURCE_DIR}/src/utils/debug_utils.hpp | ||
${CMAKE_SOURCE_DIR}/src/utils/eigen_utils.hpp | ||
${CMAKE_SOURCE_DIR}/src/utils/memory.hpp | ||
${CMAKE_SOURCE_DIR}/src/utils/nn_utils.hpp | ||
${CMAKE_SOURCE_DIR}/src/utils/timing_utils.hpp | ||
${CMAKE_SOURCE_DIR}/test/external/catch.hpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/amm_common.hpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/profile_amm.hpp | ||
${CMAKE_SOURCE_DIR}/test/quantize/test_bolt.hpp | ||
${CMAKE_SOURCE_DIR}/test/testing_utils/testing_utils.hpp | ||
) | ||
|
||
add_executable(bolt ${sourceFiles} ${headerFiles}) | ||
#add_library(bolt SHARED ${sourceFiles} ${headerFiles}) | ||
set_target_properties(bolt PROPERTIES LINKER_LANGUAGE CXX) | ||
target_compile_definitions(bolt PRIVATE "-DBLAZE") | ||
target_link_libraries(bolt Eigen3::Eigen) | ||
target_include_directories(bolt PUBLIC ${CMAKE_SOURCE_DIR}) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -march=native -fno-rtti -ffast-math") |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM debian:11.3 | ||
|
||
RUN apt update -y | ||
RUN apt install -y build-essential clang python3 virtualenv git cmake swig libeigen3-dev | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ | |
|
||
%{ | ||
#define SWIG_FILE_WITH_INIT | ||
#include "eigen/Core" | ||
#include "Eigen/Core" | ||
%} | ||
|
||
%include "numpy.i" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
numpy | ||
scikit-learn | ||
Cython | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters