Skip to content

Commit

Permalink
Clear beam search info when generate() is finished. (#630)
Browse files Browse the repository at this point in the history
Port of PR: #615
  • Loading branch information
popovaan authored Jul 15, 2024
1 parent 70b74ad commit f0c2677
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cpp/src/continuous_batching_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ContinuousBatchingPipeline::Impl {
for (const auto& sequence: request->get_sequences()) {
m_scheduler->free_sequence(sequence->get_id());
}
m_sampler->clear_beam_search_info(request->get_request_id());
requests_iterator = m_requests.erase(requests_iterator);
} else {
requests_iterator++;
Expand Down
6 changes: 6 additions & 0 deletions src/cpp/src/sampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ class Sampler {
SamplerOutput sample(std::vector<SequenceGroup::Ptr> & sequence_groups, ov::Tensor logits);

void set_seed(size_t seed) { rng_engine.seed(seed); }

void clear_beam_search_info(uint64_t request_id);
};

SamplerOutput Sampler::sample(std::vector<SequenceGroup::Ptr> & sequence_groups, ov::Tensor logits) {
Expand Down Expand Up @@ -578,4 +580,8 @@ void GroupBeamSearcher::select_next_tokens(const ov::Tensor& logits, SamplerOutp
}
}
}

void Sampler::clear_beam_search_info(uint64_t request_id) {
m_beam_search_info.erase(request_id);
}
}

0 comments on commit f0c2677

Please sign in to comment.