Skip to content

feat(vector-quantization): add RaBitQ support for VectorChord#386

Open
qdrddr wants to merge 2 commits intovectorize-io:mainfrom
qdrddr:vchord-rabitq-quantized
Open

feat(vector-quantization): add RaBitQ support for VectorChord#386
qdrddr wants to merge 2 commits intovectorize-io:mainfrom
qdrddr:vchord-rabitq-quantized

Conversation

@qdrddr
Copy link
Contributor

@qdrddr qdrddr commented Feb 16, 2026

Add environment variables and validation for vector quantization. Update alembic migrations to handle dynamic embedding dimensions and a new migration that converts embeddings to rabitq8/rabitq4 types. Provide helper to quantize embeddings on insert and query. Pass quantization flags through memory engine and extension context. Add docker‑compose file reference and ignore it in .gitignore. Include comprehensive tests for config, helpers and migration. Document quantization options, trade‑offs and usage examples.

#385

Add environment variables and validation for vector quantization.
Update alembic migrations to handle dynamic embedding dimensions and a new
migration that converts embeddings to rabitq8/rabitq4 types.
Provide helper to quantize embeddings on insert and query.
Pass quantization flags through memory engine and extension context.
Add docker‑compose file reference and ignore it in .gitignore.
Include comprehensive tests for config, helpers and migration.
Document quantization options, trade‑offs and usage examples.
return f'"{schema}".' if schema else ""


def upgrade() -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this new file is not needed - check the migration we do at api startup

text_search_ext = _detect_text_search_extension()

# Read embedding dimension from environment, defaulting to 384
embedding_dimension = int(os.getenv("DEFAULT_EMBEDDING_DIMENSION", "384"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

  1. this env is not using Hindsight config convention
  2. why we need it? it just adds confusion - just let Hindsight handles the correct dimension from the configured embedding model

if embedding_str:
embedding_expr = quantize_embedding(eval(embedding_str), config.vector_quantization_type)
else:
embedding_expr = "NULL"
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should raise exception here, something went really wrong

from ..embeddings import quantize_embedding
config = get_config()
if embedding_str:
embedding_expr = quantize_embedding(eval(embedding_str), config.vector_quantization_type)
Copy link
Collaborator

Choose a reason for hiding this comment

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

eval???

if embedding_str:
embedding_expr = quantize_embedding(eval(embedding_str), config.vector_quantization_type)
else:
embedding_expr = "NULL"
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should raise exception here, something went really wrong

from .tags import build_tags_where_clause_simple

# Build vector reference with optional quantization
config = get_config()
Copy link
Collaborator

Choose a reason for hiding this comment

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

use quantize_embedding

# Get config for quantization settings
config = get_config()
# Build vector reference with optional quantization
if config.vector_quantization_enabled:
Copy link
Collaborator

Choose a reason for hiding this comment

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

quantize_embedding

# Get config for quantization settings
config = get_config()
# Build vector reference with optional quantization
if config.vector_quantization_enabled:
Copy link
Collaborator

Choose a reason for hiding this comment

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

quantize_embedding

# Convert embedding to string for asyncpg vector type and apply quantization if enabled
from .embeddings import quantize_embedding
config = get_config()
embedding_expr = quantize_embedding(embedding[0], config.vector_quantization_type) if embedding else None
Copy link
Collaborator

Choose a reason for hiding this comment

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

raise if None pls

otel_deployment_environment: str

# Vector quantization (RaBitQ for VectorChord)
vector_quantization_enabled: bool = static(DEFAULT_VECTOR_QUANTIZATION_ENABLED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

since this is specifically for vchord, it should be vector_extension_vchord_quantization_enabled and vector_extension_vchord_quantization_type

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