Remove unnecessary distance function implementations.#1008
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes now-redundant DistanceFunction overload impls (previously used to smooth over extra reference layers / Vec<u8> wrappers) after distance computations were moved to flow through ElementRef rather than Element.
Changes:
- Removed several
DistanceFunctionimpls forDistanceComputerthat accepted&&[u8]/&Vec<u8>wrappers. - Removed
DistanceFunction/PreprocessedDistanceFunctionimpls that adaptedarc_swap::Guard<Arc<Vec<u8>>>to slices in the in-memory quant provider. - Updated affected tests to pass
&[u8](via.as_slice()/ deref) and adjusted trait imports accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
diskann-providers/src/model/pq/distance/dynamic.rs |
Drops wrapper DistanceFunction impls for DistanceComputer (keeping the core slice-based impls). |
diskann-providers/src/model/graph/provider/async_/memory_quant_vector_provider.rs |
Removes Guard-based distance trait impls; updates tests/imports to use slice-based calls. |
diskann-providers/src/model/graph/provider/async_/fast_memory_quant_vector_provider.rs |
Updates tests to pass &[u8] directly instead of &&[u8]. |
diskann-providers/src/model/graph/provider/async_/bf_tree/quant_vector_provider.rs |
Updates tests to pass &[u8] (via .as_slice()) for quant distance comparisons. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1008 +/- ##
=======================================
Coverage 90.69% 90.69%
=======================================
Files 459 459
Lines 85030 85002 -28
=======================================
- Hits 77115 77092 -23
+ Misses 7915 7910 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
harsha-simhadri
approved these changes
May 2, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
JordanMaples
approved these changes
May 4, 2026
arkrishn94
added a commit
that referenced
this pull request
May 5, 2026
Bump version to 0.51.0 due to propagate changes to downstream consumers ## Breaking API changes (AI Generated) - **`ObjectPool` moved** (#975): now lives in `diskann-utils`. Update imports from `diskann::...::ObjectPool` → `diskann_utils::ObjectPool`. - **`AlignedSlice` removed** (#994): the `AlignedSlice` abstraction in `diskann-vector` is gone. Code that converted between vector representations through `AlignedSlice` should now use the `Poly` / `CastFromSlice` polymorphic interfaces directly (see `diskann-vector::conversion` and `diskann-quantization::alloc::poly`). Storage that previously held `AlignedSlice` values should hold `Poly<T, A>` instead. - **`AsThreadPool` generic removed** (#967): functions that previously took `pool: impl AsThreadPool` now take `pool: &RayonThreadPool`. Pass a borrow of an existing pool; remove the generic parameter from your call sites. - **`sgemm()` returns `Result`** (#997): in `diskann-linalg`, the new signature is: ```rust pub fn sgemm( atranspose: Transpose, btranspose: Transpose, m: usize, n: usize, k: usize, alpha: f32, a: &[f32], b: &[f32], beta: Option<f32>, c: &mut [f32], ) -> Result<(), SgemmError> ``` `SgemmError` has variants `InvalidMatrixDimensions { matrix_name, expected_rows, expected_cols, actual_len }` and `DimensionOverflow { matrix_name, rows, cols }`. Replace previous panic-on-bad-input assumptions with explicit handling. - **Benchmarks are stateful** (#995): the `Benchmark` impls in `diskann-benchmark` are no longer stateless unit structs. Each benchmark type now has a `::new()` constructor (often holding `PhantomData<T>` or plugin state), and registration uses an instance: ```rust // before benchmarks.register("name", MyBench); // after benchmarks.register("name", MyBench::<T>::new()); ``` If you wrote a custom benchmark, give it a `new()` and register an instance. Combined with #996, search-side benchmarks now compose `Plugins<Provider, Phase, Strategy>` and expose builder methods like `.search(plugin)` to register search plugins on the instance. - **`diskann-benchmark`: `async` → `graph-index`** (#1009): the benchmark category previously named `async` was renamed to `graph-index`. JSON config `type` values and example file names changed accordingly: - `async-build` → `graph-index-build` - `async-dynamic-run` → `graph-index-dynamic-run` - and the same prefix swap for `*-pq`, `*-sq`, `*-spherical-quantization`, etc. Update any benchmark config files, scripts, or CI that reference the old `async-*` names. - **`diskann-disk` buffer alignment decoupled from `block_size`** (#984): code that assumed I/O buffer alignment equals the disk block size should now configure alignment explicitly. ## Non-breaking - New cache-aware block-transposed Chamfer/MaxSim distance for f32/f16 (#863). - A/A benchmark documentation (#974); CI publish workflow improvements (#755, #1017); openssl bump (#973); `compute_closest_centers` allocation reduction (#980). - **`DistanceComputer` `'static` bound relaxed** (#1007) and **redundant `DistanceFunction` impls removed** (#1008) **Full Changelog**: v0.50.1...v0.51.0
arkrishn94
added a commit
that referenced
this pull request
May 11, 2026
…m_row_inplace` (#976) .Couple of small independent cleanups for PQ. ## Move `calculate_chunk_offsets[_auto]` to `ChunkOffsets` as a constructor. These two functions are pure prefix-sum math over `dimensions` and `num_pq_chunks`. `ChunkOffsetsBase` / `ChunkOffsetsView` in `diskann-quantization::views` is the natural home for it. I've moved the logic into two constructors - `from_dim` and `from_dim_into` for `ChunkOffsets` and `ChunkOffsetsView` respectively to support both allocation patterns. All in-repo call sites have been updated. There might be some overlapping edits with #1010. ## Minor changes - `QueryComputer` and `DistanceComputer` had six trampoline impls forwarding `&Vec<u8>` and `&&[u8]` arguments to the canonical `&[u8]` impls. `ElementRef` in the accessor now allows us to get rid of these! This might be conflicting with #1008 - Inline `accum_row_inplace` from `diskann-providers\src\model\pq` at the two call-sites. - Move `get_chunk_from_training_data` in pq_construction.rs from public API into tests where it is used.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove unnecessary distance function implementations. These are no longer needed now that distance computations are plumbed through
ElementRefinstead ofElementdirectly.