deglib 0.2.8__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. {deglib-0.2.8 → deglib-0.3.1}/CMakeLists.txt +12 -3
  2. {deglib-0.2.8/src/deglib.egg-info → deglib-0.3.1}/PKG-INFO +70 -61
  3. {deglib-0.2.8 → deglib-0.3.1}/README.md +69 -60
  4. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/include/benchmark.h +10 -13
  5. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/include/dataset.h +14 -16
  6. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/analysis.h +5 -3
  7. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/builder.h +15 -15
  8. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/concurrent.h +15 -12
  9. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/config.h +6 -2
  10. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/deglib.h +1 -16
  11. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/evp_ip.h +147 -30
  12. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/fp16.h +4 -15
  13. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/fp16_ip.h +148 -49
  14. deglib-0.3.1/lib/deglib/include/deglib/distance/fp16_l2.h +403 -0
  15. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/fp32_ip.h +144 -48
  16. deglib-0.3.1/lib/deglib/include/deglib/distance/fp32_l2.h +424 -0
  17. deglib-0.3.1/lib/deglib/include/deglib/distance/int4.h +11 -0
  18. deglib-0.3.1/lib/deglib/include/deglib/distance/int4_ip.h +198 -0
  19. deglib-0.3.1/lib/deglib/include/deglib/distance/int4_l2.h +411 -0
  20. deglib-0.3.1/lib/deglib/include/deglib/distance/int8_ip.h +410 -0
  21. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/int8_l2.h +144 -33
  22. deglib-0.3.1/lib/deglib/include/deglib/distance/tail_mask.h +123 -0
  23. deglib-0.3.1/lib/deglib/include/deglib/distance/uint4.h +11 -0
  24. deglib-0.3.1/lib/deglib/include/deglib/distance/uint4_ip.h +332 -0
  25. deglib-0.3.1/lib/deglib/include/deglib/distance/uint4_l2.h +353 -0
  26. deglib-0.3.1/lib/deglib/include/deglib/distance/uint7_ip.h +203 -0
  27. deglib-0.3.1/lib/deglib/include/deglib/distance/uint7_l2.h +210 -0
  28. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/uint8_ip.h +107 -223
  29. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/uint8_l2.h +36 -38
  30. deglib-0.3.1/lib/deglib/include/deglib/distances.h +449 -0
  31. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/graph/dynamic_graph.h +221 -125
  32. deglib-0.3.1/lib/deglib/include/deglib/graph/internal_graph.h +1387 -0
  33. deglib-0.3.1/lib/deglib/include/deglib/graph/readonly_graph.h +360 -0
  34. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/graph/sizebounded_graph.h +225 -142
  35. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/graph/visited_list_pool.h +4 -4
  36. deglib-0.3.1/lib/deglib/include/deglib/graph.h +1364 -0
  37. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/optimization/flas/fast_linear_assignment_sorter.h +119 -50
  38. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/optimization/flas/fast_linear_assignment_sorter_mt.h +78 -7
  39. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/optimization.h +21 -10
  40. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/search/kmeans.h +176 -65
  41. deglib-0.3.1/lib/deglib/include/deglib/search/pareto_line.h +690 -0
  42. deglib-0.3.1/lib/deglib/include/deglib/search/recall_table.h +968 -0
  43. deglib-0.3.1/lib/deglib/include/deglib/search/reranker.h +1011 -0
  44. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/search/result_list.h +58 -25
  45. deglib-0.3.1/lib/deglib/include/deglib/search/searcher.h +1515 -0
  46. deglib-0.3.1/lib/deglib/include/deglib/search.h +18 -0
  47. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/transformation/evp.h +280 -257
  48. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/transformation/mips.h +24 -12
  49. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/transformation/normalize.h +9 -5
  50. deglib-0.3.1/lib/deglib/include/deglib/transformation/rotation.h +413 -0
  51. deglib-0.3.1/lib/deglib/include/deglib/transformation/scalar/common.h +197 -0
  52. deglib-0.3.1/lib/deglib/include/deglib/transformation/scalar/fp16.h +204 -0
  53. deglib-0.3.1/lib/deglib/include/deglib/transformation/scalar/int4.h +319 -0
  54. deglib-0.3.1/lib/deglib/include/deglib/transformation/scalar/int8.h +284 -0
  55. deglib-0.3.1/lib/deglib/include/deglib/transformation/scalar/uint4.h +510 -0
  56. deglib-0.3.1/lib/deglib/include/deglib/transformation/scalar/uint7.h +285 -0
  57. deglib-0.3.1/lib/deglib/include/deglib/transformation/scalar/uint8.h +301 -0
  58. deglib-0.3.1/lib/deglib/include/deglib/transformation.h +612 -0
  59. deglib-0.3.1/lib/deglib/include/deglib/tuning.h +1212 -0
  60. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/utils/cpu.h +21 -5
  61. deglib-0.3.1/lib/deglib/include/deglib/utils/memory.h +83 -0
  62. {deglib-0.2.8 → deglib-0.3.1}/lib/test/CMakeLists.txt +7 -0
  63. {deglib-0.2.8 → deglib-0.3.1}/lib/test/src/common/test_helpers.h +20 -32
  64. {deglib-0.2.8 → deglib-0.3.1}/pyproject.toml +1 -1
  65. {deglib-0.2.8 → deglib-0.3.1}/setup.py +4 -4
  66. deglib-0.3.1/src/deg_cpp/bindings_distances.cpp +191 -0
  67. deglib-0.3.1/src/deg_cpp/bindings_graph.cpp +865 -0
  68. deglib-0.3.1/src/deg_cpp/bindings_optimization.cpp +35 -0
  69. deglib-0.3.1/src/deg_cpp/bindings_search.cpp +571 -0
  70. deglib-0.3.1/src/deg_cpp/bindings_transformation.cpp +749 -0
  71. deglib-0.3.1/src/deg_cpp/bindings_tuning.cpp +196 -0
  72. deglib-0.3.1/src/deg_cpp/deglib_cpp.cpp +16 -0
  73. deglib-0.3.1/src/deglib/__init__.py +45 -0
  74. {deglib-0.2.8 → deglib-0.3.1}/src/deglib/analysis.py +57 -4
  75. deglib-0.3.1/src/deglib/builder.py +616 -0
  76. deglib-0.3.1/src/deglib/cpu.py +112 -0
  77. deglib-0.3.1/src/deglib/distances.py +409 -0
  78. deglib-0.3.1/src/deglib/graph.py +1161 -0
  79. deglib-0.3.1/src/deglib/optimization.py +145 -0
  80. deglib-0.3.1/src/deglib/search.py +908 -0
  81. deglib-0.3.1/src/deglib/transformation.py +268 -0
  82. deglib-0.3.1/src/deglib/tuning.py +244 -0
  83. {deglib-0.2.8 → deglib-0.3.1}/src/deglib/utils.py +16 -5
  84. {deglib-0.2.8 → deglib-0.3.1/src/deglib.egg-info}/PKG-INFO +70 -61
  85. {deglib-0.2.8 → deglib-0.3.1}/src/deglib.egg-info/SOURCES.txt +36 -2
  86. {deglib-0.2.8 → deglib-0.3.1}/tests/test_analysis.py +2 -1
  87. {deglib-0.2.8 → deglib-0.3.1}/tests/test_builder.py +140 -54
  88. deglib-0.3.1/tests/test_cpu.py +20 -0
  89. deglib-0.3.1/tests/test_deglib.py +608 -0
  90. deglib-0.3.1/tests/test_distances.py +75 -0
  91. deglib-0.3.1/tests/test_evp_quantizer.py +90 -0
  92. {deglib-0.2.8 → deglib-0.3.1}/tests/test_filter.py +6 -5
  93. {deglib-0.2.8 → deglib-0.3.1}/tests/test_graph.py +369 -158
  94. deglib-0.3.1/tests/test_l2_normalize.py +52 -0
  95. deglib-0.3.1/tests/test_pareto_line.py +225 -0
  96. deglib-0.3.1/tests/test_presort.py +75 -0
  97. deglib-0.3.1/tests/test_recall_table.py +249 -0
  98. deglib-0.3.1/tests/test_rerank.py +278 -0
  99. deglib-0.3.1/tests/test_rotation_transform.py +127 -0
  100. deglib-0.3.1/tests/test_scalar_quantizer.py +234 -0
  101. deglib-0.3.1/tests/test_scalar_quantizer_int4.py +34 -0
  102. deglib-0.3.1/tests/test_searcher.py +700 -0
  103. deglib-0.3.1/tests/test_transformation.py +63 -0
  104. {deglib-0.2.8 → deglib-0.3.1}/tests/test_transformation_graph.py +139 -126
  105. deglib-0.3.1/tests/test_tuning.py +314 -0
  106. deglib-0.2.8/lib/deglib/include/deglib/distance/fp16_l2.h +0 -287
  107. deglib-0.2.8/lib/deglib/include/deglib/distance/fp32_l2.h +0 -286
  108. deglib-0.2.8/lib/deglib/include/deglib/distance/int8_ip.h +0 -566
  109. deglib-0.2.8/lib/deglib/include/deglib/distances.h +0 -334
  110. deglib-0.2.8/lib/deglib/include/deglib/graph/internal_graph.h +0 -1097
  111. deglib-0.2.8/lib/deglib/include/deglib/graph/readonly_graph.h +0 -290
  112. deglib-0.2.8/lib/deglib/include/deglib/graph.h +0 -1349
  113. deglib-0.2.8/lib/deglib/include/deglib/search/reranker.h +0 -603
  114. deglib-0.2.8/lib/deglib/include/deglib/search/searcher.h +0 -698
  115. deglib-0.2.8/lib/deglib/include/deglib/search.h +0 -14
  116. deglib-0.2.8/lib/deglib/include/deglib/transformation/scalar.h +0 -1362
  117. deglib-0.2.8/lib/deglib/include/deglib/transformation.h +0 -266
  118. deglib-0.2.8/lib/deglib/include/deglib/utils/memory.h +0 -23
  119. deglib-0.2.8/src/deg_cpp/deglib_cpp.cpp +0 -2548
  120. deglib-0.2.8/src/deglib/__init__.py +0 -83
  121. deglib-0.2.8/src/deglib/builder.py +0 -456
  122. deglib-0.2.8/src/deglib/cpu.py +0 -59
  123. deglib-0.2.8/src/deglib/distances.py +0 -149
  124. deglib-0.2.8/src/deglib/graph.py +0 -548
  125. deglib-0.2.8/src/deglib/optimization.py +0 -116
  126. deglib-0.2.8/src/deglib/search.py +0 -327
  127. deglib-0.2.8/src/deglib/transformation.py +0 -96
  128. deglib-0.2.8/tests/test_evp_quantizer.py +0 -132
  129. deglib-0.2.8/tests/test_l2_normalize.py +0 -58
  130. deglib-0.2.8/tests/test_presort.py +0 -97
  131. deglib-0.2.8/tests/test_rerank.py +0 -290
  132. deglib-0.2.8/tests/test_scalar_quantizer.py +0 -302
  133. deglib-0.2.8/tests/test_searcher.py +0 -350
  134. deglib-0.2.8/tests/test_transformation.py +0 -65
  135. {deglib-0.2.8 → deglib-0.3.1}/LICENSE +0 -0
  136. {deglib-0.2.8 → deglib-0.3.1}/MANIFEST.in +0 -0
  137. {deglib-0.2.8 → deglib-0.3.1}/lib/CMakeLists.txt +0 -0
  138. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/CMakeLists.txt +0 -0
  139. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/include/build.h +0 -0
  140. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/include/file_io.h +0 -0
  141. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/include/logging.h +0 -0
  142. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/include/repository.h +0 -0
  143. {deglib-0.2.8 → deglib-0.3.1}/lib/bench/include/stopwatch.h +0 -0
  144. {deglib-0.2.8 → deglib-0.3.1}/lib/cmake_modules/DetectCPUFeatures.cmake +0 -0
  145. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/CMakeLists.txt +0 -0
  146. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/fp32.h +0 -0
  147. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/int8.h +0 -0
  148. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/residual_mode.h +0 -0
  149. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/distance/uint8.h +0 -0
  150. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/filter.h +0 -0
  151. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/graph/intrusive_list.h +0 -0
  152. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/graph/mutable_graph.h +0 -0
  153. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/optimization/flas/junker_volgenant_solver.h +0 -0
  154. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/optimization/pruning.h +0 -0
  155. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/serialization.h +0 -0
  156. {deglib-0.2.8 → deglib-0.3.1}/lib/deglib/include/deglib/utils/random.h +0 -0
  157. {deglib-0.2.8 → deglib-0.3.1}/lib/test/src/unit/graph/test_dynamic_graph_common.h +0 -0
  158. {deglib-0.2.8 → deglib-0.3.1}/setup.cfg +0 -0
  159. {deglib-0.2.8 → deglib-0.3.1}/src/deglib.egg-info/dependency_links.txt +0 -0
  160. {deglib-0.2.8 → deglib-0.3.1}/src/deglib.egg-info/requires.txt +0 -0
  161. {deglib-0.2.8 → deglib-0.3.1}/src/deglib.egg-info/top_level.txt +0 -0
