Skip to content

Commit 7986d8e

Browse files
authored
Merge pull request #503 from unum-cloud/main-dev
2 parents 9bc9936 + 512c6aa commit 7986d8e

21 files changed

+1183
-129
lines changed

.github/workflows/prerelease.yml

+105-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ env:
1111
PYTHONUTF8: 1
1212
PYTHON_VERSION: 3.11
1313
DOTNET_VERSION: 7.0.x
14+
ANDROID_NDK_VERSION: 26.3.11579264
15+
ANDROID_SDK_VERSION: 21
1416

1517
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1618
permissions:
@@ -101,11 +103,15 @@ jobs:
101103
run: npm test
102104

103105
# Rust
106+
- name: Set up Rust
107+
run: |
108+
rustup update stable
109+
rustup default stable
110+
rustc -vV
111+
- name: Build Rust
112+
run: cargo build
104113
- name: Test Rust
105-
uses: actions-rs/toolchain@v1
106-
with:
107-
toolchain: stable
108-
override: true
114+
run: cargo test
109115

110116
# Java
111117
- name: Setup Java
@@ -193,6 +199,17 @@ jobs:
193199
- name: Test Python
194200
run: pytest
195201

202+
# Rust
203+
- name: Set up Rust
204+
run: |
205+
rustup update stable
206+
rustup default stable
207+
rustc -vV
208+
- name: Build Rust
209+
run: cargo build
210+
- name: Test Rust
211+
run: cargo test
212+
196213
# C#
197214
- name: Setup .NET ${{ env.DOTNET_VERSION }}
198215
uses: actions/setup-dotnet@v3
@@ -260,6 +277,17 @@ jobs:
260277
- name: Test ObjC/Swift
261278
run: swift test
262279

280+
# Rust
281+
- name: Set up Rust
282+
run: |
283+
rustup update stable
284+
rustup default stable
285+
rustc -vV
286+
- name: Build Rust
287+
run: cargo build
288+
- name: Test Rust
289+
run: cargo test
290+
263291
# C#
264292
- name: Setup .NET ${{ env.DOTNET_VERSION }}
265293
uses: actions/setup-dotnet@v3
@@ -318,6 +346,17 @@ jobs:
318346
- name: Test JavaScript
319347
run: npm test
320348

349+
# Rust
350+
- name: Set up Rust
351+
run: |
352+
rustup update stable
353+
rustup default stable
354+
rustc -vV
355+
- name: Build Rust
356+
run: cargo build
357+
- name: Test Rust
358+
run: cargo test
359+
321360
# C#
322361
- name: Setup .NET ${{ env.DOTNET_VERSION }}
323362
uses: actions/setup-dotnet@v3
@@ -421,3 +460,65 @@ jobs:
421460
run: |
422461
test -e build_artifacts/libusearch_c.so
423462
test -e build_artifacts/libusearch_sqlite.so
463+
464+
test_ubuntu_android_ndk:
465+
name: Android NDK Build
466+
runs-on: ubuntu-22.04
467+
strategy:
468+
matrix:
469+
include:
470+
- processor: armv7a
471+
abi: armeabi-v7a
472+
target: armv7-linux-androideabi
473+
- processor: aarch64
474+
abi: arm64-v8a
475+
target: aarch64-linux-android
476+
steps:
477+
- uses: actions/checkout@v4
478+
- run: git submodule update --init --recursive
479+
480+
- name: Install NDK ndk
481+
run: |
482+
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ANDROID_NDK_VERSION }}"
483+
484+
- name: Build C/C++
485+
run: |
486+
cmake -B build_artifacts \
487+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
488+
-D CMAKE_EXPORT_COMPILE_COMMANDS=1 \
489+
-D CMAKE_TOOLCHAIN_FILE=${ANDROID_HOME}/ndk/${{ env.ANDROID_NDK_VERSION }}/build/cmake/android.toolchain.cmake \
490+
-D CMAKE_ANDROID_STL_TYPE=c++_static \
491+
-D ANDROID_PLATFORM=${{ env.ANDROID_SDK_VERSION }} \
492+
-D ANDROID_ABI=${{ matrix.abi }} \
493+
-D USEARCH_BUILD_LIB_C=1 \
494+
-D USEARCH_BUILD_TEST_CPP=0 \
495+
-D USEARCH_BUILD_BENCH_CPP=0
496+
497+
cmake --build build_artifacts --config RelWithDebInfo
498+
499+
# We can't run the produced builds, but we can make sure they exist
500+
- name: Test artifacts presense
501+
run: |
502+
test -e build_artifacts/libusearch_c.so
503+
504+
# Rust
505+
- name: Set up Rust
506+
run: |
507+
rustup update stable
508+
rustup default stable
509+
rustup target add ${{ matrix.target }}
510+
rustc -vV
511+
512+
- name: Set up Rust Env
513+
run: |
514+
TOOLCHAIN=${ANDROID_HOME}/ndk/${{ env.ANDROID_NDK_VERSION }}/toolchains/llvm/prebuilt/linux-x86_64/bin/
515+
NDK_CLANG=$(find ${TOOLCHAIN} -name "${{ matrix.processor }}*${{ env.ANDROID_SDK_VERSION }}-clang")
516+
echo "CC_${{ matrix.target }}=${NDK_CLANG}" >> ${GITHUB_ENV}
517+
echo "CXX_${{ matrix.target }}=${NDK_CLANG}++" >> ${GITHUB_ENV}
518+
echo "AR_${{ matrix.target }}=${TOOLCHAIN}/llvm-ar" >> ${GITHUB_ENV}
519+
echo "CARGO_${{ matrix.target }}=${NDK_CLANG}" >> ${GITHUB_ENV}
520+
echo "CARGO_${{ matrix.target }}=${TOOLCHAIN}/llvm-ar" >> ${GITHUB_ENV}
521+
522+
- name: Build Rust
523+
run: |
524+
cargo build --target ${{ matrix.target }}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"ivdep",
158158
"jaccard",
159159
"Jemalloc",
160+
"kmeans",
160161
"Kullback",
161162
"Leibler",
162163
"libjemalloc",
@@ -173,6 +174,7 @@
173174
"nlevels",
174175
"Numba",
175176
"numpy",
177+
"NVME",
176178
"objc",
177179
"OPENMP",
178180
"preprocess",
@@ -198,6 +200,7 @@
198200
"uninitialize",
199201
"unumusearch",
200202
"usearch",
203+
"usecase",
201204
"usecases",
202205
"Vardanian",
203206
"vectorize",

