Skip to content

Commit 6a7e83f

Browse files
committed
improve(knng): ignore the distance of explore as rerank do not use them
1 parent 4e0574a commit 6a7e83f

10 files changed

Lines changed: 370 additions & 200 deletions

File tree

examples/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Navigating into any example directory and running `uv sync` or `uv run` will aut
3030
```bash
3131
cd examples/knng
3232
uv sync
33+
34+
# If C++ code or pybind11 bindings were modified, force rebuilding the extension:
35+
uv sync --reinstall-package deglib
3336
```
3437

3538
## Projects

examples/dynamic_data/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ Since `pyproject.toml` references `deglib` locally (`path = "../../python"`), ru
6262
```bash
6363
# Install dependencies & compile latest deglib C++ bindings
6464
uv sync
65+
66+
# If C++ code or pybind11 bindings were modified, force rebuilding the extension:
67+
uv sync --reinstall-package deglib
6568
```
6669

6770
> **Note:** A C++ compiler (MSVC on Windows, GCC/Clang on Linux/macOS) and CMake must be available in your system `PATH`. `setup.py` handles copying C++ files, running CMake, and compiling the extension during the `uv sync` step.

examples/knng/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Since `pyproject.toml` references `deglib` locally (`path = "../../python"`), ru
2222
```bash
2323
# Install dependencies & compile latest deglib C++ bindings
2424
uv sync
25+
26+
# If C++ code or pybind11 bindings were modified, force rebuilding the extension:
27+
uv sync --reinstall-package deglib
2528
```
2629

2730
> **Note:** A C++ compiler (MSVC on Windows, GCC/Clang on Linux/macOS) and CMake must be available in your system `PATH`. `setup.py` handles copying C++ files, running CMake, and compiling the extension during the `uv sync` step.

examples/knng/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ def construct_knng(
107107
# explore() accepts external labels
108108
t0 = time.perf_counter()
109109
entry_labels = np.ascontiguousarray(labels, dtype=np.uint32)
110-
indices, distances = graph.explore(
110+
indices = graph.explore(
111111
entry_labels,
112112
k=evp_k,
113113
max_distance_computation_count=max_dist,
114114
include_entry=False,
115-
threads=threads
115+
threads=threads,
116+
return_distances=False,
117+
unsorted=True
116118
)
117119
t_explore = time.perf_counter() - t0
118120
print(f"Graph candidate search completed in {t_explore:.3f}s")
@@ -125,7 +127,9 @@ def construct_knng(
125127
candidate_indices=indices,
126128
base_vectors=train_vectors,
127129
k_top=k_top,
128-
num_threads=threads
130+
num_threads=threads,
131+
return_distances=False,
132+
unsorted=True
129133
)
130134
t_rerank = time.perf_counter() - t0
131135
print(f"FP16 Reranking completed in {t_rerank:.3f}s")

examples/static_data/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Since `pyproject.toml` references `deglib` locally (`path = "../../python"`), ru
1919
```bash
2020
# Install dependencies & compile latest deglib C++ bindings
2121
uv sync
22+
23+
# If C++ code or pybind11 bindings were modified, force rebuilding the extension:
24+
uv sync --reinstall-package deglib
2225
```
2326

2427
> **Note:** A C++ compiler (MSVC on Windows, GCC/Clang on Linux/macOS) and CMake must be available in your system `PATH`. `setup.py` handles copying C++ files, running CMake, and compiling the extension during the `uv sync` step.

0 commit comments

Comments
 (0)