Skip to content

Commit 394f234

Browse files
committed
Integrate hnsw_with_vectors
1 parent c73bb59 commit 394f234

32 files changed

Lines changed: 110 additions & 14 deletions

docs/grpc/docs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@
978978
| max_indexing_threads | [uint64](#uint64) | optional | Number of parallel threads used for background index building. If 0 - automatically select from 8 to 16. Best to keep between 8 and 16 to prevent likelihood of building broken/inefficient HNSW graphs. On small CPUs, less threads are used. |
979979
| on_disk | [bool](#bool) | optional | Store HNSW index on disk. If set to false, the index will be stored in RAM. |
980980
| payload_m | [uint64](#uint64) | optional | Number of additional payload-aware links per node in the index graph. If not set - regular M parameter will be used. |
981+
| copy_vectors | [bool](#bool) | optional | Store copies of original and quantized vectors within the HNSW index file. Default: false. Enabling this option will trade the search speed for disk usage by reducing amount of random seeks during the search. Requires quantized vectors to be enabled. Multi-vectors are not supported. |
981982

982983

983984

docs/redoc/master/openapi.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6929,6 +6929,11 @@
69296929
"format": "uint",
69306930
"minimum": 0,
69316931
"nullable": true
6932+
},
6933+
"copy_vectors": {
6934+
"description": "Store copies of original and quantized vectors within the HNSW index file. Default: false. Enabling this option will trade the search speed for disk usage by reducing amount of random seeks during the search. Requires quantized vectors to be enabled. Multi-vectors are not supported.",
6935+
"type": "boolean",
6936+
"nullable": true
69326937
}
69336938
}
69346939
},
@@ -7222,6 +7227,11 @@
72227227
"format": "uint",
72237228
"minimum": 0,
72247229
"nullable": true
7230+
},
7231+
"copy_vectors": {
7232+
"description": "Store copies of original and quantized vectors within the HNSW index file. Default: false. Enabling this option will trade the search speed for disk usage by reducing amount of random seeks during the search. Requires quantized vectors to be enabled. Multi-vectors are not supported.",
7233+
"type": "boolean",
7234+
"nullable": true
72257235
}
72267236
}
72277237
},

lib/api/src/grpc/conversions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,7 @@ impl From<HnswConfigDiff> for segment::types::HnswConfig {
21262126
max_indexing_threads,
21272127
on_disk,
21282128
payload_m,
2129+
copy_vectors,
21292130
} = hnsw_config;
21302131
Self {
21312132
m: m.unwrap_or_default() as usize,
@@ -2134,6 +2135,7 @@ impl From<HnswConfigDiff> for segment::types::HnswConfig {
21342135
max_indexing_threads: max_indexing_threads.unwrap_or_default() as usize,
21352136
on_disk,
21362137
payload_m: payload_m.map(|x| x as usize),
2138+
copy_vectors,
21372139
}
21382140
}
21392141
}

lib/api/src/grpc/proto/collections.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ message HnswConfigDiff {
195195
Number of additional payload-aware links per node in the index graph. If not set - regular M parameter will be used.
196196
*/
197197
optional uint64 payload_m = 6;
198+
/*
199+
Store copies of original and quantized vectors within the HNSW index file. Default: false.
200+
Enabling this option will trade the search speed for disk usage by reducing amount of
201+
random seeks during the search.
202+
Requires quantized vectors to be enabled. Multi-vectors are not supported.
203+
*/
204+
optional bool copy_vectors = 7;
198205
}
199206

