Skip to content

LLM inference in C/C++

C++ ggml

spec : fix n-gram drafts rejected at temp > 0 after truncation (#29924)

Pranesh Gonegandla8330e9696708
diff --git a/common/speculative.cpp b/common/speculative.cpp
index 328ed241a6..33dda825d4 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);
}
}