Skip to content

Commit 195c1e3

Browse files
committed
cont : improve error message
ggml-ci
1 parent 3ddb77b commit 195c1e3

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/llama-batch.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,32 @@ bool llama_batch_allocr::init(
245245
}
246246

247247
if (memory) {
248+
bool ok = true;
249+
248250
if (batch.token) {
249251
if (seq_pos_min(s) != memory->seq_pos_max(s) + 1) {
250-
LLAMA_LOG_ERROR("%s: sequence %d (min = %d) does not start from the last position (%d) stored in the memory\n",
251-
__func__, s, seq_pos_min(s), memory->seq_pos_max(s));
252-
return false;
252+
ok = false;
253253
}
254254
} else {
255255
assert(batch.embd);
256256

257257
// for embeddings (typically used as vision input), we allow them to have repeating positions
258258
// ref: https://github.com/ggml-org/llama.cpp/issues/13694#issuecomment-2983871762
259259
if (seq_pos_min(s) != memory->seq_pos_max(s) && seq_pos_min(s) != memory->seq_pos_max(s) + 1) {
260-
LLAMA_LOG_ERROR("%s: sequence %d (min = %d) does not start from the last position (%d) stored in the memory\n",
261-
__func__, s, seq_pos_min(s), memory->seq_pos_max(s));
262-
return false;
260+
ok = false;
263261
}
264262
}
263+
264+
if (!ok) {
265+
LLAMA_LOG_ERROR(
266+
"%s: the tokens of sequence %d in the input batch have inconsistent sequence positions:\n"
267+
" - the last position stored in the memory module of the context (i.e. the KV cache) for sequence %d is X = %d\n"
268+
" - the tokens for sequence %d in the input batch have a starting position of Y = %d\n"
269+
" it is required that the sequence positions remain consecutive: Y = X + 1\n",
270+
__func__, s, s, memory->seq_pos_max(s), s, seq_pos_min(s));
271+
272+
return false;
273+
}
265274
}
266275

267276
if (seq_pos_max(s) - seq_pos_min(s) + 1 > (int) seq_pos[s].size()) {

0 commit comments

Comments
 (0)