Skip to content

More ergonomic spherical::iface::Quantizer constructors - #1418

Open
Mark Hildebrand (hildebrandmw) wants to merge 1 commit into
mainfrom
mhildebr/quantizer
Open

Mark Hildebrand (hildebrandmw) wants to merge 1 commit into
mainfrom
mhildebr/quantizer

Conversation

@hildebrandmw

@hildebrandmw Mark Hildebrand (hildebrandmw) commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Currently, constructing the spherical::iface::Quantizer trait object from a spherical::SphericalQuantizer is a pain, especially when erasing across multiple bit widths.

This PR adds a method spherical::SphericalQuantizer::as_quantizer for constructing a

Poly<dyn spherical::iface::Quantizer<GlobalAllocator>, GlobalAllocator>

which simplifies things considerably.

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.

🟡 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-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.51%. Comparing base (8a22f25) to head (240c4b2).

Files with missing lines Patch % Lines
diskann-quantization/src/spherical/iface.rs 80.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
miri 91.51% <94.44%> (-1.13%) ⬇️
unittests 91.26% <94.44%> (-1.33%) ⬇️

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

Files with missing lines Coverage Δ
diskann-bftree/src/provider.rs 92.82% <ø> (ø)
diskann-bftree/src/quant.rs 88.23% <100.00%> (ø)
diskann-quantization/src/spherical/quantizer.rs 98.15% <100.00%> (+0.01%) ⬆️
diskann-quantization/src/spherical/iface.rs 91.33% <80.00%> (-0.17%) ⬇️

... and 44 files with indirect coverage changes

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

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.

3 participants