Skip to content

feat: add vector quantization and HNSW index configuration#1261

Open
zhangzhenghao wants to merge 1 commit intogorse-io:masterfrom
zhangzhenghao:feature/vector-quantization-config
Open

feat: add vector quantization and HNSW index configuration#1261
zhangzhenghao wants to merge 1 commit intogorse-io:masterfrom
zhangzhenghao:feature/vector-quantization-config

Conversation

@zhangzhenghao
Copy link
Copy Markdown
Contributor

Summary

This PR adds vector quantization and HNSW index configuration support for vector databases.

Changes

  1. VectorConfig struct - Unified configuration for quantization and HNSW parameters
  2. Database interface - Updated AddCollection to accept VectorConfig
  3. Quantization support per database:
    • Milvus: SQ (int8), PQ
    • Qdrant: SQ (int8), PQ
    • Weaviate: PQ only
    • SQLite: Not supported (returns error)

Quantization Types

Type Memory Saving Description
none 0% float32 vectors (default)
sq 75% Scalar quantization (int8)
pq ~90% Product quantization

Configuration Example

[database.vector]
quantization = "sq"  # none | sq | pq
sq_bits = 8          # SQ bits (only 8 supported)
pq_subvectors = 8    # PQ subvector count
pq_bits = 8          # PQ bits per subvector
hnsw_m = 16          # HNSW M parameter
hnsw_ef_construction = 200
hnsw_ef_search = 64

Breaking Change

The AddCollection method signature has changed.

TODO

  • Regenerate protobuf files
  • Add tests for quantization configurations

@zhangzhenghao zhangzhenghao force-pushed the feature/vector-quantization-config branch from 76f8e77 to 631ef86 Compare May 1, 2026 12:22
- Add VectorConfig struct with quantization (SQ, PQ) and HNSW parameters
- Update Database interface to accept VectorConfig in AddCollection
- Implement HNSW parameters for Milvus, Qdrant, Weaviate, SQLite
- SQ/PQ quantization support requires additional API exploration
- Proxy uses DefaultVectorConfig (protobuf VectorConfig pending regeneration)
- Update tests to use DefaultVectorConfig()

Quantization types:
- none: float32 vectors (default)
- sq: scalar quantization (pending full implementation)
- pq: product quantization (pending full implementation)

Note: Full protobuf support for VectorConfig requires regenerating
vector_store.pb.go and vector_store_grpc.pb.go locally with protoc.
@zhangzhenghao zhangzhenghao force-pushed the feature/vector-quantization-config branch from 631ef86 to 009c1bd Compare May 1, 2026 12:27
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 68.18182% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.33%. Comparing base (09bd49a) to head (009c1bd).

Files with missing lines Patch % Lines
storage/vectors/weaviate.go 46.66% 6 Missing and 2 partials ⚠️
storage/vectors/milvus.go 50.00% 1 Missing and 1 partial ⚠️
storage/vectors/qdrant.go 84.61% 1 Missing and 1 partial ⚠️
storage/vectors/sqlite.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1261      +/-   ##
==========================================
+ Coverage   72.95%   73.33%   +0.38%     
==========================================
  Files          91       91              
  Lines       16715    16747      +32     
==========================================
+ Hits        12194    12281      +87     
+ Misses       3279     3248      -31     
+ Partials     1242     1218      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

2 participants