add sparse quantization (no simd optimization)#517
Conversation
0e68ad7 to
539c8c2
Compare
Codecov ReportAttention: Patch coverage is @@ Coverage Diff @@
## main #517 +/- ##
==========================================
- Coverage 90.94% 90.70% -0.25%
==========================================
Files 189 194 +5
Lines 11562 11812 +250
==========================================
+ Hits 10515 10714 +199
- Misses 1047 1098 +51
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
478961e to
e3503b8
Compare
3b5d927 to
10f7fac
Compare
| uint32_t current_offset_{0}; | ||
| }; | ||
|
|
||
| template <typename QuantTmpl, typename IOTmpl> |
There was a problem hiding this comment.
move all implements to .inl file and in file end #include this .inl file
| void | ||
| SparseVectorDataCell<QuantTmpl, IOTmpl>::BatchInsertVector(const void* vectors, | ||
| InnerIdType count, | ||
| InnerIdType* idx) { |
| if (idx == nullptr) { | ||
| idx = idx_ptr.data(); | ||
| for (InnerIdType i = 0; i < count; ++i) { | ||
| idx[i] = total_count_ + i; |
| void | ||
| SparseVectorDataCell<QuantTmpl, IOTmpl>::InsertVector(const void* vector, InnerIdType idx) { | ||
| if (idx == std::numeric_limits<InnerIdType>::max()) { | ||
| idx = total_count_; |
There was a problem hiding this comment.
Why change the sparse vector idx ?
There was a problem hiding this comment.
I have removed this part
| idx = total_count_; | ||
| ++total_count_; | ||
| } else { | ||
| total_count_ = std::max(total_count_, idx + 1); |
There was a problem hiding this comment.
Q: total_count_ in here is means 'max_idx’ ?
There was a problem hiding this comment.
If the input ID exceeds the current total_count, update the total_count.
| template <typename QuantTmpl, typename IOTmpl> | ||
| MetricType | ||
| SparseVectorDataCell<QuantTmpl, IOTmpl>::GetMetricType() { | ||
| return this->quantizer_->Metric(); |
src/parameter.h
Outdated
| CHECK_ARGUMENT(json.contains("type"), "params must have type"); // TODO(LHT): "type" rename | ||
| return json["type"]; | ||
| CHECK_ARGUMENT(json.contains(QUANTIZATION_TYPE_KEY), | ||
| "params must have type"); // TODO(LHT): "type" rename |
There was a problem hiding this comment.
here let TryToParseType to get QUANTIZATION_TYPE_KEY type ?
Signed-off-by: jinjiabao.jjb <jinjiabao.jjb@antgroup.com>
718cbf5 to
01bea36
Compare
src/data_cell/flatten_interface.cpp
Outdated
| #include "io/io_headers.h" | ||
| #include "quantization/quantizer_headers.h" | ||
| #include "quantization/sparse_quantization/sparse_quantizer.h" | ||
| #include "sparse_vector_datacell.inl" |
There was a problem hiding this comment.
move #include "sparse_vector_datacell.inl to sparse_vector_datacell.h file bottom
|
|
||
| void | ||
| BatchInsertVector(const float* vectors, InnerIdType count, InnerIdType* idx) override; | ||
| BatchInsertVector(const void* vectors, InnerIdType count, InnerIdType* idx) override; |
| template <typename QuantTmpl, typename IOTmpl> | ||
| void | ||
| FlattenDataCell<QuantTmpl, IOTmpl>::BatchInsertVector(const float* vectors, | ||
| FlattenDataCell<QuantTmpl, IOTmpl>::BatchInsertVector(const void* vectors, |
|
|
||
| virtual void | ||
| BatchInsertVector(const float* vectors, InnerIdType count, InnerIdType* idx = nullptr) = 0; | ||
| BatchInsertVector(const void* vectors, InnerIdType count, InnerIdType* idx = nullptr) = 0; |
| } | ||
| auto* codes = reinterpret_cast<uint8_t*>(allocator_->Allocate(code_size)); | ||
| quantizer_->EncodeOne((const float*)vector, codes); | ||
| uint32_t now_current_offset = 0; |
There was a problem hiding this comment.
now_current_offset -> new_offset ?
|
|
||
| void | ||
| FromJson(const JsonType& json) override { | ||
| } |
There was a problem hiding this comment.
yes, there is no parameter for sparse quantizer now
related to:#324