Skip to content
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

enable allocator for quantizers #80

Merged
merged 1 commit into from
Oct 27, 2024
Merged

Conversation

LHT129
Copy link
Collaborator

@LHT129 LHT129 commented Oct 22, 2024

#40

  • use allocator to manager Computer
  • use allocator for quantizer
  • update ip to 1-ip for InnerProduct metric
  • ignore flatten_datacell_test which will be enable by following pr

@LHT129 LHT129 added the kind/feature New feature or request label Oct 22, 2024
@LHT129 LHT129 self-assigned this Oct 22, 2024
@LHT129 LHT129 requested a review from jiaweizone as a code owner October 22, 2024 09:12
computer.buf_ = reinterpret_cast<uint8_t*>(this->allocator_->Allocate(this->code_size_));
} catch (const std::bad_alloc& e) {
computer.buf_ = nullptr;
logger::error("bad alloc when init computer buf");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it matter for memcpy(computer.buf_, query, this->code_size_) when computer.buf_ is nullpter

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

computer.buf_ = reinterpret_cast<uint8_t*>(this->allocator_->Allocate(aligned_size));
} catch (const std::bad_alloc& e) {
computer.buf_ = nullptr;
logger::error("bad alloc when init computer buf");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@LHT129 LHT129 force-pushed the quantizer_allocator branch 2 times, most recently from 0f610f9 to 91bb191 Compare October 23, 2024 08:16
@LHT129 LHT129 force-pushed the quantizer_allocator branch 3 times, most recently from d97b00e to 068f12a Compare October 25, 2024 03:19
@@ -35,7 +35,7 @@ template <typename T>
class Computer : public ComputerInterface {
public:
~Computer() {
delete[] buf_;
quantizer_->ReleaseComputer(*this);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use quantizer to release anther class instance ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the buf is allocated by the quantizer

src/quantization/sq4_uniform_quantizer.h Show resolved Hide resolved
@@ -96,7 +101,8 @@ SQ8Quantizer<metric>::TrainImpl(const vsag::DataType* data, uint64_t count) {
if (this->is_trained_) {
return true;
}
std::vector<DataType> upperBound(this->dim_, std::numeric_limits<DataType>::lowest());
Vector<DataType> upperBound(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upper_bound

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- use allocator to manager Computer
- use allocator for quantizer
- update ip to 1-ip for InnerProduct metric
- ignore flatten_datacell_test which will be enable by following pr

Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
@LHT129 LHT129 force-pushed the quantizer_allocator branch from 068f12a to 827a8ca Compare October 25, 2024 14:43
Copy link
Collaborator

@jiaweizone jiaweizone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LHT129 LHT129 merged commit 7358e3d into antgroup:main Oct 27, 2024
2 checks passed
@LHT129 LHT129 deleted the quantizer_allocator branch January 17, 2025 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants