gracefully handle bad grammar instead of crashing

This commit is contained in:
Concedo
2026-03-23 17:00:53 +08:00
parent ef854f002e
commit 993925ba96
3 changed files with 17 additions and 2 deletions
+4
View File
@@ -789,6 +789,10 @@ static speculative_draft_result speculative_decoding_eval_chunk(llama_context *
// KCPP SAMPLING FUNCTIONS
void sample_softmax(llama_token_data_array * cur_p, bool do_sort=true) {
if(!(cur_p->size > 0))
{
throw std::runtime_error("No valid candidates during sampling. Current request aborted!");
}
GGML_ASSERT(cur_p->size > 0);
// Sort the logits in descending order
if (!cur_p->sorted && do_sort) {