@@ -8,8 +8,8 @@ if(DEFINED PYTHON_EXECUTABLE)
8
8
  endif()
9
9
  find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
10
10
 
11
- # Add pybind11
12
- find_package(pybind11 CONFIG REQUIRED)
11
+ # Add nanobind
12
+ find_package(nanobind CONFIG REQUIRED)
13
13
 
14
14
  # disable benchmark and test building
15
15
  set(ENABLE_BENCHMARKS OFF CACHE BOOL "Disable benchmarks" FORCE)
@@ -26,7 +26,16 @@ endif()
26
26
 
27
27
  # Add cpp-deglib
28
28
  add_subdirectory(${DEGLIB_CPP_DIR} deglib_cpp_build)
29
- pybind11_add_module(deglib_cpp src/deg_cpp/deglib_cpp.cpp)
29
+ nanobind_add_module(
30
+ deglib_cpp NOMINSIZE
31
+ src/deg_cpp/deglib_cpp.cpp
32
+ src/deg_cpp/bindings_distances.cpp
33
+ src/deg_cpp/bindings_optimization.cpp
34
+ src/deg_cpp/bindings_transformation.cpp
35
+ src/deg_cpp/bindings_search.cpp
36
+ src/deg_cpp/bindings_graph.cpp
37
+ src/deg_cpp/bindings_tuning.cpp
38
+ )
30
39
 
31
40
  # Specify the include directories
32
41
  include_directories(${DEGLIB_CPP_DIR}/deglib/include)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deglib
3
- Version: 0.2.8
3
+ Version: 0.3.1
4
4
  Summary: Python bindings for the Dynamic Exploration Graph library by Nico Hezel
5
5
  Author: Nico Hezel
6
6
  Author-email: Bruno Schilling <bruno.schilling@htw-berlin.de>
@@ -69,13 +69,25 @@ To build and install the package directly from the repository:
69
69
  ```bash
70
70
  cd python/
71
71
  uv venv
72
- uv pip install setuptools==83.0.0 pybind11==3.0.4 build==1.5.0 wheel==0.48.0
72
+ uv pip install setuptools==83.0.0 nanobind==3.1.0 build==1.5.0 wheel==0.48.0
73
73
  uv run python setup.py copy_build_files
74
74
  uv pip install . --no-build-isolation
75
75
  ```
76
76
 
77
77
  ---
78
78
 
79
+ See [python/API.md](API.md) for the full API reference and [docs/python_metric_quantization_matrix.md](../docs/python_metric_quantization_matrix.md) for the complete metric/quantization behavior matrix.
80
+
81
+ ## API Layers: High-Level vs. Low-Level
82
+
83
+ Top-level `deglib` intentionally exports only the **High-Level API** and core result/config types:
84
+ - `deglib.build`, `deglib.presort`, `deglib.compress`, `deglib.reranker`, `deglib.reranker_with_data`, `deglib.searcher`, `deglib.load_graph`
85
+ - `deglib.DynamicExplorationGraph`, `deglib.Searcher`, `deglib.Reranker`, `deglib.SearchResults`, `deglib.Metric`, `deglib.OptimizationTarget`
86
+
87
+ All **Low-Level / Expert APIs** live in submodules (`deglib.graph.create_empty`, `deglib.builder.GraphBuilder`, `deglib.optimization.prune_non_mrng_edges`, `deglib.transformation.make_*`, `deglib.search.RecallTable`, `deglib.cpu.InstructionSet`, `deglib.analysis.analyze_graph`, `deglib.tuning.predict_*`).
88
+
89
+ ---
90
+
79
91
  ## Quickstart & Examples
80
92
 
81
93
  ### Basic Usage
@@ -90,14 +102,15 @@ num_samples, dims = 10_000, 128
90
102
  data = np.random.random((num_samples, dims)).astype(np.float32)
91
103
  query = np.random.random(dims).astype(np.float32)
92
104
 
93
- # 2. Build index directly from data (multithreaded by default)
94
- graph = deglib.builder.build_from_data(data, edges_per_vertex=32, show_progress=True)
105
+ # 2. Build index directly from data (multithreaded & optimized by default)
106
+ graph = deglib.build(data, edges_per_vertex=32, show_progress=True)
95
107
 
96
- # 3. Query top-k nearest neighbors
97
- indices, distances = graph.search(query, k=10, eps_or_ef=0.1)
108
+ # 3. Query top-k nearest neighbors (returns SearchResults with zero-copy .indices/.distances and telemetry)
109
+ res = graph.search(query, k=10, eps_or_ef=0.1)
98
110
 
99
- print("Nearest neighbors:", indices)
100
- print("Distances:", distances)
111
+ print("Nearest neighbors:", res.indices)
112
+ print("Distances:", res.distances)
113
+ print("Distance evals:", res.graph_distance_count, "| Hops:", res.graph_hop_count)
101
114
  ```
102
115
 
103
116
  ---
@@ -108,13 +121,12 @@ All search graphs are represented by `DynamicExplorationGraph`, backed by one of
108
121
 
109
122
  1. **Fixed-Capacity Mutable (`SizeBoundedGraph`)**: Memory is preallocated for a fixed maximum capacity. Fast and memory-efficient for static/batch datasets.
110
123
  ```python
111
- space = deglib.FloatSpace.create(dim=128, metric=deglib.Metric.FP32_L2)
112
- graph = deglib.create_empty(capacity=10_000, feature_space=space, edges_per_vertex=32)
124
+ graph = deglib.graph.create_empty(capacity=10_000, dim=128, edges_per_vertex=32, metric=deglib.Metric.FP32_L2)
113
125
  ```
114
126
 
115
127
  2. **Chunk-Allocated Mutable (`DynamicGraph`)**: Dynamically allocates memory in chunks (e.g. 1024 vertices per chunk). Ideal for streaming datasets where total capacity is unknown.
116
128
  ```python
