Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions engine/clients/pgvector/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
}

DISTANCE_MAPPING_CREATE_RUST = {
Distance.L2: "l2_ops",
Distance.COSINE: "cosine_ops",
Distance.DOT: "dot_ops",
Distance.L2: "vector_l2_ops",
Distance.COSINE: "vector_cos_ops",
Distance.DOT: "vector_dot_ops",
}

DISTANCE_MAPPING_SEARCH = {
Expand Down
7 changes: 1 addition & 6 deletions engine/clients/pgvector/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ def search_one(cls, vector: List[float], meta_conditions, top: Optional[int], sc
cur.execute("BEGIN;")
# set index create parameter
for key in cls.search_params["params"].keys():
if cls.engine_type == "c":
cur.execute(f"SET LOCAL {key} = {cls.search_params['params'][key]};")
else:
# pgvector_rs only support hnsw
cur.execute(f"SET LOCAL vectors.k = {cls.search_params['params']['hnsw.ef_search']};")
break
cur.execute(f"SET LOCAL {key} = {cls.search_params['params'][key]};")

meta_conditions = cls.parser.parse(meta_conditions)
if meta_conditions:
Expand Down
16 changes: 9 additions & 7 deletions engine/clients/pgvector/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def upload_batch(cls, ids: List[int], vectors: List[list], metadata: List[Option
raise RuntimeError("PGVector batch upload unhealthy")
# Getting the names of structured data columns based on the first meta information.
col_name_tuple = ('id', 'vector')
col_type_tuple = ('%s', '%s::real[]')
col_type_tuple = ('%s', '%s')
if metadata[0] is not None:
for col_name in list(metadata[0].keys()):
col_name_tuple += (col_name,)
col_type_tuple += ('%s',)

insert_data = []
for i in range(0, len(ids)):
temp_tuple = (ids[i], vectors[i])
temp_tuple = (ids[i], str(vectors[i]))
if metadata[i] is not None:
for col_name in list(metadata[i].keys()):
value = metadata[i][col_name]
Expand Down Expand Up @@ -74,11 +74,6 @@ def post_upload(cls, distance):
if cls.engine_type == "rust":
create_index_command = f"""
CREATE INDEX ON {PGVECTOR_INDEX} USING vectors (vector {cls.distance}) WITH (options=$$
capacity = {int(cls.vector_count*1.2)}
[vectors]
memmap = "ram"
[algorithm.hnsw]
memmap = "ram"
{index_options_rust}
$$);
"""
Expand All @@ -92,3 +87,10 @@ def post_upload(cls, distance):
with cls.conn.cursor() as cur:
cur.execute("SELECT phase, tuples_done, tuples_total FROM pg_stat_progress_create_index;")
cls.conn.commit()
if cls.engine_type == "rust":
with cls.conn.cursor() as cur:
indexing = True
while indexing:
cur.execute("SELECT idx_indexing FROM pg_vector_index_stat;")
indexing = cur.fetchone()[0]
cls.conn.commit()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"platform": "CloudTest_v0.0.4",
"index_type": "HNSW",
"dataset": "laion-768-5m-ip",
"version": "pg15-latest",
"version": "pg16-v0.2.0",
"branch": "master",
"commit": "sha256:38c7e5c4fa3afd48fb4911b3f96489ac287b59f8bfdd9b7b55c0eca898ffec21",
"remark": "pgvector implemented in RUST",
Expand All @@ -24,37 +24,39 @@
"parallel": 4,
"top": 10,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100
}
},
{
"parallel": 4,
"top": 100,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100
}
},
{
"parallel": 8,
"top": 10,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100
}
},
{
"parallel": 8,
"top": 100,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100
}
}
],
"upload_params": {
"parallel": 16,
"batch_size": 64,
"index_params": {
"m": 12,
"ef_construction": 100
"indexing.hnsw.m": 12,
"indexing.hnsw.ef_construction": 100,
"optimizing.optimizing_threads": 8,
"segment.max_sealed_segment_size": 5000000
},
"index_type": "hnsw",
"engine_type": "rust"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"platform": "CloudTest_v0.0.4",
"index_type": "HNSW",
"dataset": "laion-768-5m-ip-probability",
"version": "pg15-latest",
"version": "pg16-v0.2.0",
"branch": "master",
"commit": "sha256:38c7e5c4fa3afd48fb4911b3f96489ac287b59f8bfdd9b7b55c0eca898ffec21",
"remark": "pgvector implemented in RUST",
Expand All @@ -24,7 +24,8 @@
"parallel": 4,
"top": 10,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.01
Expand All @@ -34,7 +35,8 @@
"parallel": 4,
"top": 10,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.1
Expand All @@ -44,7 +46,8 @@
"parallel": 4,
"top": 100,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.01
Expand All @@ -54,7 +57,8 @@
"parallel": 4,
"top": 100,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.1
Expand All @@ -64,7 +68,8 @@
"parallel": 8,
"top": 10,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.01
Expand All @@ -74,7 +79,8 @@
"parallel": 8,
"top": 10,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.1
Expand All @@ -84,7 +90,8 @@
"parallel": 8,
"top": 100,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.01
Expand All @@ -94,7 +101,8 @@
"parallel": 8,
"top": 100,
"params": {
"hnsw.ef_search": 100
"vectors.hnsw_ef_search": 100,
"vectors.search_mode": "vbase"
},
"query_meta": {
"probability": 0.1
Expand All @@ -105,8 +113,10 @@
"parallel": 16,
"batch_size": 64,
"index_params": {
"m": 12,
"ef_construction": 100
"indexing.hnsw.m": 12,
"indexing.hnsw.ef_construction": 100,
"optimizing.optimizing_threads": 8,
"segment.max_sealed_segment_size": 5000000
},
"index_type": "hnsw",
"engine_type": "rust"
Expand Down