BENCHMARKS.md

+31-19
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ All major HNSW implementation share an identical list of hyper-parameters:
1010

1111
The default values vary drastically.
1212

13-
| Library | Connectivity | EF @ A | EF @ S |
14-
| :-------: | :----------: | :----: | :----: |
15-
| `hnswlib` | 16 | 200 | 10 |
16-
| `FAISS` | 32 | 40 | 16 |
17-
| `USearch` | 16 | 128 | 64 |
13+
| Library | Connectivity | EF @ A | EF @ S |
14+
| :-------- | -----------: | -----: | -----: |
15+
| `hnswlib` | 16 | 200 | 10 |
16+
| `FAISS` | 32 | 40 | 16 |
17+
| `USearch` | 16 | 128 | 64 |
1818

1919
Below are the performance numbers for a benchmark running on the 64 cores of AWS `c7g.metal` "Graviton 3"-based instances.
2020
The main columns are:
@@ -26,27 +26,27 @@ The main columns are:
2626
### Different "connectivity"
2727

2828
| Vectors | Connectivity | EF @ A | EF @ S | __Add__, QPS | __Search__, QPS | __Recall @1__ |
29-
| :--------- | :----------: | :----: | :----: | :----------: | :-------------: | ------------: |
30-
| `f32` x256 | 16 | 128 | 64 | 75'640 | 131'654 | 99.3% |
31-
| `f32` x256 | 12 | 128 | 64 | 81'747 | 149'728 | 99.0% |
32-
| `f32` x256 | 32 | 128 | 64 | 64'368 | 104'050 | 99.4% |
29+
| :--------- | -----------: | -----: | -----: | -----------: | --------------: | ------------: |
30+
| `f32` x256 | 16 | 128 | 64 | 75'640 | 131'654 | 99.3% |
31+
| `f32` x256 | 12 | 128 | 64 | 81'747 | 149'728 | 99.0% |
32+
| `f32` x256 | 32 | 128 | 64 | 64'368 | 104'050 | 99.4% |
3333

3434
### Different "expansion factors"
3535

3636
| Vectors | Connectivity | EF @ A | EF @ S | __Add__, QPS | __Search__, QPS | __Recall @1__ |
37-
| :--------- | :----------: | :----: | :----: | :----------: | :-------------: | ------------: |
38-
| `f32` x256 | 16 | 128 | 64 | 75'640 | 131'654 | 99.3% |
39-
| `f32` x256 | 16 | 64 | 32 | 128'644 | 228'422 | 97.2% |
40-
| `f32` x256 | 16 | 256 | 128 | 39'981 | 69'065 | 99.2% |
37+
| :--------- | -----------: | -----: | -----: | -----------: | --------------: | ------------: |
38+
| `f32` x256 | 16 | 128 | 64 | 75'640 | 131'654 | 99.3% |
39+
| `f32` x256 | 16 | 64 | 32 | 128'644 | 228'422 | 97.2% |
40+
| `f32` x256 | 16 | 256 | 128 | 39'981 | 69'065 | 99.2% |
4141

