Skip to content

Commit

Permalink
correct token pos in llama_batch_allocr
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Oct 18, 2024
1 parent 9dd7e77 commit 5d99ae4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/infill/infill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ int main(int argc, char ** argv) {
n_past, n_left, n_ctx, params.n_keep, n_discard);

llama_kv_cache_seq_rm (ctx, 0, params.n_keep + 1 , params.n_keep + n_discard + 1);
llama_kv_cache_seq_add(ctx, 0, params.n_keep + 1 + n_discard, n_past + 1, -n_discard);
llama_kv_cache_seq_add(ctx, 0, params.n_keep + 1 + n_discard, n_past, -n_discard);

n_past -= n_discard;

Expand Down
2 changes: 1 addition & 1 deletion src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21141,7 +21141,7 @@ struct llama_batch_allocr {
batch = in_batch;
if (!batch.pos) {
// determine the last position in KV cache
llama_pos last_pos = 0;
llama_pos last_pos = -1;
for (const auto & cell : ctx->kv_self.cells) {
if (cell.has_seq_id(batch_default_seq_id)) {
last_pos = std::max(last_pos, cell.pos);
Expand Down

0 comments on commit 5d99ae4

Please sign in to comment.