-
Notifications
You must be signed in to change notification settings - Fork 83
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
enhance: knowhere support data view index node #1016
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cqy123456 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@cqy123456 🔍 Important: PR Classification Needed! For efficient project management and a seamless review process, it's essential to classify your PR correctly. Here's how:
For any PR outside the kind/improvement category, ensure you link to the associated issue using the format: “issue: #”. Thanks for your efforts and contribution to the community!. |
4ed53dd
to
c488c94
Compare
669d387
to
d9dc4cb
Compare
include/knowhere/object.h
Outdated
template <typename T> | ||
class Pack : public Object { | ||
static_assert(std::is_same_v<T, std::shared_ptr<knowhere::FileManager>>, | ||
static_assert(std::is_same_v<T, std::shared_ptr<knowhere::FileManager>> || std::is_same_v<T, knowhere::ViewDataOp>, | ||
"IndexPack only support std::shared_ptr<knowhere::FileManager> by far."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message should be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
* @param range_filter | ||
*/ | ||
virtual RangeSearchResult | ||
RangeSearchWithIds(const idx_t n, const void* x, const idx_t* ids_num_lims, const idx_t* ids, const float radius, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same above
1667fc3
to
d4ff301
Compare
namespace knowhere { | ||
class IndexWithDataViewRefinerConfig : public ScannConfig { | ||
public: | ||
CFG_INT reorder_k; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this config is in scannconfig, could be excluded here
@@ -1261,4 +1261,7 @@ KNOWHERE_MOCK_REGISTER_DENSE_FLOAT_ALL_GLOBAL(IVF_SQ8, IvfIndexNode, knowhere::f | |||
KNOWHERE_MOCK_REGISTER_DENSE_FLOAT_ALL_GLOBAL(IVF_SQ_CC, IvfIndexNode, knowhere::feature::NONE, | |||
faiss::IndexIVFScalarQuantizerCC) | |||
|
|||
// faiss index + data view refiner combination | |||
KNOWHERE_SIMPLE_REGISTER_DENSE_FLOAT_ALL_GLOBAL(SCANN_DVR, IndexNodeWithDataViewRefiner, knowhere::feature::NONE, | |||
IvfIndexNode<fp32, faiss::IndexScaNN>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need IVFFLAT and IVFSQ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can all more xxx_with_data_view_refiner index in the future.
@@ -118,7 +119,7 @@ constexpr const char* WITH_RAW_DATA = "with_raw_data"; | |||
constexpr const char* ENSURE_TOPK_FULL = "ensure_topk_full"; | |||
constexpr const char* CODE_SIZE = "code_size"; | |||
constexpr const char* RAW_DATA_STORE_PREFIX = "raw_data_store_prefix"; | |||
|
|||
constexpr const char* SUB_DIM = "sub_dim"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could use m like PQ and not introduce a new config, but m is slightly different from sub_dim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this parameter is a bit like the meaning of diskann's pq_code_budget_gb, and it is ealier to maintain a constant memory/(raw data size) ratio for different dim in milvus.
cb686ab
to
d3b1a95
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1016 +/- ##
=========================================
+ Coverage 0 73.00% +73.00%
=========================================
Files 0 86 +86
Lines 0 8138 +8138
=========================================
+ Hits 0 5941 +5941
- Misses 0 2197 +2197 |
// use copy to avoid concurrent add and search | ||
std::shared_lock lock(norms_mutex_); | ||
base_norms = std::shared_ptr<float[]>(new float[norms_.size()]); | ||
std::memcpy(base_norms.get(), norms_.data(), sizeof(float) * norms_.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to clarify: a single query with n == 1
leads to copying of all norms?
if (is_cosine_) { | ||
for (auto j = 0; j < base_n; j++) { | ||
if (base_ids[j] != -1) { | ||
std::shared_lock lock(norms_mutex_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putting a lock here could impose a very hardcore overhead. Isn't it better to put it around for
-loop or clone norms_
?
@@ -88,6 +89,8 @@ struct IndexIVFFastScan : IndexIVF { | |||
// // todo aguzhva: get rid of this | |||
std::vector<float> norms; | |||
|
|||
std::shared_ptr<std::shared_mutex> mutex = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this cannot be resolved by surrounding a corresponding faiss index with a mutex rather than adding a mutex as a field? Technically, adding such a mutex implies a lot of unit testing and thorough analysis of the whole class
@@ -361,6 +364,7 @@ void IndexIVFFastScan::search_preassigned( | |||
bool store_pairs, | |||
const IVFSearchParameters* params, | |||
IndexIVFStats* stats) const { | |||
std::shared_lock<std::shared_mutex> lock(*mutex.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for range_search and iterator
d3b1a95
to
8f30983
Compare
0b71169
to
506348a
Compare
506348a
to
dbbc39e
Compare
c3b89ea
to
505699f
Compare
|
||
namespace { | ||
constexpr int64_t kBatchSize = 4096; | ||
constexpr int64_t kMaxTrainSize = 5000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for training what exactly? 5k points seems to be a bit small
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DVR index will only uses in milvus growing segment, and the row count of growing segment is not very large.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference may be large for different dims, so dynamic parameters may need to be considered here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why different dims need different train row count?
505699f
to
2e306a3
Compare
Signed-off-by: cqy123456 <[email protected]>
2e306a3
to
b768594
Compare
/hold wait v2.5.4 release |
issue: #909