Skip to content

Commit e987482

Browse files
committed
context : revert llama_batch_allocr position change
ggml-ci
1 parent a91b15f commit e987482

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/llama-batch.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "llama-batch.h"
22

3+
#include <cassert>
34
#include <cstring>
45
#include <algorithm>
56

@@ -281,9 +282,10 @@ llama_batch_allocr::llama_batch_allocr(struct llama_batch in_batch, llama_pos p0
281282
batch = in_batch;
282283
GGML_ASSERT(batch.n_tokens > 0);
283284
if (!batch.pos) {
285+
assert(p0 >= 0);
284286
pos.resize(batch.n_tokens);
285287
for (int32_t i = 0; i < batch.n_tokens; i++) {
286-
pos[i] = p0 + i + 1;
288+
pos[i] = p0 + i;
287289
}
288290
batch.pos = pos.data();
289291
}

src/llama-context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ int llama_context::decode(llama_batch & inp_batch) {
867867
llama_kv_cache * kv_self = static_cast<llama_kv_cache *>(memory.get());
868868

869869
// temporary allocate memory for the input batch if needed
870-
llama_batch_allocr batch_allocr(inp_batch, inp_batch.pos ? -1 : kv_self->seq_pos_max(0));
870+
llama_batch_allocr batch_allocr(inp_batch, inp_batch.pos ? -1 : kv_self->seq_pos_max(0) + 1);
871871

872872
const llama_batch & batch = batch_allocr.batch;
873873

0 commit comments

Comments
 (0)