Skip to content

Remove unnecessary distance function implementations.#1008

Merged
hildebrandmw merged 3 commits into
mainfrom
mhildebr/remove-unnecessary-impls
May 4, 2026
Merged

Remove unnecessary distance function implementations.#1008
hildebrandmw merged 3 commits into
mainfrom
mhildebr/remove-unnecessary-impls

Conversation

@hildebrandmw
Copy link
Copy Markdown
Contributor

Remove unnecessary distance function implementations. These are no longer needed now that distance computations are plumbed through ElementRef instead of Element directly.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DistanceFunction impls for DistanceComputer that accepted &&[u8] / &Vec<u8> wrappers.
  • Removed DistanceFunction / PreprocessedDistanceFunction impls that adapted arc_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.

Comment thread diskann-providers/src/model/graph/provider/async_/memory_quant_vector_provider.rs Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.69%. Comparing base (d2ec7d0) to head (7008363).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1008   +/-   ##
=======================================
  Coverage   90.69%   90.69%           
=======================================
  Files         459      459           
  Lines       85030    85002   -28     
=======================================
- Hits        77115    77092   -23     
+ Misses       7915     7910    -5     
Flag Coverage Δ
miri 90.69% <100.00%> (+<0.01%) ⬆️
unittests 90.65% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ovider/async_/fast_memory_quant_vector_provider.rs 98.46% <100.00%> (ø)
...ph/provider/async_/memory_quant_vector_provider.rs 98.26% <100.00%> (-0.10%) ⬇️
diskann-providers/src/model/pq/distance/dynamic.rs 91.30% <ø> (+4.38%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@hildebrandmw hildebrandmw enabled auto-merge (squash) May 4, 2026 18:15
@hildebrandmw hildebrandmw disabled auto-merge May 4, 2026 21:06
@hildebrandmw hildebrandmw merged commit 65857ad into main May 4, 2026
26 checks passed
@hildebrandmw hildebrandmw deleted the mhildebr/remove-unnecessary-impls branch May 4, 2026 21:06
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants