Commit Graph

175 Commits

Author SHA1 Message Date
Ivan Pleshkov
61cfb8bcb5 Test fix segment builder for sparse (#4397)
* test fix segment builder for sparse

* are you happy fmt
2024-06-05 13:52:08 +02:00
Ivan Pleshkov
a629fc4d4c Fix hnsw full scan threshold (#4369)
* fix hnsw full scan threshold

* add test

* are you happy clippy

* separate open_vector_storage

* remove public fields from builder

* wip: do not create segment in builder before build

* avoid arc in storage test and low-level loading functions

* WIP: remove internal segment from SegmentBuilder

* fmt

* finalize segment builder fixes

* Revert "are you happy clippy"

This reverts commit c04afa6989.

* Revert "add test"

This reverts commit 8e7ad6207e.

* Revert "fix hnsw full scan threshold"

This reverts commit 8904443fcb.

* remove _daatabse from builder

* fix optimizer test

* fix id tracker versions persistence

* do flush for segment components on build

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-06-04 11:16:11 +02:00
Luis Cossío
57aee5addf universal-query: Impl of query_internal in collection (#4331)
* move ScoredPointTies to segment, make inner by reference

* `query_internal` implementation

* remove empty utils mod

* use `then_with`

* Improve readability, remove duplicated code

* refactoring suggestions

* don't collect eagerly

* remove unused import

* dont panic on empty transpose input

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-05-31 08:56:06 -04:00
Ivan Pleshkov
912e081bff Mmap for quantized multivector offsets (#4354)
* mmap for quantized multivector offsets

* resolve save vector

* fmt

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-05-30 14:56:58 +02:00
xzfc
f026fc8a42 Recreate sparse vector index (#4313)
* Recreate sparse vector index

* Rename index file; add simple migration
2024-05-29 17:04:17 +00:00
Ivan Pleshkov
ef1a8b8f55 Use correct vector storage size (#4312)
* use correct vector storage size

* remove dim from segment entry

* are you happy fmt

* codespell and proportions

* remove obsolete comment

* remove `try_vector_dim`

* are you happy fmt

* remove todo

* revert code of conduct

* check div 0

* Simplify a bit with max iterator

* Update lib/segment/src/index/hnsw_index/hnsw.rs

Co-authored-by: Tim Visée <tim+github@visee.me>

* are you happy fmt

* Update lib/segment/src/index/plain_payload_index.rs

Co-authored-by: Tim Visée <tim+github@visee.me>

* review fix

* set full scan threshold 0 for test

* use u128 also for multivector storages

* fix sparse vector size calculation

* Move size calculation into if-branch

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Tim Visée <tim+github@visee.me>
2024-05-28 16:38:56 +02:00
Ivan Pleshkov
93ed4ab5c8 Multidense vectors quantization (#4202)
* quantized multivector definition

new multiquantization scorers

encode query

maxsim for quantized vectors

remove obsolete todo

reuse existing scorers

create multivector quantized storage

save load offsets

add test

fix vectors count

tempopery disable test while debugging

fix tests

fix build

less static lifetimes

less static lifetimes

fix build

* fix build after rebase

* add persistence test

* fix codespell

* increase accuracy in tests

* review remarks

* add comment references

* are you happy codespell

* don't use bincode
2024-05-28 12:36:09 +02:00
Andrey Vasnetsov
d4dc0f3f42 allow reading of the non-existent sparse vector same way we allow dense (#4322) 2024-05-24 21:42:38 +02:00
xzfc
93a42b4e2d Compressed posting lists (#4253) 2024-05-22 18:18:20 +00:00
Ivan Pleshkov
a68965f05a Fix wrong multivectors count in storage (#4283)
* fix wrong multivectors count in storage

* add test
2024-05-21 12:27:07 +02:00
xzfc
ccf7f1d24f InvertedIndexImmutableRam and index migrations (#4220)
* Move StorageVersion from segment crate to common/io

* Refine StorageVersion API

* Move methods from SparseVectorDataConfig to enum SparseIndexType

* Introduce InvertedIndexImmutableRam

* Add migrate

* Don't migrate
2024-05-16 06:47:47 +00:00
Luis Cossío
bfa72bb6d8 universal-query: Add query() to ShardOperation trait (#4210)
* add `query` to shard trait

* add missing conversions for query

* update grpc docs

* Query response has intermediate results

* add ShardQueryResponse description

* move pub use to the top, keep only one way of reaching reexports
2024-05-15 09:36:46 -04:00
Ivan Pleshkov
e80844969f Float16 integration and API (#4234)
* f16 integration

tests

api

fix test

are you happy clippy

* fix build
2024-05-15 10:36:55 +02:00
Arnaud Gourlay
86ca51aa2d Allow basic multivec search on legacy API (#4203)
* Allow multivec search on legacy REST API

* show that it works for gRPC as well

* better error message

* update error assertion

* show validation on REST as well

* remove unecessary test

* fix conversion - dim is not vec count

* fmt

* Use TypedMultiDenseVectorRef everywhere (#4224)

* Use TypedMultiDenseVectorRef everywhere

* remove obsolete test

* fix codespell

* fix build

* test single dense vector expansion on upsert

---------

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2024-05-14 17:54:11 +02:00
xzfc
4f3239f27c Misc fixes (#4212)
* SparseVectorIndex: replace pub with feature-gated getters

* Fixup dev-dependencies

* Fixup rust doc comments
2024-05-10 08:16:28 +00:00
xzfc
cb31c533bf Introduce Cargo feature "testing" (#4192) 2024-05-07 16:14:46 +00:00
Ivan Pleshkov
679d6fcd06 Mmap multivector storage (#4106)
* mmap multivector storage

update_from

fix build

are you happy fmt

fix bug

share multivector storages tests

* review remarks
2024-05-07 10:28:31 +02:00
Arnaud Gourlay
571143ae87 Simplify MaxSim configuration (#4171)
* Simplify MaxSim configuration

* enable extension of multivectorconfig

* rename multi_vec_config to multivec_config
2024-05-06 14:19:42 +02:00
Andrey Vasnetsov
4038a0082e Faster deleted filter in proxy segments (#4148)
* [WIP] introduce internal has-id check

* fmt

* update value of the deleted_mask in proxy

* use deleted_points from the context, if present

* fmt

* move stopped flag into query context

* fmt

* segment-specific query context

* enable custom deleted mask in proxy

* remove unused HasIdConditionInternal

* fix tests

* remove debug
2024-05-06 11:51:50 +02:00
Arnaud Gourlay
ed25c388b1 Proactively fix lints for Clippy 1.78 (#4140) 2024-04-30 09:22:29 +02:00
Andrey Vasnetsov
c173a9f5e5 Sparse idf dot (#4126)
* introduce QueryContext, which accumulates runtime info needed for executing search

* fmt

* propagate query context into segment internals

* [WIP] prepare idf stats for search query context

* Split SparseVector and RemmapedSparseVector to guarantee we will not mix them up on the type level

* implement filling of the query context with IDF statistics

* implement re-weighting of the sparse query with idf

* fmt

* update idf param only if explicitly specified (more consistent with diff param update

* replace idf bool with modifier enum, improve further extensibility

* test and fixes

* Update lib/collection/src/operations/types.rs

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>

* review fixes

* fmt

---------

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2024-04-29 14:54:14 +02:00
Arnaud Gourlay
abcd2af537 Median based TopK for sparse vectors scoring (#4037)
* Median based TopK for sparse vectors scoring

* add test with identical scores
2024-04-19 13:27:21 +02:00
Ivan Pleshkov
528d759429 byte storage quantization fix and test (#4063)
* byte storage quantization fix and test

* apply quantization_preprocess in quantization scorers

* exact true

* exact true

* calculate sames count

* wrong distance getter

* fix Manhattan distance getter

* less acc check

* fix build

* update acc
2024-04-19 11:04:09 +02:00
Ivan Pleshkov
224e4f600a Byte storage integration into segment (#4049)
* byte storage with quantization

raw scorer integration

config and test

are you happy fmt

fn renamings

cow refactor

use quantization branch

quantization update

* are you happy clippy

* don't use distance in quantized scorers

* fix build

* add fn quantization_preprocess

* apply preprocessing for only cosine float metric

* fix sparse vectors tests

* update openapi

* more complicated integration test

* update openapi comment

* mmap byte storages support

* fix async test

* move .unwrap closer to the actual check of the vector presence

* fmt

* remove distance similarity function

* avoid copying data while working with cow

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-04-18 00:42:17 +02:00
Arnaud Gourlay
0fcc002581 Fix multivector flaky tests (#4036) 2024-04-15 11:26:28 +02:00
Andrey Vasnetsov
c1c1ebf478 remove search method from serment trait to simplify usage in tests and prevent accidental usage in release (#3999) 2024-04-11 22:52:01 +02:00
Andrey Vasnetsov
ebc9ba0172 Fix indexed-only behavior for proxy shard (#3998)
* move check for unindexed segment size inside the segment to allow proxy shard decide where to search better

* fmt

* move indexed_only check inside the plain index
2024-04-11 13:16:56 +02:00
Arnaud Gourlay
1944e4acd8 Flatten representation for MultiDenseVectors (#4004)
* Flatten representation for MultiDenseVectors

* use chunk_exact

* better naming

* introduce multivector placeholder to avoid illegal state

* use existing conversion

* efficient copy

* validation error on empty multivector
2024-04-11 06:47:24 +02:00
Arnaud Gourlay
54d28d2d53 Integrate Multivector at segment level (#3973)
* Integrate Multivector at segment level

* more tests - green with lower accuracy

* decrease expected accuracy to fix test

* cleanup test

* multivector can not be empty

* vary number of vector per multivec point
2024-04-08 12:22:24 +02:00
Arnaud Gourlay
b49000858a Multivec knob for SegmentConfig (#3963)
* Multivec knob for SegmentConfig

* regen openapi

* add TODO for next step

* introduce multivecconfig to support more similarity aggregation

* update openapi
2024-04-04 16:38:09 +02:00
Ivan Pleshkov
1fbcebcdbe Multivector hnsw test (#3880)
* colbert query scorers (#3713)

* colbert query scorers

fix build after rebase

* review remarks

multivector hnsw test

* fixes after rebase

* fix test

* fix build after rebase

* review remark
2024-03-21 13:58:02 +01:00
Arnaud Gourlay
758779c3cd Use DenseVector alias where possible (#3705) 2024-02-28 10:31:16 +01:00
xzfc
0ed86ce057 Introduce JsonPathString (#3674)
* Introduce JsonPathString

* Fix fomatting
2024-02-23 15:38:40 +01:00
xzfc
b087df7270 Refactor: introduce details level enum (#3612) 2024-02-20 14:55:57 +00:00
shylock
eff1fd821e Feat/set payload by key (#3548)
* Support set by key in low level.

* Rename key field.

* Format.

* Pass key.

* Format.

* Test.

* Clippy.

* Fix ci lint.

* Check grpc consistency.

* Update openapi.

* Fix empty key test case.

* Support array index.

* Format.

* Add test for non exists key.

* Clippy fix.

* Add idempotence test.

* Update index by updated payload.

* Add ut for utils.

* Add ut for 1 level key.

* Fix ut.

* Support no exits key.

* Fix test result.

* Fix after rebase

* handle wildcart insertion into non-existing array

* avoid double read of payload during update

* fix missing removing data from index in case if set_payload removes indexed field

---------

Co-authored-by: Shylock Hg <shylock@DESKTOP-40I855A>
Co-authored-by: Albert Safin <xzfcpw@gmail.com>
Co-authored-by: generall <andrey@vasnetsov.com>
2024-02-15 15:15:05 +01:00
ding-young
62428e61e9 Support Min should clause (#3331) (#3466)
* Add min_should field in Filter struct

* min_should clause checks whether at least given number (min_count) of conditions are met
* modify test cases due to change in Filter struct (set min_should: None)
* add simple condition check unit test
* docs, cardinality estimation, grpc not implemented yet

* Add min_should field in Filter struct

* min_should clause checks whether at least given number (min_count) of conditions are met
* modify test cases due to change in Filter struct (set min_should: None)
* add simple condition check unit test

* Impl min_should clause in REST API

* perform cardinality estimation by estimating cardinalities of intersection and combining as union
* add openapi spec with docs update
* add integration test

* Impl min_should clause in gRPC

* Cargo fmt & clippy

* Fix minor comments

* add equivalence test between min_should and must

* shortcut at min_count matches

* use `Filter::new_*` whenever possible

* Add missing min_should field

* Fix gRPC field ordering & remove deny_unknown_fields

* Empty commit

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2024-02-11 16:43:43 +01:00
Jojii
c15adf5c72 allow stopping segment loading (#3498)
* allow stopping segment loading

* fix benches
2024-02-08 12:52:03 +01:00
Jojii
7f33ac1f63 Optimize MatchAny (#3525)
* add benches for large MatchAny

* use HashSet for MatchAny

* use fnv hash

* make fnv workspace level dependency; apply clippy

* remove SmolStr from Keyword; Improve performance

* add bench for small number of keywords

* fix openapi

* fix performance issue

* apply integer optimization; create magic number constant
2024-02-08 12:50:58 +01:00
Tim Visée
0301e39943 Dynamic CPU saturation internals (#3364)
* Move CPU count function to common, fix wrong CPU count in visited list

* Change default number of rayon threads to 8

* Use CPU budget and CPU permits for optimizer tasks to limit utilization

* Respect configured thread limits, use new sane defaults in config

* Fix spelling issues

* Fix test compilation error

* Improve breaking if there is no CPU budget

* Block optimizations until CPU budget, fix potentially getting stuck

Our optimization worker now blocks until CPU budget is available to
perform the task.

Fix potential issue where optimization worker could get stuck. This
would happen if no optimization task is started because there's no
available CPU budget. This ensures the worker is woken up again to
retry.

* Utilize n-1 CPUs with optimization tasks

* Better handle situations where CPU budget is drained

* Dynamically scale rayon CPU count based on CPU size

* Fix incorrect default for max_indexing_threads conversion

* Respect max_indexing_threads for collection

* Make max_indexing_threads optional, use none to set no limit

* Update property documentation and comments

* Property max_optimization_threads is per shard, not per collection

* If we reached shard optimization limit, skip further checks

* Add remaining TODOs

* Fix spelling mistake

* Align gRPC comment blocks

* Fix compilation errors since last rebase

* Make tests aware of CPU budget

* Use new CPU budget calculation function everywhere

* Make CPU budget configurable in settings, move static budget to common

* Do not use static CPU budget, instance it and pass it through

* Update CPU budget description

* Move heuristic into defaults

* Fix spelling issues

* Move cpu_budget property to a better place

* Move some things around

* Minor review improvements

* Use range match statement for CPU count heuristics

* Systems with 1 or 2 CPUs do not keep cores unallocated by default

* Fix compilation errors since last rebase

* Update lib/segment/src/types.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

* Update lib/storage/src/content_manager/toc/transfer.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

* Rename cpu_budget to optimizer_cpu_budget

* Update OpenAPI specification

* Require at least half of the desired CPUs for optimizers

This prevents running optimizations with just one CPU, which could be
very slow.

* Don't use wildcard in CPU heuristic match statements

* Rename cpu_budget setting to optimizer_cpu_budget

* Update CPU budget comments

* Spell acquire correctly

* Change if-else into match

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

* Rename max_rayon_threads to num_rayon_threads, add explanation

* Explain limit in update handler

* Remove numbers for automatic selection of indexing threads

* Inline max_workers variable

* Remove CPU budget from ShardTransferConsensus trait, it is in collection

* small allow(dead_code) => cfg(test)

* Remove now obsolete lazy_static

* Fix incorrect CPU calculation in CPU saturation test

* Make waiting for CPU budget async, don't block current thread

* Prevent deadlock on optimizer signal channel

Do not block the optimization worker task anymore to wait for CPU budget
to be available. That prevents our optimizer signal channel from being
drained, blocking incoming updates because the cannot send another
optimizer signal. Now, prevent blocking this task all together and
retrigger the optimizers separately when CPU budget is available again.

* Fix incorrect CPU calculation in optimization cancel test

* Rename CPU budget wait function to notify

* Detach API changes from CPU saturation internals

This allows us to merge into a patch version of Qdrant. We can
reintroduce the API changes in the upcoming minor release to make all of
it fully functional.

---------

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>
Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2024-01-31 11:56:34 +01:00
Tim Visée
cf8d13cf6c Rename IntegerParams to IntegerIndexParams to be consistent with text (#3385) 2024-01-12 16:16:22 +01:00
Tim Visée
e42f35b623 Parameterize integer index, allow lookup or range exclusively (#3380)
* Merge serde attributes

* Remove obsolete conversion

* Add integer type with parameters

* Make integer lookup and range parameters non-optional

* Add parameterized integer index types test

Co-authored-by: Di Zhao <diz@twitter.com>

* Cleanup

---------

Co-authored-by: Di Zhao <diz@twitter.com>
2024-01-11 18:41:14 +00:00
Arnaud Gourlay
2cd426dccf Fix clippy 1.75 (#3270) 2023-12-25 13:26:21 +00:00
Ivan Pleshkov
84f9011537 sparse vectors with large indices support (#3230)
* sparse vectors with large indices support

* fix unit tests

* add tracker file to snapshot

* fix unit tests

* are you happy clippy

* fix config loading

* test with max value

* fix python tests

* fix consensus tests

* review remarks; acc test for inverted index
2023-12-16 00:02:01 +00:00
Ivan Pleshkov
4f0211af5e Remove quantization update from hnsw index (#3221)
* remove quantization update from hnsw index

* test that hnsw was builded with presented quantization

* are you happy codespell

* prefer method over public field

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2023-12-15 13:00:28 +00:00
Ivan Pleshkov
c054773296 Load non-appendable ram sparse vector index from file (#3154)
* internal sparse vector segment configs

update openapi

fix build

provide correct index type to fixtures

internal sparse vector segment configs

update openapi

fix build

load ram sparse index from file

fix spelling

add test

spelling error

use appendable flag to decide load or not

fix conflict

dont flush mmap when file is empty

* fix build

* set list of files for snapshot

* fix snapshots test

* fix codespell

* simple save-load unit test

* refactor InvertedIndex::files

* fix unit tests

* add debug_assert

* test all persistence loading cases
2023-12-06 17:36:08 +01:00
Ivan Pleshkov
83e2e167e8 Internal sparse configs for segment (#3168)
* internal sparse vector segment configs

update openapi

fix build

provide correct index type to fixtures

rename grpc stuff

optional search threshold

update api consistency

* review fix

* rollback rename

* reger docs

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2023-12-06 13:28:17 +01:00
Arnaud Gourlay
32e1bbb601 Fix sparse mmap snapshot (#3166) 2023-12-06 10:58:11 +01:00
Ivan Pleshkov
7d57fb8859 Sparse vectors advanced search api support (#3128)
* sparse vectors query scorer

plain search test without internals

fix sparse_vector_index_plain_search

fix async scorer build

fix unit tests

are you happy fmt

sparse index with full query support

fix benches, use exact flag to force plain search

add alias and comment to exact flag

fix tests

recommendations TODOs fix

add simple test

add todo

refactor index

test vs comparison dense and sparse discovery

are you happy fmt

propogate error from avg negatives

reuse filtered points list

rollback api changes

better discovery test

are you happy fmt

rollback openapi

fix build

fix tests

review remark recommendations

review remarks

review remarks

codespell

integrate plain search

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

fix comment of plain search

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

fix tests

* simplify search query function
2023-12-05 20:32:23 +01:00
Arnaud Gourlay
032025c447 Fix optimizer change sparse index on disk (#3143)
* Estimate sparse vector dimension for optimizer (#3142)

* Estimate sparse vector dimension for optimizer

* add hack explanation + todo

Fix optimizer change sparse index on disk

fix index to disk

is appendable fix

add index files if necessary

fix test

* fix tests

---------

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2023-12-05 00:24:30 +01:00
Ivan Pleshkov
d272bf4b90 Sparse index persistence (#3131)
* sparse index persistence

* fix tests

* remove defaults
2023-12-04 12:02:53 +01:00