Skip to content

Commit

Permalink
fix block verification
Browse files Browse the repository at this point in the history
  • Loading branch information
lzhangzz committed Nov 2, 2023
1 parent 6de4a37 commit 86f60c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/turbomind/models/llama/BlockManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int BlockManager::Lock(const std::vector<const Block*>& bs)

Move(cached_ids_, idxs, active_ids_);

dbg(cached_ids_, active_ids_);
// dbg(cached_ids_, active_ids_);

return idxs.size();
}
Expand Down
24 changes: 13 additions & 11 deletions src/turbomind/models/llama/SequenceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,20 @@ bool SequenceManager::Erase(uint64_t id)

void SequenceManager::VerifyAndLockCached(const Sequences& sequences)
{
if (!need_verify_) {
return;
}
std::vector<const Block*> blocks;
for (const auto& p : sequences) {
auto& seq = const_cast<Sequence&>(*p);
if (seq.status != Sequence::kCached) {
continue;
}
FT_CHECK(seq.blocks.size() == seq.block_unique_ids.size());
for (int i = 0; i < seq.blocks.size(); ++i) {
if (seq.blocks[i]->unique_id != seq.block_unique_ids[i]) {
seq.blocks.resize(i);
seq.block_unique_ids.resize(i);
break;
if (need_verify_) {
for (int i = 0; i < seq.blocks.size(); ++i) {
if (seq.blocks[i]->unique_id != seq.block_unique_ids[i]) {
seq.blocks.resize(i);
seq.block_unique_ids.resize(i);
break;
}
}
}
blocks.insert(blocks.end(), seq.blocks.begin(), seq.blocks.end());
Expand Down Expand Up @@ -334,7 +333,7 @@ void SequenceManager::AssignAndActivate(const Sequences& sequenc
for (int i = 0; i < sequences.size(); ++i) {
auto& s = const_cast<Sequence&>(*sequences[i]);
auto count = counts[i];
dbg(count);
// dbg(count);
auto last = first + count;
std::for_each(first, last, [&](const Block* b) {
s.blocks.push_back(b);
Expand Down Expand Up @@ -417,8 +416,11 @@ auto SequenceManager::Materialize(Sequences sequences,
}

// allocate & assign blocks
if (schedule.allocate) {
auto blocks = block_manager_->Allocate(schedule.allocate);
{
std::vector<const Block*> blocks;
if (schedule.allocate) {
blocks = block_manager_->Allocate(schedule.allocate);
}
AssignAndActivate(schedule.active, schedule.block_counts, blocks);
}

Expand Down

0 comments on commit 86f60c3

Please sign in to comment.