From 8330e9696708fcfd5d465cdbd333e4c5a67e2808 Mon Sep 17 00:00:00 2001 From: Pranesh Gonegandla Date: Sun, 4 Oct 2026 14:15:22 +0530 Subject: [PATCH] spec : fix n-gram drafts rejected at temp > 0 after truncation (#29924) Co-authored-by: Pranesh Gonegandla --- common/speculative.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/speculative.cpp b/common/speculative.cpp index 328ed241a..33dda825d 100644 --- a/common/speculative.cpp +++ b/common/speculative.cpp @@ -2915,8 +2915,8 @@ void common_speculative_draft(common_speculative * spec) { SPC_DBG("truncating draft to %d tokens\n", dp.n_max); result.resize(dp.n_max); - // the candidates are one per drafted token and must be cut with them - if (dp.result_q) { + // trim the candidates only if the drafter produced them (n-gram drafters do not) + if (dp.result_q && !dp.result_q->empty()) { dp.result_q->resize(dp.n_max); } }