Repository navigation
spec : fix n-gram drafts rejected at temp > 0 after truncation - #29924
Merged
ggerganov merged 1 commit intoOct 4, 2026
Merged
Conversation
Contributor
Author
|
@ggerganov, @danbev, @gaugarg-nv, @lbyte |
|
Verified, the regression is fixed. |
ggerganov
approved these changes
Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fix the regression where, at temperature > 0, n-gram drafts cut short near the end of a reply were wrongly rejected outright, slowing generation down. The regression affects n-gram drafters and is fixed with this PR; draft-simple and draft-mtp are not affected by the regression.
Regression introduced by #27694 commit 1fb7ef3e3.
Root cause
The server passes a candidate list (result_q) to the drafters whenever temperature > 0. use_spec_rejection() checks only temp > 0.0f, and --spec-draft-sampling doesn't affect this.
draft-simple and draft-mtp either clear the list in greedy mode or fill one candidate list per drafted token in probabilistic mode. N-gram drafters (and EAGLE3/DFlash/DSpark) never touch it.
common_speculative_draft() truncates drafts longer than dp.n_max, which is the remaining room before max_tokens or the end of the context. It also resizes result_q to n_max. On an untouched, empty list this creates n_max empty candidate lists.
The verifier then sees a non-empty list whose size matches the draft, so it switches to rejection sampling. With q = 0 for every drafted token, it rejects the whole draft.
Effect: near the end of a reply, every truncated n-gram draft is fully rejected.
Both greedy (default) and probabilistic modes are affected, temperature 0 is not affected, draft-simple and draft-mtp on their own are not affected.
Fix
Testing
Tested on RTX 5090, following decode perf data is with builds corresponding to pre-PR 134b2bb, ToT 836d571, ToT + fix (this PR). Temperature 0.7 over 8 seeds:
Llama-3.1-8B-Instruct Q4_K_M (dense):
--spec-typeQwen3.6-35B-A3B Q4_K_M (hybrid, built-in MTP):
--spec-typeRequirements