Skip to content

Relax Copy to Clone on Standard<T> matrix elements#1265

Merged
suri-kumkaran merged 2 commits into
mainfrom
users/suryangupta/remove_copy_from_diskann_quantization
Jul 21, 2026
Merged

Relax Copy to Clone on Standard<T> matrix elements#1265
suri-kumkaran merged 2 commits into
mainfrom
users/suryangupta/remove_copy_from_diskann_quantization

Conversation

@suri-kumkaran

Copy link
Copy Markdown
Contributor

What

Mat<Standard<T>> required T: Copy. Now it works for any Clone element (and any T for views) — matching what diskann-utils::Matrix<T> already allows.

Why

The Copy bound wasn't load-bearing; it came from a naive derive and a few over-broad where clauses. Relaxing it is a prerequisite for unifying Matrix<T> with Mat<Standard<T>>.

How

  • Standard<T>: hand-write unconditional Copy/Clone (it's just dims + PhantomData), drop the unused Eq, keep PartialEq.
  • Drop T: Copy from Repr/ReprMut/ReprOwned/NewRef/NewMut and the Mat/MatRef/MatMut impl blocks.
  • NewOwned/NewCloned: CopyClone (value.clone(), .cloned()).
  • Add a String-element test covering fill / from_fn / mutation / clone / views.

Repr metadata stays Copy (required by Repr: Copy, free for PhantomData) — only the element bound relaxes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 relaxes Mat<Standard<T>> to support non-Copy element types by switching construction/cloning paths from T: Copy to T: Clone, while keeping Standard<T> metadata Copy (so Repr: Copy continues to hold). This aligns multi_vector::Mat behavior more closely with diskann-utils::Matrix<T> and unblocks future unification work.

Changes:

  • Relax T: Copy bounds to T: Clone (or remove entirely for views) across Standard<T>’s Repr*/New* impls and Mat/MatRef/MatMut impl blocks.
  • Update owned initialization and cloning paths to use .clone() / .cloned() instead of copying.
  • Add a String-backed test to validate fill, from_fn, mutation, clone, and slice-backed views for non-Copy elements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread diskann-quantization/src/multi_vector/matrix.rs Outdated
@codecov-commenter

codecov-commenter commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.16%. Comparing base (1552e51) to head (00e516b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
diskann-quantization/src/multi_vector/matrix.rs 92.50% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1265      +/-   ##
==========================================
+ Coverage   90.16%   91.16%   +0.99%     
==========================================
  Files         509      510       +1     
  Lines       97238    97291      +53     
==========================================
+ Hits        87678    88694    +1016     
+ Misses       9560     8597     -963     
Flag Coverage Δ
miri 91.16% <92.50%> (+0.99%) ⬆️
unittests 91.12% <92.50%> (+1.28%) ⬆️

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

Files with missing lines Coverage Δ
diskann-quantization/src/multi_vector/matrix.rs 95.53% <92.50%> (-0.18%) ⬇️

... and 53 files with indirect coverage changes

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

@hildebrandmw hildebrandmw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Just a few minor comments.

Comment thread diskann-quantization/src/multi_vector/matrix.rs
Comment thread diskann-quantization/src/multi_vector/matrix.rs Outdated
Comment thread diskann-quantization/src/multi_vector/matrix.rs Outdated
Comment thread diskann-quantization/src/multi_vector/matrix.rs Outdated
@suri-kumkaran
suri-kumkaran merged commit 028d8d5 into main Jul 21, 2026
24 checks passed
@suri-kumkaran
suri-kumkaran deleted the users/suryangupta/remove_copy_from_diskann_quantization branch July 21, 2026 08:52
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