Skip to content

Commit

Permalink
[Fix] Skip empty batch (#747)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzhangzz authored Nov 23, 2023
1 parent d338635 commit a7c5007
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/turbomind/models/llama/LlamaBatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ bool LlamaBatch<T>::Initialize()
template<typename T>
void LlamaBatch<T>::CopyState(const std::vector<std::tuple<BatchState*, BatchState*, int, int>>& desc)
{
if (desc.empty()) {
return;
}

std::vector<int> idxs(desc.size());
std::iota(idxs.begin(), idxs.end(), 0);

Expand Down Expand Up @@ -1430,18 +1434,21 @@ void LlamaBatch<T>::InternalThreadEntry(int device_id)
// finished sequences is handled by `Initialize()`
finished_count = 0;

ContextDecode();

if (state_->active_size) {

ContextDecode();

if (modified) {
g = InitializeGeneration();
InitializeSampling();
}

for (int i = 0; i < step_length_; ++i) {
if (!Generate(g)) {
break;
}
}

if (auto signals = Finish(g, finished_count); !signals.empty()) {
if (finished_count) {
// Finished requests and corresponding output tensors will be released when notified
Expand Down

0 comments on commit a7c5007

Please sign in to comment.