117
- graph = deglib.create_dynamic_empty(feature_space=space, edges_per_vertex=32, chunk_size=1024)
129
+ graph = deglib.graph.create_dynamic_empty(dim=128, edges_per_vertex=32, metric=deglib.Metric.FP32_L2, chunk_size=1024)
118
130
  ```
119
131
 
120
132
  3. **Read-Only Deployment (`ReadOnlyGraph`)**: Stripped of mutation structures for minimal memory footprint and maximum query throughput.
@@ -131,13 +143,13 @@ All search graphs are represented by `DynamicExplorationGraph`, backed by one of
131
143
  graph.save_graph("index.deg")
132
144
 
133
145
  # Load as compact, optimized read-only graph for production search
134
- readonly_graph = deglib.load_readonly_graph("index.deg")
146
+ readonly_graph = deglib.load_graph("index.deg")
135
147
 
136
148
  # Load as dynamic graph supporting further insertions and deletions
137
- dynamic_graph = deglib.load_dynamic_graph("index.deg")
149
+ dynamic_graph = deglib.graph.load_dynamic_graph("index.deg")
138
150
 
139
151
  # Load as fixed-capacity mutable graph
140
- mutable_graph = deglib.load_mutable_graph("index.deg")
152
+ mutable_graph = deglib.graph.load_mutable_graph("index.deg")
141
153
  ```
142
154
 
143
155
  ---
@@ -150,15 +162,14 @@ For continuous additions and removals, use `GraphBuilder`:
150
162
  import numpy as np
151
163
  import deglib
152
164
  from deglib.builder import GraphBuilder, OptimizationTarget
153
- from deglib.distances import FloatSpace, Metric
165
+ from deglib.distances import Metric
154
166
 
155
167
  dims = 128
156
168
  max_capacity = 10_000
157
169
  edges_per_vertex = 32
158
170
 
159
- # 1. Create feature space and empty mutable graph
160
- space = FloatSpace.create(dims, metric=Metric.FP32_L2)
161
- graph = deglib.create_empty(max_capacity, space, edges_per_vertex)
171
+ # 1. Create empty mutable graph
172
+ graph = deglib.graph.create_empty(max_capacity, dims, edges_per_vertex, metric=Metric.FP32_L2)
162
173
 
163
174
  # 2. Initialize builder
164
175
  builder = GraphBuilder(graph, optimization_target=OptimizationTarget.StreamingData, seed=42)
@@ -186,7 +197,8 @@ from deglib.search import Filter, rerank
186
197
  allowed_ids = np.array([1, 5, 10, 42, 99], dtype=np.int32)
187
198
  search_filter = Filter(allowed_ids)
188
199
 
189
- indices, distances = graph.search(query, k=5, eps_or_ef=0.1, filter_labels=search_filter)
200
+ res = graph.search(query, k=5, eps_or_ef=0.1, filter_labels=search_filter)
201
+ indices, distances = res.indices, res.distances
190
202
 
191
203
  # Exact distance reranking across candidates
192
204
  queries = np.random.random((10, dims)).astype(np.float32)
@@ -194,7 +206,7 @@ candidates = np.random.randint(0, 1000, size=(10, 50), dtype=np.uint32)
194
206
  base_vectors = np.random.random((1000, dims)).astype(np.float32)
195
207
 
