More ergonomic spherical::iface::Quantizer constructors - #1418
Open
Mark Hildebrand (hildebrandmw) wants to merge 1 commit into
Open
Mark Hildebrand (hildebrandmw) wants to merge 1 commit into
Mark Hildebrand (hildebrandmw) wants to merge 1 commit into
Conversation
Mark Hildebrand (hildebrandmw)
requested review from
a team
and
a lite review from Copilot
September 18, 2026 17:59
Copilot started reviewing on behalf of
Mark Hildebrand (hildebrandmw)
September 18, 2026 18:00
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Remove unused imports from the provider doctest so it passes with warnings treated as errors.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds an ergonomic SphericalQuantizer::as_quantizer constructor for creating erased quantizer trait objects.
Changes:
- Adds the new constructor.
- Updates tests, examples, and benchmarks.
- Removes duplicated quantizer-erasure helpers.
File summaries
| File | Summary |
|---|---|
diskann-quantization/src/spherical/quantizer.rs |
Adds the type-erasing constructor. |
diskann-quantization/src/spherical/iface.rs |
Updates examples and tests. |
diskann-bftree/src/quant.rs |
Simplifies test quantizer creation. |
diskann-bftree/src/provider.rs |
Updates the provider documentation example. |
diskann-benchmark/src/index/bftree/spherical.rs |
Uses the new constructor for dispatch. |
diskann-benchmark/src/index/bftree/spherical_streaming.rs |
Uses the new constructor for streaming dispatch. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+151
to
+155
| /// let quantizer = SphericalQuantizer::train( | ||
| /// data.as_view(), TransformKind::Null, | ||
| /// SupportedMetric::SquaredL2, PreScale::None, | ||
| /// &mut rng, GlobalAllocator, | ||
| /// ).unwrap(); | ||
| /// let imp = iface::Impl::<1>::new(sq).unwrap(); | ||
| /// let poly = Poly::new(imp, GlobalAllocator).unwrap(); | ||
| /// let quantizer: Poly<dyn iface::Quantizer> = poly!(iface::Quantizer, poly); | ||
| /// ) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1418 +/- ##
==========================================
- Coverage 92.64% 91.51% -1.13%
==========================================
Files 527 527
Lines 103055 103064 +9
==========================================
- Hits 95472 94320 -1152
- Misses 7583 8744 +1161
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Currently, constructing the
spherical::iface::Quantizertrait object from aspherical::SphericalQuantizeris a pain, especially when erasing across multiple bit widths.This PR adds a method
spherical::SphericalQuantizer::as_quantizerfor constructing awhich simplifies things considerably.