Skip to content

Commit 5d99ae4

Browse files
committed
correct token pos in llama_batch_allocr
1 parent 9dd7e77 commit 5d99ae4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/infill/infill.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ int main(int argc, char ** argv) {
376376
n_past, n_left, n_ctx, params.n_keep, n_discard);
377377

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

381381
n_past -= n_discard;
382382

src/llama.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21141,7 +21141,7 @@ struct llama_batch_allocr {
2114121141
batch = in_batch;
2114221142
if (!batch.pos) {
2114321143
// determine the last position in KV cache
21144-
llama_pos last_pos = 0;
21144+
llama_pos last_pos = -1;
2114521145
for (const auto & cell : ctx->kv_self.cells) {
2114621146
if (cell.has_seq_id(batch_default_seq_id)) {
2114721147
last_pos = std::max(last_pos, cell.pos);

0 commit comments

Comments
 (0)