Repository navigation
[diskann-quantization] Make block-transposed matrix construction fallible - #1618
Conversation
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>
There was a problem hiding this comment.
🟢 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
LloydsErrorand 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 Report❌ Patch coverage is
❌ 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@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Mark Hildebrand (hildebrandmw)
left a comment
There was a problem hiding this comment.
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>
Integrate microsoft#1618 and remove the foundation migration from the TopK diff. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
34731cea319dc35a7c283365df3d1deb86d55c14↓ Linux and ARM64 runtime behavior, emulated ISA paths, and coverage were not validated locally.
↓ No production incident trace was supplied.
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, andtry_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).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.