196
208
  top_indices, top_distances = rerank(
197
- space=graph.get_feature_space(),
209
+ metric=graph.get_metric(),
198
210
  queries=queries,
199
211
  candidate_indices=candidates,
200
212
  base_vectors=base_vectors,
@@ -211,68 +223,56 @@ DEG supports exploratory search directly from existing vertex labels (single or
211
223
 
212
224
  ```python
213
225
  # Explore graph starting from entry vertex label 105
214
- explored_labels, distances = graph.explore(entry_external_label=105, k=10, eps_or_ef=0.1, include_entry=False)
226
+ exp_res = graph.explore(entry_external_label=105, k=10, eps_or_ef=0.1, include_entry=False)
227
+ explored_labels, distances = exp_res.indices, exp_res.distances
215
228
 
216
229
  # Batch exploration from multiple entry vertices in parallel
217
230
  batch_entries = np.array([105, 210, 315], dtype=np.uint32)
218
- batch_labels, batch_distances = graph.explore(batch_entries, k=10, eps_or_ef=0.1, threads=4)
231
+ batch_exp = graph.explore(batch_entries, k=10, eps_or_ef=0.1, threads=4)
232
+ batch_labels, batch_distances = batch_exp.indices, batch_exp.distances
219
233
 
220
234
  # Retrieve graph neighbors directly
221
235
  neighbors = graph.get_neighbors(105)
222
- batch_neighbors = graph.get_neighbors_batch(batch_entries, threads=4) # shape: (3, edges_per_vertex)
236
+ batch_neighbors = graph.get_neighbors(batch_entries, threads=4) # shape: (3, edges_per_vertex)
223
237
  ```
224
238
 
225
239
  ---
226
240
 
227
241
  ### Graph Optimization, Quantization & Reranking Pipeline
228
242
 
229
- A complete end-to-end pipeline demonstrating **FLAS pre-sorting**, **multithreaded graph building**, **Int8 quantization**, **ReadOnlyGraph conversion**, and deployment with **`Searcher`** for automatic query quantization and high-precision reranking:
243
+ A complete end-to-end pipeline demonstrating **FLAS pre-sorting**, **multithreaded graph building**, **Int8 self-quantization**, **ReadOnlyGraph conversion**, and deployment with **`Searcher`** for automatic query quantization and high-precision reranking:
230
244
 
231
245
  ```python
232
246
  import numpy as np
233
247
  import deglib
234
- from deglib.optimization import presort
235
- from deglib.transformation import make_scalar_quantizer_int8
236
- from deglib.search import create_searcher
237
248
 
238
249
  num_vectors, dims = 10_000, 128
239
250
  data = np.random.randn(num_vectors, dims).astype(np.float32)
240
251
  query = np.random.randn(dims).astype(np.float32)
241
252
 
242
- # 1. Pre-sort vectors using FLAS for improved memory locality and index construction speed
243
- perm = presort(data, metric=deglib.Metric.FP32_InnerProduct, show_progress=True)
244
- sorted_data = data[perm]
245
-
246
- # 2. Build exploration graph on unquantized/original data
247
- graph = deglib.builder.build_from_data(
248
- sorted_data,
249
- metric=deglib.Metric.FP32_InnerProduct,
253
+ # 1. Pre-sort with FLAS and build exploration graph in FP32
254
+ graph = deglib.build(
255
+ data,
256
+ metric="cosine",
250
257
  edges_per_vertex=32,
258
+ presort=True,
259
+ optimize=False,
251
260
  show_progress=True,
252
261
  )
253
262
 
254
- # 3. Quantize features to Int8 for memory reduction and ultra-fast search
255
- quantizer = make_scalar_quantizer_int8(sorted_data)
256
- quant_int8_data = quantizer.quantize(sorted_data)
257
- int8_space = deglib.FloatSpace.create(dims, deglib.Metric.Int8_InnerProduct)
258
-
259
- # 4. Convert mutable graph to a compact ReadOnlyGraph equipped with the quantized features
260
- readonly_graph = graph.to_readonly(
261
- feature_space=int8_space, custom_features=quant_int8_data, transformations=[quantizer]
263
+ # 2. Extract FP16 reranker from FP32 graph and create compressed 8-bit Searcher
264
+ reranker = deglib.reranker(graph, compress="16bit")
265
+ searcher = deglib.searcher(
266
+ graph,
267
+ compress="8bit",
268
+ reranker=reranker,
262
269
  )
263
270
 
264
- # 5. Create high-performance Searcher equipped with base vectors for exact candidate reranking
265
- rerank_space = deglib.FloatSpace.create(dims, deglib.Metric.FP32_InnerProduct)
266
- searcher = create_searcher(
267
- graph=readonly_graph,
268
- rerank_space=rerank_space,
269
- rerank_data=sorted_data,
270
- )
271
-
272
- # 6. Query search (query is automatically quantized and top candidates are reranked)
273
- indices, distances = searcher.search(query, k=10, eps_or_ef=0.1, rerank_factor=1.5, return_distances=True)
274
- print("Top-10 nearest neighbor indices:", indices)
275
- print("Top-10 exact distances:", distances)
271
+ # 3. Query search (query is automatically quantized and top candidates are reranked)
272
+ res = searcher.search(query, k=10, eps_or_ef=0.1, rerank_factor=1.5, return_distances=True)
273
+ print("Top-10 nearest neighbor indices:", res.indices)
274
+ print("Top-10 exact distances:", res.distances)
275
+ print("Graph dists:", res.graph_distance_count, "| Rerank dists:", res.rerank_distance_count)
276
276
  ```
277
277
 
278
278
  ---
@@ -295,10 +295,13 @@ Controls the topology optimization strategy:
295
295
 
296
296
  ```python
297
297
  # Mode 1: Relative distance margin (default: eps_or_ef=0.1)
298
- indices, distances = searcher.search(query, k=10, eps_or_ef=0.1)
298
+ res = searcher.search(query, k=10, eps_or_ef=0.1, return_distances=True)
299
299
 
300
300
  # Mode 2: Fixed candidate pool (HNSW-style)
301
- indices, distances = searcher.search(query, k=10, eps_or_ef=128)
301
+ res_ef = searcher.search(query, k=10, eps_or_ef=128, return_distances=True)
302
+
303
+ # Optional: hard per-query budget of graph distance computations (0 = unlimited)
304
+ indices = searcher.search(query, k=10, eps_or_ef=128, max_distance_computation_count=700).indices
302
305
  ```
303
306
 
304
307
  ### Supported Metrics & Data Types
@@ -306,11 +309,17 @@ indices, distances = searcher.search(query, k=10, eps_or_ef=128)
306
309
  - `Metric.FP32_InnerProduct`: Inner product / cosine distance (`np.float32`)
307
310
  - `Metric.Uint8_L2`: 8-bit unsigned integer Euclidean distance (`np.uint8`)
308
311
  - `Metric.Uint8_InnerProduct`: 8-bit unsigned integer inner product (`np.uint8`)
309
- - `Metric.FP16_L2`: 16-bit half-precision Euclidean distance (`np.uint16`)
310
- - `Metric.FP16_InnerProduct`: 16-bit half-precision inner product (`np.uint16`)
311
- - `Metric.EVP_InnerProduct`: Quantized Extreme Value Property bit-packed vectors (`np.uint8`)
312
+ - `Metric.FP16_L2`: 16-bit half-precision Euclidean distance (`np.float16` / `np.uint16`)
313
+ - `Metric.FP16_InnerProduct`: 16-bit half-precision inner product (`np.float16` / `np.uint16`)
314
+ - `Metric.EVP_InnerProduct`: Quantized Equi-Voronoi Polytopes (EVP) bit-packed vectors (`np.uint8`)
312
315
  - `Metric.Int8_InnerProduct`: 8-bit signed integer inner product (`np.int8`)
313
316
  - `Metric.Int8_L2`: 8-bit signed integer Euclidean distance (`np.int8`)
317
+ - `Metric.Uint4_L2`: 4-bit unsigned integer Euclidean distance, packed 2 per byte (`np.uint8`)
318
+ - `Metric.Uint4_InnerProduct`: 4-bit unsigned integer inner product, packed 2 per byte (`np.uint8`)
319
+ - `Metric.Int4_L2`: 4-bit signed integer Euclidean distance, packed 2 per byte (`np.uint8`)
320
+ - `Metric.Int4_InnerProduct`: 4-bit signed integer inner product, packed 2 per byte (`np.uint8`)
321
+ - `Metric.UInt7_L2`: 7-bit unsigned integer Euclidean distance in [0, 127] (`np.int8`)
322
+ - `Metric.UInt7_InnerProduct`: 7-bit unsigned integer inner product in [0, 127] (`np.int8`)
314
323
 
315
324
  ---
316
325
 
@@ -342,7 +351,7 @@ If you want to contribute, modify C++ bindings, run tests, or build release pack
342
351
  # 1. Setup virtual environment and dependencies (using uv)
343
352
  cd python/
344
353
  uv venv
345
- uv pip install setuptools==83.0.0 pybind11==3.0.4 build==1.5.0 wheel==0.48.0
354
+ uv pip install setuptools==83.0.0 nanobind==3.1.0 build==1.5.0 wheel==0.48.0
346
355
  uv run python setup.py copy_build_files
347
356
 
348
357
  # 2. Install in editable mode
@@ -41,13 +41,25 @@ To build and install the package directly from the repository:
41
41
  ```bash
42
42
  cd python/
43
43
  uv venv
44
- uv pip install setuptools==83.0.0 pybind11==3.0.4 build==1.5.0 wheel==0.48.0
44
+ uv pip install setuptools==83.0.0 nanobind==3.1.0 build==1.5.0 wheel==0.48.0
45
45
  uv run python setup.py copy_build_files
46
46
  uv pip install . --no-build-isolation
47
47
  ```
48
48
 
49
49
  ---
50
50
 
51
+ See [python/API.md](API.md) for the full API reference and [docs/python_metric_quantization_matrix.md](../docs/python_metric_quantization_matrix.md) for the complete metric/quantization behavior matrix.
52
+
53
+ ## API Layers: High-Level vs. Low-Level
54
+
55
+ Top-level `deglib` intentionally exports only the **High-Level API** and core result/config types:
56
+ - `deglib.build`, `deglib.presort`, `deglib.compress`, `deglib.reranker`, `deglib.reranker_with_data`, `deglib.searcher`, `deglib.load_graph`
57
+ - `deglib.DynamicExplorationGraph`, `deglib.Searcher`, `deglib.Reranker`, `deglib.SearchResults`, `deglib.Metric`, `deglib.OptimizationTarget`
58
+
59
+ All **Low-Level / Expert APIs** live in submodules (`deglib.graph.create_empty`, `deglib.builder.GraphBuilder`, `deglib.optimization.prune_non_mrng_edges`, `deglib.transformation.make_*`, `deglib.search.RecallTable`, `deglib.cpu.InstructionSet`, `deglib.analysis.analyze_graph`, `deglib.tuning.predict_*`).
60
+
61
+ ---
62
+
51
63
  ## Quickstart & Examples
52
64
 
53
65
  ### Basic Usage
@@ -62,14 +74,15 @@ num_samples, dims = 10_000, 128
62
74
  data = np.random.random((num_samples, dims)).astype(np.float32)
63
75
  query = np.random.random(dims).astype(np.float32)
64
76
 
65
- # 2. Build index directly from data (multithreaded by default)
66
- graph = deglib.builder.build_from_data(data, edges_per_vertex=32, show_progress=True)
77
+ # 2. Build index directly from data (multithreaded & optimized by default)
78
+ graph = deglib.build(data, edges_per_vertex=32, show_progress=True)
67
79
 
68
- # 3. Query top-k nearest neighbors
69
- indices, distances = graph.search(query, k=10, eps_or_ef=0.1)
80
+ # 3. Query top-k nearest neighbors (returns SearchResults with zero-copy .indices/.distances and telemetry)
81
+ res = graph.search(query, k=10, eps_or_ef=0.1)
70
82
 
71
- print("Nearest neighbors:", indices)
72
- print("Distances:", distances)
83
+ print("Nearest neighbors:", res.indices)
84
+ print("Distances:", res.distances)
85
+ print("Distance evals:", res.graph_distance_count, "| Hops:", res.graph_hop_count)
73
86
  ```
74
87
 
75
88
  ---
@@ -80,13 +93,12 @@ All search graphs are represented by `DynamicExplorationGraph`, backed by one of
80
93
 
81
94
  1. **Fixed-Capacity Mutable (`SizeBoundedGraph`)**: Memory is preallocated for a fixed maximum capacity. Fast and memory-efficient for static/batch datasets.
82
95
  ```python
83
- space = deglib.FloatSpace.create(dim=128, metric=deglib.Metric.FP32_L2)
84
- graph = deglib.create_empty(capacity=10_000, feature_space=space, edges_per_vertex=32)
96
+ graph = deglib.graph.create_empty(capacity=10_000, dim=128, edges_per_vertex=32, metric=deglib.Metric.FP32_L2)
85
97
  ```
86
98
 
87
99
  2. **Chunk-Allocated Mutable (`DynamicGraph`)**: Dynamically allocates memory in chunks (e.g. 1024 vertices per chunk). Ideal for streaming datasets where total capacity is unknown.
88
100
  ```python
89
- graph = deglib.create_dynamic_empty(feature_space=space, edges_per_vertex=32, chunk_size=1024)
101
+ graph = deglib.graph.create_dynamic_empty(dim=128, edges_per_vertex=32, metric=deglib.Metric.FP32_L2, chunk_size=1024)
90
102
  ```
91
103
 
92
104
  3. **Read-Only Deployment (`ReadOnlyGraph`)**: Stripped of mutation structures for minimal memory footprint and maximum query throughput.
@@ -103,13 +115,13 @@ All search graphs are represented by `DynamicExplorationGraph`, backed by one of
103
115
  graph.save_graph("index.deg")
104
116
 
105
117
  # Load as compact, optimized read-only graph for production search
106
- readonly_graph = deglib.load_readonly_graph("index.deg")
118
+ readonly_graph = deglib.load_graph("index.deg")
107
119
 
108
120
  # Load as dynamic graph supporting further insertions and deletions
109
- dynamic_graph = deglib.load_dynamic_graph("index.deg")
121
+ dynamic_graph = deglib.graph.load_dynamic_graph("index.deg")
110
122
 
111
123
  # Load as fixed-capacity mutable graph
112
- mutable_graph = deglib.load_mutable_graph("index.deg")
124
+ mutable_graph = deglib.graph.load_mutable_graph("index.deg")
113
125
  ```
114
126
 
115
127
  ---
@@ -122,15 +134,14 @@ For continuous additions and removals, use `GraphBuilder`:
122
134
  import numpy as np
123
135
  import deglib
124
136
  from deglib.builder import GraphBuilder, OptimizationTarget
125
- from deglib.distances import FloatSpace, Metric
137
+ from deglib.distances import Metric
126
138
 
127
139
  dims = 128
128
140
  max_capacity = 10_000
129
141
  edges_per_vertex = 32
130
142
 
131
- # 1. Create feature space and empty mutable graph
132
- space = FloatSpace.create(dims, metric=Metric.FP32_L2)
133
- graph = deglib.create_empty(max_capacity, space, edges_per_vertex)
143
+ # 1. Create empty mutable graph
144
+ graph = deglib.graph.create_empty(max_capacity, dims, edges_per_vertex, metric=Metric.FP32_L2)
134
145
 
135
146
  # 2. Initialize builder
136
147
  builder = GraphBuilder(graph, optimization_target=OptimizationTarget.StreamingData, seed=42)
@@ -158,7 +169,8 @@ from deglib.search import Filter, rerank
158
169
  allowed_ids = np.array([1, 5, 10, 42, 99], dtype=np.int32)
159
170
  search_filter = Filter(allowed_ids)
160
171
 
161
- indices, distances = graph.search(query, k=5, eps_or_ef=0.1, filter_labels=search_filter)
172
+ res = graph.search(query, k=5, eps_or_ef=0.1, filter_labels=search_filter)
173
+ indices, distances = res.indices, res.distances
162
174
 
163
175
  # Exact distance reranking across candidates
164
176
  queries = np.random.random((10, dims)).astype(np.float32)
@@ -166,7 +178,7 @@ candidates = np.random.randint(0, 1000, size=(10, 50), dtype=np.uint32)
166
178
  base_vectors = np.random.random((1000, dims)).astype(np.float32)
167
179
 
168
180
  top_indices, top_distances = rerank(
169
- space=graph.get_feature_space(),
181
+ metric=graph.get_metric(),
170
182
  queries=queries,
171
183
  candidate_indices=candidates,
172
184
  base_vectors=base_vectors,
@@ -183,68 +195,56 @@ DEG supports exploratory search directly from existing vertex labels (single or
183
195
 
184
196
  ```python
185
197
  # Explore graph starting from entry vertex label 105
186
- explored_labels, distances = graph.explore(entry_external_label=105, k=10, eps_or_ef=0.1, include_entry=False)
198
+ exp_res = graph.explore(entry_external_label=105, k=10, eps_or_ef=0.1, include_entry=False)
199
+ explored_labels, distances = exp_res.indices, exp_res.distances
187
200
 
188
201
  # Batch exploration from multiple entry vertices in parallel
189
202
  batch_entries = np.array([105, 210, 315], dtype=np.uint32)
190
- batch_labels, batch_distances = graph.explore(batch_entries, k=10, eps_or_ef=0.1, threads=4)
203
+ batch_exp = graph.explore(batch_entries, k=10, eps_or_ef=0.1, threads=4)
204
+ batch_labels, batch_distances = batch_exp.indices, batch_exp.distances
191
205
 
192
206
  # Retrieve graph neighbors directly
193
207
  neighbors = graph.get_neighbors(105)
194
- batch_neighbors = graph.get_neighbors_batch(batch_entries, threads=4) # shape: (3, edges_per_vertex)
208
+ batch_neighbors = graph.get_neighbors(batch_entries, threads=4) # shape: (3, edges_per_vertex)
195
209
  ```
196
210
 
197
211
  ---
198
212
 
199
213
  ### Graph Optimization, Quantization & Reranking Pipeline
200
214
 
201
- A complete end-to-end pipeline demonstrating **FLAS pre-sorting**, **multithreaded graph building**, **Int8 quantization**, **ReadOnlyGraph conversion**, and deployment with **`Searcher`** for automatic query quantization and high-precision reranking:
215
+ A complete end-to-end pipeline demonstrating **FLAS pre-sorting**, **multithreaded graph building**, **Int8 self-quantization**, **ReadOnlyGraph conversion**, and deployment with **`Searcher`** for automatic query quantization and high-precision reranking:
202
216
 
203
217
  ```python
204
218
  import numpy as np
205
219
  import deglib
206
- from deglib.optimization import presort
207
- from deglib.transformation import make_scalar_quantizer_int8
208
- from deglib.search import create_searcher
209
220
 
210
221
  num_vectors, dims = 10_000, 128
211
222
  data = np.random.randn(num_vectors, dims).astype(np.float32)
212
223
  query = np.random.randn(dims).astype(np.float32)
213
224
 
214
- # 1. Pre-sort vectors using FLAS for improved memory locality and index construction speed
215
- perm = presort(data, metric=deglib.Metric.FP32_InnerProduct, show_progress=True)
216
- sorted_data = data[perm]
217
-
218
- # 2. Build exploration graph on unquantized/original data
219
- graph = deglib.builder.build_from_data(
220
- sorted_data,
221
- metric=deglib.Metric.FP32_InnerProduct,
225
+ # 1. Pre-sort with FLAS and build exploration graph in FP32
226
+ graph = deglib.build(
227
+ data,
228
+ metric="cosine",
222
229
  edges_per_vertex=32,
230
+ presort=True,
231
+ optimize=False,
223
232
  show_progress=True,
224
233
  )
225
234
 
226
- # 3. Quantize features to Int8 for memory reduction and ultra-fast search
227
- quantizer = make_scalar_quantizer_int8(sorted_data)
228
- quant_int8_data = quantizer.quantize(sorted_data)
229
- int8_space = deglib.FloatSpace.create(dims, deglib.Metric.Int8_InnerProduct)
230
-
231
- # 4. Convert mutable graph to a compact ReadOnlyGraph equipped with the quantized features
232
- readonly_graph = graph.to_readonly(
233
- feature_space=int8_space, custom_features=quant_int8_data, transformations=[quantizer]
235
+ # 2. Extract FP16 reranker from FP32 graph and create compressed 8-bit Searcher
236
+ reranker = deglib.reranker(graph, compress="16bit")
237
+ searcher = deglib.searcher(
238
+ graph,
239
+ compress="8bit",
240
+ reranker=reranker,
234
241
  )
235
242
 
236
- # 5. Create high-performance Searcher equipped with base vectors for exact candidate reranking
237
- rerank_space = deglib.FloatSpace.create(dims, deglib.Metric.FP32_InnerProduct)
238
- searcher = create_searcher(
239
- graph=readonly_graph,
240
- rerank_space=rerank_space,
241
- rerank_data=sorted_data,
242
- )
243
-
244
- # 6. Query search (query is automatically quantized and top candidates are reranked)
245
- indices, distances = searcher.search(query, k=10, eps_or_ef=0.1, rerank_factor=1.5, return_distances=True)
246
- print("Top-10 nearest neighbor indices:", indices)
247
- print("Top-10 exact distances:", distances)
243
+ # 3. Query search (query is automatically quantized and top candidates are reranked)
244
+ res = searcher.search(query, k=10, eps_or_ef=0.1, rerank_factor=1.5, return_distances=True)
245
+ print("Top-10 nearest neighbor indices:", res.indices)
246
+ print("Top-10 exact distances:", res.distances)
247
+ print("Graph dists:", res.graph_distance_count, "| Rerank dists:", res.rerank_distance_count)
248
248
  ```
249
249
 
250
250
  ---
@@ -267,10 +267,13 @@ Controls the topology optimization strategy:
267
267
 
268
268
  ```python
269
269
  # Mode 1: Relative distance margin (default: eps_or_ef=0.1)
270
- indices, distances = searcher.search(query, k=10, eps_or_ef=0.1)
270
+ res = searcher.search(query, k=10, eps_or_ef=0.1, return_distances=True)
271
271
 
272
272
  # Mode 2: Fixed candidate pool (HNSW-style)
273
- indices, distances = searcher.search(query, k=10, eps_or_ef=128)
273
+ res_ef = searcher.search(query, k=10, eps_or_ef=128, return_distances=True)
274
+
275
+ # Optional: hard per-query budget of graph distance computations (0 = unlimited)
276
+ indices = searcher.search(query, k=10, eps_or_ef=128, max_distance_computation_count=700).indices
274
277
  ```
275
278
 
276
279
  ### Supported Metrics & Data Types
@@ -278,11 +281,17 @@ indices, distances = searcher.search(query, k=10, eps_or_ef=128)
278
281
  - `Metric.FP32_InnerProduct`: Inner product / cosine distance (`np.float32`)
279
282
  - `Metric.Uint8_L2`: 8-bit unsigned integer Euclidean distance (`np.uint8`)
280
283
  - `Metric.Uint8_InnerProduct`: 8-bit unsigned integer inner product (`np.uint8`)
281
- - `Metric.FP16_L2`: 16-bit half-precision Euclidean distance (`np.uint16`)
282
- - `Metric.FP16_InnerProduct`: 16-bit half-precision inner product (`np.uint16`)
283
- - `Metric.EVP_InnerProduct`: Quantized Extreme Value Property bit-packed vectors (`np.uint8`)
284
+ - `Metric.FP16_L2`: 16-bit half-precision Euclidean distance (`np.float16` / `np.uint16`)
285
+ - `Metric.FP16_InnerProduct`: 16-bit half-precision inner product (`np.float16` / `np.uint16`)
286
+ - `Metric.EVP_InnerProduct`: Quantized Equi-Voronoi Polytopes (EVP) bit-packed vectors (`np.uint8`)
284
287
  - `Metric.Int8_InnerProduct`: 8-bit signed integer inner product (`np.int8`)
285
288
  - `Metric.Int8_L2`: 8-bit signed integer Euclidean distance (`np.int8`)
289
+ - `Metric.Uint4_L2`: 4-bit unsigned integer Euclidean distance, packed 2 per byte (`np.uint8`)
290
+ - `Metric.Uint4_InnerProduct`: 4-bit unsigned integer inner product, packed 2 per byte (`np.uint8`)
291
+ - `Metric.Int4_L2`: 4-bit signed integer Euclidean distance, packed 2 per byte (`np.uint8`)
292
+ - `Metric.Int4_InnerProduct`: 4-bit signed integer inner product, packed 2 per byte (`np.uint8`)
293
+ - `Metric.UInt7_L2`: 7-bit unsigned integer Euclidean distance in [0, 127] (`np.int8`)
294
+ - `Metric.UInt7_InnerProduct`: 7-bit unsigned integer inner product in [0, 127] (`np.int8`)
286
295
 
287
296
  ---
288
297
 
@@ -314,7 +323,7 @@ If you want to contribute, modify C++ bindings, run tests, or build release pack
314
323
  # 1. Setup virtual environment and dependencies (using uv)
315
324
  cd python/
316
325
  uv venv
317
- uv pip install setuptools==83.0.0 pybind11==3.0.4 build==1.5.0 wheel==0.48.0
326
+ uv pip install setuptools==83.0.0 nanobind==3.1.0 build==1.5.0 wheel==0.48.0
318
327
  uv run python setup.py copy_build_files
319
328
 
320
329
  # 2. Install in editable mode
@@ -34,10 +34,7 @@ namespace deglib::benchmark {
34
34
  * @param base_gt Optional contiguous BaseGroundTruth buffer
35
35
  * @return GraphStats with all computed statistics
36
36
  */
37
- inline deglib::analysis::GraphStats analyze_graph(
38
- const deglib::graph::InternalGraph& graph,
39
- const BaseGroundTruth& base_gt = {}
40
- ) {
37
+ inline deglib::analysis::GraphStats analyze_graph(const deglib::graph::InternalGraph& graph, const BaseGroundTruth& base_gt = {}) {
41
38
  auto stats = deglib::analysis::analyze_graph(graph, base_gt.data(), base_gt.rows, base_gt.k);
42
39
 
43
40
  log("Graph Statistics:\n");
@@ -133,11 +130,11 @@ static float test_approx_anns(
133
130
 
134
131
  uint32_t correct = 0;
135
132
  const auto& gt = ground_truth[i];
136
- while (result_queue.empty() == false) {
137
- const auto& result = result_queue.top();
133
+ while (result_queue.results.empty() == false) {
134
+ const auto& result = result_queue.results.top();
138
135
  const auto external_id = graph.getExternalLabel(result.getIdentifier());
139
136
  if (std::binary_search(gt.begin(), gt.end(), external_id)) correct++;
140
- result_queue.pop();
137
+ result_queue.results.pop();
141
138
  }
142
139
 
143
140
  corrects[thread_id] += correct;
@@ -172,11 +169,11 @@ static float test_approx_explore(
172
169
 
173
170
  uint32_t correct = 0;
174
171
  const auto& gt = ground_truth[i];
175
- while (result_queue.empty() == false) {
176
- const auto& result = result_queue.top();
172
+ while (result_queue.results.empty() == false) {
173
+ const auto& result = result_queue.results.top();
177
174
  const auto external_id = graph.getExternalLabel(result.getIdentifier());
178
175
  if (std::binary_search(gt.begin(), gt.end(), external_id)) correct++;
179
- result_queue.pop();
176
+ result_queue.results.pop();
180
177
  }
181
178
 
182
179
  corrects[thread_id] += correct;
@@ -212,11 +209,11 @@ static std::vector<float> estimate_recall(
212
209
  total += result_queue.size();
213
210
 
214
211
  size_t local_correct = 0;
215
- while (result_queue.empty() == false) {
216
- const auto internal_index = result_queue.top().getIdentifier();
212
+ while (result_queue.results.empty() == false) {
213
+ const auto internal_index = result_queue.results.top().getIdentifier();
217
214
  const auto external_id = graph.getExternalLabel(internal_index);
218
215
  if (std::binary_search(gt.begin(), gt.end(), external_id)) local_correct++;
219
- result_queue.pop();
216
+ result_queue.results.pop();
220
217
  }
221
218
  correct += local_correct;
222
219
  });