Skip to content

feat: add vector quantization configuration#1261

Merged
zhenghaoz merged 18 commits into
gorse-io:masterfrom
zhangzhenghao:feature/vector-quantization-config
Jun 28, 2026
Merged

feat: add vector quantization configuration#1261
zhenghaoz merged 18 commits into
gorse-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

codecov Bot commented May 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.77226% with 146 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.49%. Comparing base (83a2266) to head (4f581c7).

Files with missing lines Patch % Lines
storage/vectors/milvus.go 67.39% 28 Missing and 17 partials ⚠️
storage/vectors/qdrant.go 76.85% 24 Missing and 4 partials ⚠️
storage/vectors/weaviate.go 72.85% 14 Missing and 5 partials ⚠️
master/master.go 59.52% 9 Missing and 8 partials ⚠️
storage/vectors/sqlite.go 57.50% 12 Missing and 5 partials ⚠️
storage/vectors/database.go 0.00% 12 Missing ⚠️
storage/vectors/proxy.go 84.61% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1261      +/-   ##
==========================================
- Coverage   73.67%   73.49%   -0.18%     
==========================================
  Files          93       93              
  Lines       17316    17739     +423     
==========================================
+ Hits        12757    13037     +280     
- Misses       3214     3312      +98     
- Partials     1345     1390      +45     

☔ View full report in Codecov by Harness.
📢 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.

zhenghaoz added 16 commits June 21, 2026 10:41
…tization-config

# Conflicts:
#	config/config.go
…on handling

- Updated Milvus client import paths and initialization to align with the latest SDK changes.
- Refactored index creation and search parameter handling to utilize new index types and options.
- Removed deprecated methods and variables related to RQ query bits.
- Enhanced the AddCollection and AddVectors methods to support new collection and vector configurations.
- Consolidated quantization tests into a single method for better coverage and maintainability.
@zhenghaoz zhenghaoz changed the title feat: add vector quantization and HNSW index configuration feat: add vector quantization configuration Jun 28, 2026
@zhenghaoz zhenghaoz merged commit 7153ac6 into gorse-io:master Jun 28, 2026
12 of 13 checks passed
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