Skip to content

[diskann-quantization] Make block-transposed matrix construction fallible - #1618

Merged
juchen-ms (partychen) merged 3 commits into
microsoft:mainfrom
partychen:juchen-microsoft-fallible-matrix-constructors
Dec 2, 2026
Merged

juchen-ms (partychen) merged 3 commits into
microsoft:mainfrom
partychen:juchen-microsoft-fallible-matrix-constructors

Conversation

@partychen

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 34731cea319dc35a7c283365df3d1deb86d55c14

Dimension Assessment Rationale
Change confidence 9/10 ↑ 518 default-feature and 517 no-default-feature unit tests pass; workspace all-targets Clippy and ARM64 Windows cross-check pass.
↓ Linux and ARM64 runtime behavior, emulated ISA paths, and coverage were not validated locally.
Diagnosis confidence 9/10 ↑ Regression tests demonstrate valid row-major views whose padded packing overflows; packing now returns typed errors before row scratch allocation.
Evidence fit 8/10 ↑ Tests directly cover padded-extent overflow and duplicated error-chain presentation.
↓ No production incident trace was supplied.
  • Does this PR have a descriptive title that could go in our release notes?
  • Does this PR add any new dependencies?
  • Does this PR modify any existing APIs?
  • Is the change to the API backwards compatible?
  • Should this result in any changes to our documentation, either updating existing docs or adding new ones?

Reference Issues/PRs

Relates to #1583. Extracts its fallible-constructor foundation without TopK, traversal, SIMD, or ISA-dispatch refactors.

What does this implement/fix? Briefly explain your changes.

Replace panicking block-transposed constructors with try_new, try_from_strided, and try_from_matrix_view. Propagate packing overflow through MaxSim preparation, k-means initialization, product training, and pivot construction, including widened query conversion. Preserve same-layout cloning.

Expose a dedicated transparent LloydsError, document 16-row tail padding and byte-budget overflow, and separate k-means++ selection counts, packing context, and overflow details into nonduplicating error-chain layers.

This intentionally changes constructor names and Lloyd's return type. No dependencies are added. Two commits separate the constructor migration from error-interface improvements.

Any other comments?

Validation on Windows x86-64:

  • cargo fmt --all --check — passed.
  • cargo test -p diskann-quantization --lib --quiet — passed, 518 tests.
  • cargo test -p diskann-quantization --no-default-features --lib --quiet — passed, 517 tests.
  • cargo test -p diskann-quantization --doc --quiet — passed, 31 tests; 6 ignored.
  • cargo clippy --workspace --all-targets -- -D warnings — passed.
  • cargo clippy -p diskann-quantization --all-targets --all-features -- -D warnings — passed.
  • cargo check -p diskann-quantization --all-targets --all-features --target aarch64-pc-windows-msvc --quiet — passed (cross-compilation only).
  • With RUSTDOCFLAGS='-D warnings -D rustdoc::all', cargo doc -p diskann-quantization --no-deps --all-features --document-private-items --quiet — passed.
  • git diff --check origin/main...HEAD — passed.

Not run locally: full workspace tests, Linux tests, ARM64 runtime tests, SDE baseline/AVX-512 emulation, and coverage collection.

juchen-ms (partychen) and others added 2 commits December 1, 2026 12:25
Extract fallible packing and propagate overflow through k-means, product training, pivot construction, and MaxSim factories without changing ISA dispatch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Expose a dedicated transparent LloydsError and document 16-row padding and allocation-byte limits. Keep k-means++ selection counts, packing context, and overflow details in separate source-chain layers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@partychen
juchen-ms (partychen) requested review from a team and a balanced review from Copilot December 1, 2026 09:13

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.

🟢 Approval recommended

No active review issues are reported for the changes introducing fallible block-transposed matrix construction.

No open issues 🎉

What changed in this PR

Makes block-transposed matrix construction fallible in diskann-quantization, providing the overflow-handling foundation extracted from #1583 without its TopK or kernel refactors.

Changes:

  • Replaces panicking constructors with fallible APIs and propagates overflow through MaxSim, k-means, product training, and pivot construction.
  • Introduces LloydsError and separates k-means++ error-chain messages to avoid duplicated details.
  • Updates callers and tests, adds overflow regressions, and documents padded allocation limits.
