Skip to content

Commit b1c8843

Browse files
committed
log error and return instead of storing max_seq_exceeded int
1 parent c80860c commit b1c8843

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tools/perplexity/perplexity.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,14 +1542,16 @@ static void multiple_choice_score(llama_context * ctx, const common_params & par
15421542
// the common prefix is shared among the 4 sequences to save tokens
15431543
// we extract logits only from the last common token and from all ending tokens of each sequence
15441544
int s0 = 0;
1545-
int max_seq_exceeded = 0;
15461545
while (n_cur + (int) tasks[i1].required_tokens <= n_ctx) {
15471546
auto& cur_task = tasks[i1];
15481547
int n_logits = 0;
15491548

15501549
int num_answers = cur_task.seq_tokens.size();
15511550
if (s0 + num_answers > max_seq) {
1552-
max_seq_exceeded = s0 + num_answers;
1551+
if (i0 == i1) {
1552+
LOG_ERR("%s : task %zu requires a higher -np|--parallel value (at least %d)\n", __func__, i0, num_answers);
1553+
return;
1554+
}
15531555
break;
15541556
}
15551557

@@ -1590,11 +1592,7 @@ static void multiple_choice_score(llama_context * ctx, const common_params & par
15901592
}
15911593

15921594
if (i0 == i1) {
1593-
if (max_seq_exceeded > max_seq) {
1594-
LOG_ERR("%s : task %zu requires a higher -np|--parallel value (at least %d)\n", __func__, i0, max_seq_exceeded);
1595-
} else {
1596-
LOG_ERR("%s : task %zu does not fit in the context window (requires %lu tokens)\n", __func__, i0, tasks[i0].required_tokens);
1597-
}
1595+
LOG_ERR("%s : task %zu does not fit in the context window (requires %lu tokens)\n", __func__, i0, tasks[i0].required_tokens);
15981596
return;
15991597
}
16001598

0 commit comments

Comments
 (0)