200207
message SparseIndexConfig {

lib/api/src/grpc/qdrant.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ pub struct HnswConfigDiff {
407407
/// Number of additional payload-aware links per node in the index graph. If not set - regular M parameter will be used.
408408
#[prost(uint64, optional, tag = "6")]
409409
pub payload_m: ::core::option::Option<u64>,
410+
/// Store copies of original and quantized vectors within the HNSW index file. Default: false.
411+
/// Enabling this option will trade the search speed for disk usage by reducing amount of
412+
/// random seeks during the search.
413+
/// Requires quantized vectors to be enabled. Multi-vectors are not supported.
414+
#[prost(bool, optional, tag = "7")]
415+
pub copy_vectors: ::core::option::Option<bool>,
410416
}
411417
#[derive(serde::Serialize)]
412418
#[allow(clippy::derive_partial_eq_without_eq)]

lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ mod tests {
348348
max_indexing_threads: 0,
349349
on_disk: None,
350350
payload_m: None,
351+
copy_vectors: None,
351352
};
352353

353354
// Optimizers used in test
@@ -508,6 +509,7 @@ mod tests {
508509
max_indexing_threads: 0,
509510
on_disk: None,
510511
payload_m: None,
512+
copy_vectors: None,
511513
};
512514

513515
let permit_cpu_count = num_rayon_threads(hnsw_config_collection.max_indexing_threads);

lib/collection/src/collection_manager/optimizers/indexing_optimizer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ mod tests {
877877
max_indexing_threads: 0,
878878
on_disk: None,
879879
payload_m: None,
880+
copy_vectors: None,
880881
};
881882

882883
{

lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ mod tests {
468468
max_indexing_threads: 0,
469469
on_disk: None,
470470
payload_m: None,
471+
copy_vectors: None,
471472
};
472473

473474
let permit_cpu_count = num_rayon_threads(hnsw_config.max_indexing_threads);

lib/collection/src/operations/config_diff.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ pub struct HnswConfigDiff {
9090
/// Custom M param for additional payload-aware HNSW links. If not set, default M will be used.
9191
#[serde(default, skip_serializing_if = "Option::is_none")]
9292
pub payload_m: Option<usize>,
93+
/// Store copies of original and quantized vectors within the HNSW index file. Default: false.
94+
/// Enabling this option will trade the search speed for disk usage by reducing amount of
95+
/// random seeks during the search.
96+
/// Requires quantized vectors to be enabled. Multi-vectors are not supported.
97+
#[serde(default, skip_serializing_if = "Option::is_none")]
98+
pub copy_vectors: Option<bool>,
9399
}
94100

95101
#[derive(

lib/collection/src/operations/conversions.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ impl From<api::grpc::qdrant::HnswConfigDiff> for HnswConfigDiff {
240240
max_indexing_threads,
241241
on_disk,
242242
payload_m,
243+
copy_vectors,
243244
} = value;
244245
Self {
245246
m: m.map(|v| v as usize),
@@ -248,6 +249,7 @@ impl From<api::grpc::qdrant::HnswConfigDiff> for HnswConfigDiff {
248249
max_indexing_threads: max_indexing_threads.map(|v| v as usize),
249250
on_disk,
250251
payload_m: payload_m.map(|v| v as usize),
252+
copy_vectors,
251253
}
252254
}
253255
}
@@ -261,6 +263,7 @@ impl From<HnswConfigDiff> for api::grpc::qdrant::HnswConfigDiff {
261263
max_indexing_threads,
262264
on_disk,
263265
payload_m,
266+
copy_vectors,
264267
} = value;
265268
Self {
266269
m: m.map(|v| v as u64),
@@ -269,6 +272,7 @@ impl From<HnswConfigDiff> for api::grpc::qdrant::HnswConfigDiff {
269272
max_indexing_threads: max_indexing_threads.map(|v| v as u64),
270273
on_disk,
271274
payload_m: payload_m.map(|v| v as u64),
275+
copy_vectors,
272276
}
273277
}
274278
}
@@ -412,6 +416,7 @@ impl From<CollectionInfo> for api::grpc::qdrant::CollectionInfo {
412416
max_indexing_threads,
413417
on_disk,
414418
payload_m,
419+
copy_vectors,
415420
} = hnsw_config;
416421

417422
let CollectionParams {
@@ -493,6 +498,7 @@ impl From<CollectionInfo> for api::grpc::qdrant::CollectionInfo {
493498
max_indexing_threads: Some(max_indexing_threads as u64),
494499
on_disk,
495500
payload_m: payload_m.map(|v| v as u64),
501+
copy_vectors,
496502
}),
497503
optimizer_config: Some(api::grpc::qdrant::OptimizersConfigDiff {
498504
deleted_threshold: Some(deleted_threshold),

0 commit comments

Comments
 (0)