File Description
diskann-quantization/​src/​product/​train.rs Propagates packing failures through product-training errors.
diskann-quantization/​src/​product/​tables/​transposed/​pivots.rs Adds overflow handling to pivot chunk construction.
diskann-quantization/​src/​multi_vector/​matrix.rs Adds equality traits to Overflow.
diskann-quantization/​src/​multi_vector/​distance/​factory.rs Propagates query-packing and conversion overflow through MaxSim construction.
diskann-quantization/​src/​multi_vector/​block_transposed.rs Replaces panicking constructors and adds padded-overflow tests.
diskann-quantization/​src/​matrix_kernels/​maxsim/​packed_i8_x_unpacked_i8.rs Migrates integer kernel test setup to fallible construction.
diskann-quantization/​src/​matrix_kernels/​maxsim/​packed_f32_x_unpacked_f32.rs Migrates f32 kernel test setup to fallible construction.
diskann-quantization/​src/​matrix_kernels/​maxsim/​packed_f32_x_unpacked_f16.rs Migrates mixed-precision kernel test setup to fallible construction.
diskann-quantization/​src/​matrix_kernels/​blocks/​packed.rs Updates packed-block tests for the constructor API.
diskann-quantization/​src/​algorithms/​kmeans/​plusplus.rs Reports packing failures before scratch allocation and improves error chaining.
diskann-quantization/​src/​algorithms/​kmeans/​lloyds.rs Returns LloydsError, documents allocation limits, and tests overflow handling.

Review effort: Balanced

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.79263% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.26%. Comparing base (7d76ac7) to head (ded50f7).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...-quantization/src/multi_vector/distance/factory.rs 71.42% 26 Missing ⚠️
diskann-quantization/src/product/train.rs 22.22% 7 Missing ⚠️

❌ Your patch status has failed because the patch coverage (84.79%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1618      +/-   ##
==========================================
- Coverage   92.27%   92.26%   -0.01%     
==========================================
  Files         633      633              
  Lines      133563   133627      +64     
==========================================
+ Hits       123239   123291      +52     
- Misses      10324    10336      +12     
Flag Coverage Δ
miri 92.26% <84.79%> (-0.01%) ⬇️
unittests 92.21% <84.79%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...skann-quantization/src/algorithms/kmeans/lloyds.rs 99.29% <100.00%> (+0.03%) ⬆️
...ann-quantization/src/algorithms/kmeans/plusplus.rs 99.50% <100.00%> (+0.01%) ⬆️
...n-quantization/src/matrix_kernels/blocks/packed.rs 99.70% <100.00%> (ø)
...matrix_kernels/maxsim/packed_f32_x_unpacked_f16.rs 100.00% <100.00%> (ø)
...matrix_kernels/maxsim/packed_f32_x_unpacked_f32.rs 99.54% <100.00%> (ø)
...c/matrix_kernels/maxsim/packed_i8_x_unpacked_i8.rs 99.53% <100.00%> (ø)
...-quantization/src/multi_vector/block_transposed.rs 99.10% <100.00%> (+<0.01%) ⬆️
diskann-quantization/src/multi_vector/matrix.rs 96.29% <ø> (ø)
...antization/src/product/tables/transposed/pivots.rs 98.30% <100.00%> (+0.10%) ⬆️
diskann-quantization/src/product/train.rs 92.50% <22.22%> (-1.89%) ⬇️
... and 1 more

... and 12 files with indirect coverage changes

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two small bits of feedback. In general, this change is surprisingly noisy. Failing in the low-level constructors is reasonable. I'm not as convinced that propagating at the higher levels is better than panicking, but I don't feel that strongly about it.

Use the existing error-chain formatter and assert_contains helper instead of manually walking and counting error messages. Keep imports at module scope.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@partychen
juchen-ms (partychen) merged commit cdea177 into microsoft:main Dec 2, 2026
31 checks passed
juchen-ms (partychen) added a commit to partychen/DiskANN that referenced this pull request Dec 2, 2026
Integrate microsoft#1618 and remove the foundation migration from the TopK diff.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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