Skip to content

Add int8 data type support to diskann-garnet/vectorset#1060

Draft
Copilot wants to merge 6 commits into
mainfrom
copilot/add-int8-support-vectorset
Draft

Add int8 data type support to diskann-garnet/vectorset#1060
Copilot wants to merge 6 commits into
mainfrom
copilot/add-int8-support-vectorset

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

  • Analyze existing SB8 test patterns (all use VectorQuantType::NoQuant)
  • Add create_test_index_q8 helper in ffi_tests.rs
  • Add basic Q8 insert/search tests in ffi_tests.rs
  • Parameterize run_sb8_recall in ffi_recall_tests.rs to accept quant type
  • Add Q8 recall grid tests in ffi_recall_tests.rs
  • Verify tests compile and pass (all 53 garnet tests pass)
  • Clippy clean

- Add SB8 variant to VectorValueType for signed 8-bit input
- Handle SB8 in interpret_vector (direct storage and f32 conversion)
- Handle Q8 quant type in create_index to create index with i8 VectorRepr
- Handle FP32 + Q8 path for converting f32 input to i8 storage
- Add Int8 variant to vectorset DataType enum
- Implement Element trait for i8 and wire up dispatch
- Use SB8/Q8 protocol values in ingest and query commands
- Update README to document SB8 and Q8 extensions

Agent-Logs-Url: https://github.com/microsoft/DiskANN/sessions/7664c19b-7cdd-4a84-8249-951b2e2e040b

Co-authored-by: harsha-simhadri <5590673+harsha-simhadri@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/DiskANN/sessions/9adc0f60-1eec-419c-ae00-3fbc815d2e5b

Co-authored-by: harsha-simhadri <5590673+harsha-simhadri@users.noreply.github.com>
@harsha-simhadri harsha-simhadri requested a review from Copilot May 18, 2026 18:44
@harsha-simhadri
Copy link
Copy Markdown
Contributor

@copilot start reviewing this draft PR

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 18, 2026

@copilot start reviewing this draft PR

Here's a summary of this PR's changes:

Rust FFI (diskann-garnet/src/lib.rs)

  • Added VectorValueType::SB8 (signed int8, discriminant = 3) to match the C# enum
  • Added VectorQuantType::Q8 arm in create_index → dispatches to create_index_impl::<i8>
  • Extended interpret_vector:
    • FP32 input + Q8 quant: converts f32→i8→u8 for storage
    • SB8 input + Q8 quant: zero-copy passthrough (raw bytes are already i8)
    • SB8 input + NoQuant: sign-extends each byte to f32
  • Byte-length calculation handles SB8 same as XB8 (1 byte/dim)

vectorset CLI (vectorset/src/main.rs)

  • Added DataType::Int8 variant, impl Element for i8
  • Dispatches SB8 value type and Q8 quantizer tokens for ingest/query

Tests (diskann-garnet/src/ffi_tests.rs, ffi_recall_tests.rs)

  • add_check_and_remove_sb8_vector: insert, ID validation, search, remove lifecycle
  • sb8_search_after_delete: verifies deletion exclusion
  • sb8_search_multi_results: multi-vector nearest-neighbor ordering
  • sb8_grid_l2_recall_3d_7 and sb8_grid_l2_recall_4d_5: grid recall tests matching the existing XB8/FP32 pattern

Garnet companion patch (garnet-sb8-support.patch.md)

  • Instructions for adding VectorValueType.SB8 and wiring it through parsing, DiskANNService, and VectorManager in the C# Garnet repo

All 45 tests pass (including 5 new SB8 tests). Build is clean.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds end-to-end int8 (SB8) vector support to the diskann-garnet FFI layer and the vectorset ingestion/query tool, parallel to the existing uint8 (XB8) path. A new VectorValueType::SB8 is wired through create_index/interpret_vector with a new VectorQuantType::Q8 storage path (i8 backing) and a SB8 → NoQuant conversion path (sign-extended to f32). The PR also includes a Markdown document describing the corresponding manual edits required in the external microsoft/garnet C# server, and an unrelated tweak to vectorset/config.toml.example.

Changes:

  • Add VectorValueType::SB8 and a VectorQuantType::Q8 branch in diskann-garnet, including FP32↔Q8 and SB8↔NoQuant conversions.
  • Add Int8/SB8/Q8 handling to the vectorset CLI so it can ingest and query int8 datasets.
  • Add SB8 FFI unit tests and recall tests; add a Garnet-side patch instructions doc and update the README.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
diskann-garnet/src/lib.rs New SB8 enum variant and Q8 storage / SB8 interpretation paths in create_index and interpret_vector.
diskann-garnet/src/ffi_tests.rs Adds SB8 helpers and tests covering insert/remove/search, negative values, large external IDs, and bitmap filtering (all using a NoQuant index).
diskann-garnet/src/ffi_recall_tests.rs Adds SB8 recall helpers and 1D–4D grid recall tests against an f32/NoQuant index.
diskann-garnet/README.md Documents new SB8 value type and Q8 quantizer and recommended pairings.
vectorset/src/main.rs Adds Int8 DataType, Element for i8, and SB8/Q8 arguments in ingest/query pipelines.
vectorset/config.toml.example Replaces the commented scope placeholder with scope = "" (unrelated to int8 support).
garnet-sb8-support.patch.md New document with manual edit instructions for the external microsoft/garnet repo to mirror the SB8/Q8 wiring.

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

Comment thread diskann-garnet/src/lib.rs
Comment on lines +249 to +263
VectorQuantType::Q8 => {
if let Ok(index) = create_index_impl::<i8>(
quant_type,
config,
dim as usize,
metric_type,
max_degree as usize,
callbacks,
context,
) {
Arc::into_raw(index).cast::<c_void>()
} else {
ptr::null()
}
}
Comment thread vectorset/config.toml.example Outdated
Comment thread garnet-sb8-support.patch.md Outdated
Adds tests exercising the VectorQuantType::Q8 code path (native i8 index):
- create_test_index_q8 helper in ffi_tests.rs
- Q8 insert/remove, search, negative values, FP32→Q8 truncation tests
- Parameterized run_sb8_recall_with_quant in ffi_recall_tests.rs
- Q8 recall grid tests (1D–4D)

Agent-Logs-Url: https://github.com/microsoft/DiskANN/sessions/163f33b7-e6d4-46ba-b54a-03c4f95f2d60

Co-authored-by: harsha-simhadri <5590673+harsha-simhadri@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.

Add support for i8 vectors int8 support in diskann-garnet/vectorset

3 participants