Skip to content

Commit

Permalink
llama : add missing kv clear in llama_beam_search (ggerganov#6664)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha authored Apr 14, 2024
1 parent 04fbc5f commit 1958f7e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13063,6 +13063,11 @@ struct llama_beam_search_data {
}
llama_logit_info logit_info(ctx);
std::vector<llama_token_data> next_tokens = logit_info.top_k(n_beams);

// Clear the kv slot so that other beams may try different tokens at this position. The llama_decode()
// call in loop() will conclusively fill in the kv slot once the beams converge at this position.
llama_kv_cache_seq_rm(ctx, 0, n_past, -1);

size_t i=0;
if (next_beams.size() < n_beams) {
for (; next_beams.size() < n_beams ; ++i) {
Expand Down

0 comments on commit 1958f7e

Please sign in to comment.