Skip to content

Conversation

@ChenyuZhu1
Copy link
Contributor

@ChenyuZhu1 ChenyuZhu1 commented Oct 15, 2025

Purpose

What this PR does / why we need it?

Implementation of DRAM connector

Modifications

A new infrastructure, the MemoryPool class is implemented and referenced in the dramstore implementation class, to store the KVCache data. The memory pool is initialized at the beginning with capacity and blockSize, and NewBlock(), LookupBlock(), GetAddress(), CommitBlock() interfaces are implemented here. It acts like an LRU-Cache. The storage pool is divided into slotNum=capacity/blockSize slots with dummy block names in the format __slot_{index}. During the initialization stage, all slots are pushed back into the LRU queue. Each time an allocation request (blockId) is requested, the last element of the LRU queue is popped, with the corresponding address assigned to the new blockId, which is soonly added into addressMap_.
Each time a block is committed, whether true or false, the block will be pushed into the LRU queue. If success==true, then it will be pushed to the front of the LRU queue (so that it is unlikely to be popped out soon); and if success==false, then it will be pushed to the tail of the LRU queue (so that it will be soonly popped out next time an allocation request comes). If success==true, the blockId will be added into the availableBlocks_ set.
Also, in the dramstore/domain directory, DramTsfTaskManager is implemented with a transfer task queue similar to the counterpart in the nfsstore.

Test

under folder infra/mem_pool_test.cc and passed in CI

void Commit(const std::string& block, const bool success) override {}
int32_t Setup(const Config& config) {
// config里之前没有blockSize,稳妥起见还是先打桩
int32_t blockSize = 128;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can get blocksize here from vllm.config?

Copy link
Contributor Author

@ChenyuZhu1 ChenyuZhu1 Oct 15, 2025

Choose a reason for hiding this comment

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

Yes you are right, but currently blockSize is not added into config. If possible, it will be added into the Config class soon.

void Commit(const std::string& block, const bool success) override {}
int32_t Setup(const Config& config) {
// config里之前没有blockSize,稳妥起见还是先打桩
int32_t blockSize = 128;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need blocksize? config.def_readwrite("ioSize", &UC::DRAMStorePy::Config::ioSize) we have iosize here

this->_device = DeviceFactory::Make(deviceId, 0, 0); // 这里不需要buffer,暂时都先传0吧
if (!this->_device) { return Status::OutOfMemory(); }
}
if (!this->_streamOper.Setup([this](DramTsfTask& task) { this->StreamOper(task); })) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this->_device->Setup() shoulld be called here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

uint32_t GetNextAvailableOffset() const { return head_; }

Status NewBlock(std::string blockId) {
if (head_ >= capacity_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to consider concurrency issues here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

memory pool is rewritten today

this->memPool_ = std::make_unique<MemoryPool>(config.capacity, blockSize).release();
// 初始化memPool的办法是否正确?如果失败的话怎么办?
int32_t streamNumber = 60; // 这个参数是否需要,以及怎么传,还要讨论
int32_t timeoutMs = 10000; // 这个参数是否需要,以及怎么传,还要讨论
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to add these two variables to the config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants