Skip to content

Commit 6fd5ad5

Browse files
committed
server: cap n_predict if not set to n_ctx_train
1 parent 91c7360 commit 6fd5ad5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

examples/server/server.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,18 @@ struct server_context {
887887
});
888888
slot.params.n_predict = slot.n_predict;
889889
}
890+
if (slot.params.n_predict < 1 && slot.ga_n == 1) {
891+
auto n_ctx_train = llama_n_ctx_train(model);
892+
LOG_WARNING("n_predict is not set and self-context extend is disabled. Limiting generated tokens to n_ctx_train to avoid EOS-less generation infinite loop", {
893+
{"params.n_predict", slot.params.n_predict},
894+
{"slot.n_predict", slot.n_predict},
895+
{"n_slots", params.n_parallel},
896+
{"n_ctx", n_ctx},
897+
{"n_ctx_train", n_ctx_train},
898+
{"ga_n", slot.ga_n},
899+
});
900+
slot.params.n_predict = n_ctx_train;
901+
}
890902

891903
// infill
892904
slot.params.input_prefix = json_value(data, "input_prefix", default_params.input_prefix);

0 commit comments

Comments
 (0)