4242
### Different vectors "quantization"
4343

4444
| Vectors | Connectivity | EF @ A | EF @ S | __Add__, QPS | __Search__, QPS | __Recall @1__ |
45-
| :----------- | :----------: | :----: | :----: | :----------: | :-------------: | ------------: |
46-
| `f32` x256 | 16 | 128 | 64 | 87'995 | 171'856 | 99.1% |
47-
| `f16` x256 | 16 | 128 | 64 | 87'270 | 153'788 | 98.4% |
48-
| `f16` x256 ✳️ | 16 | 128 | 64 | 71'454 | 132'673 | 98.4% |
49-
| `i8` x256 | 16 | 128 | 64 | 115'923 | 274'653 | 98.9% |
45+
| :----------- | -----------: | -----: | -----: | -----------: | --------------: | ------------: |
46+
| `f32` x256 | 16 | 128 | 64 | 87'995 | 171'856 | 99.1% |
47+
| `f16` x256 | 16 | 128 | 64 | 87'270 | 153'788 | 98.4% |
48+
| `f16` x256 ✳️ | 16 | 128 | 64 | 71'454 | 132'673 | 98.4% |
49+
| `i8` x256 | 16 | 128 | 64 | 115'923 | 274'653 | 98.9% |
5050

5151
As seen on the chart, for `f16` quantization, performance may differ depending on native hardware support for that numeric type.
5252
Also worth noting, 8-bit quantization results in almost no quantization loss and may perform better than `f16`.
@@ -58,9 +58,12 @@ Within this repository you will find two commonly used utilities:
5858
- `cpp/bench.cpp` the produces the `bench_cpp` binary for broad USearch benchmarks.
5959
- `python/bench.py` and `python/bench.ipynb` for interactive charts against FAISS.
6060

61+
### C++ Benchmarking Utilities
62+
6163
To achieve best highest results we suggest compiling locally for the target architecture.
6264

6365
```sh
66+
git submodule update --init --recursive
6467
cmake -USEARCH_BUILD_BENCH_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_USE_OPENMP=1 -DUSEARCH_USE_SIMSIMD=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -B build_profile
6568
cmake --build build_profile --config RelWithDebInfo -j
6669
build_profile/bench_cpp --help
@@ -146,11 +149,20 @@ build_profile/bench_cpp \
146149
--cos
147150
```
148151

149-
150152
> Optional parameters include `connectivity`, `expansion_add`, `expansion_search`.
151153
152154
For Python, jut open the Jupyter Notebook and start playing around.
153155

156+
### Python Benchmarking Utilities
157+
158+
Several benchmarking suites are available for Python: approximate search, exact search, and clustering.
159+
160+
```sh
161+
python/scripts/bench.py --help
162+
python/scripts/bench_exact.py --help
163+
python/scripts/bench_cluster.py --help
164+
```
165+
154166
## Datasets
155167

156168
BigANN benchmark is a good starting point, if you are searching for large collections of high-dimensional vectors.

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ cibuildwheel --platform macos # works only on MacOS
200200
cibuildwheel --platform windows # works only on Windows
201201
```
202202

203-
You may need root previligies for multi-architecture builds:
203+
You may need root privileges for multi-architecture builds:
204204

205205
```sh
206206
sudo $(which cibuildwheel) --platform linux

build.gradle

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import org.gradle.internal.jvm.Jvm
22

33
plugins {
44
id 'java-library'
5+
id 'c'
56
id 'cpp'
67
id 'maven-publish'
78
id 'signing'
@@ -66,6 +67,15 @@ model {
6667
srcDirs "include", "fp16/include", "simsimd/include", "${Jvm.current().javaHome}/include"
6768
}
6869
}
70+
c {
71+
source {
72+
srcDirs "simsimd/c/"
73+
include "**/*.c"
74+
}
75+
exportedHeaders {
76+
srcDirs "simsimd/include"
77+
}
78+
}
6979
}
7080
binaries.withType(StaticLibraryBinarySpec) {
7181
buildable = false
@@ -83,6 +93,11 @@ model {
8393
cppCompiler.args "-I${Jvm.current().javaHome}/include/win32"
8494
cppCompiler.args '/std:c++11'
8595
}
96+
cppCompiler.args '-DUSEARCH_USE_FP16LIB=1'
97+
cppCompiler.args '-DUSEARCH_USE_SIMSIMD=1'
98+
cppCompiler.args '-DSIMSIMD_DYNAMIC_DISPATCH=1'
99+
cppCompiler.args '-DSIMSIMD_NATIVE_BF16=0'
100+
cppCompiler.args '-DSIMSIMD_NATIVE_F16=0'
86101
}
87102
}
88103
}

0 commit comments

Comments
 (0)