Skip to content

[ENH] Turn on spann by default #4351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 25, 2025
Merged
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
16 changes: 10 additions & 6 deletions chromadb/test/property/invariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,20 @@ def fd_not_exceeding_threadpool_size(threadpool_size: int) -> None:
)

def get_space(collection: Collection):
# TODO: this is a hack to get the space
# We should update the tests to not pass space via metadata instead use collection
# configuration_json
space = None
if "hnsw:space" in collection.metadata:
return collection.metadata["hnsw:space"]
space = collection.metadata["hnsw:space"]
if collection._model.configuration_json is None:
return None
return space
if 'spann' in collection._model.configuration_json and collection._model.configuration_json.get('spann') is not None and 'space' in collection._model.configuration_json.get('spann'):
return collection._model.configuration_json.get('spann').get('space')
space = collection._model.configuration_json.get('spann').get('space')
elif 'hnsw' in collection._model.configuration_json and collection._model.configuration_json.get('hnsw') is not None and 'space' in collection._model.configuration_json.get('hnsw'):
return collection._model.configuration_json.get('hnsw').get('space')
else:
return None
if space is None:
space = collection._model.configuration_json.get('hnsw').get('space')
return space

def ann_accuracy(
collection: Collection,
Expand Down
2 changes: 1 addition & 1 deletion rust/frontend/sample_configs/distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ scorecard:
- "collection_id:*"
score: 100
enable_span_indexing: true
default_knn_index: "hnsw"
default_knn_index: "spann"
2 changes: 1 addition & 1 deletion rust/frontend/sample_configs/tilt_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ scorecard:
circuit_breaker:
requests: 1000
enable_span_indexing: true
default_knn_index: "hnsw"
default_knn_index: "spann"
10 changes: 7 additions & 3 deletions rust/frontend/src/impls/service_based_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,9 +1438,13 @@ mod tests {
assert!(segments.iter().any(
|s| s.r#type == SegmentType::BlockfileMetadata && s.scope == SegmentScope::METADATA
));
assert!(segments
.iter()
.any(|s| s.r#type == SegmentType::HnswDistributed && s.scope == SegmentScope::VECTOR));
assert!(
segments.iter().any(
|s| s.r#type == SegmentType::HnswDistributed && s.scope == SegmentScope::VECTOR
) || segments
.iter()
.any(|s| s.r#type == SegmentType::Spann && s.scope == SegmentScope::VECTOR)
);
assert!(segments
.iter()
.any(|s| s.r#type == SegmentType::BlockfileRecord && s.scope == SegmentScope::RECORD));
Expand Down
5 changes: 5 additions & 0 deletions rust/index/src/spann/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,11 @@ impl<'me> SpannIndexReader<'me> {
dimensionality: usize,
ef_search: usize,
) -> Result<HnswIndexRef, SpannIndexReaderError> {
// We take a lock here to synchronize concurrent open of the same index.
// Otherwise, we could end up with a corrupted index since the filesystem
// operations are not guaranteed to be atomic.
// The lock is a partitioned mutex to allow for higher concurrency across collections.
let _guard = hnsw_provider.write_mutex.lock(id).await;
match hnsw_provider.get(id, cache_key).await {
Some(index) => Ok(index),
None => {
Expand Down
Loading