Repository navigation
Conversation
Speculative decoding could return accepted draft tokens past an EOG within the accepted draft portion of the result. The server used this untrimmed result to compute draft acceptance, rollback, prompt contents, and model state before `process_token()` stopped generation, leaving client-visible output correct while acceptance statistics and slot state could include post-EOG tokens. Search the accepted draft portion for its first EOG and truncate the full speculative result at that token before rollback or state updates. For FULL/recurrent memory, restore the checkpoint and replay only the valid prefix before EOG; if that prefix is empty, skip drafting once so the target can resample the terminating token without a replay loop. The regression test covers the `ngram-simple` 48-EOG draft case and verifies zero accepted drafts and no stale slot tail.
|
Hi @Lipenghee, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
@Lipenghee I ran into the same issue (MTP on Qwen3.8-27B) and fixed it one level lower, in Would you be open to switching to this approach? Otherwise I can open it as a separate PR and reference this one. |
|
#29638 fixed the mid-draft EOG case and closed #28049, but I found a broader version of the bug. Any stop on an accepted draft token, including stop strings, leaves stale tokens in the slot cache. I have a fix that trims the cache wherever I'd like to open mine separately and link it here, unless you'd rather combine them. |
|
Thanks @ethanhq and @philippesic, and sorry for the late reply. #29638 already stops mid-draft EOG acceptance in #32771 covers the remaining non-checkpoint cases this PR did not handle — stop strings, end-of-draft EOG, and rejection-sampling mid-draft EOG — by trimming the slot cache after |
Overview
Speculative decoding could return accepted draft tokens past an EOG within the accepted draft portion of the result. The server used this untrimmed result to compute draft acceptance, rollback, prompt contents, and model state before
process_token()stopped generation, leaving client-visible output correct while acceptance statistics and slot state could include post-EOG tokens.Search the accepted draft portion for its first EOG and truncate the full speculative result at that token before rollback or state updates. For FULL/recurrent memory, restore the checkpoint and replay only the valid prefix before EOG; if that prefix is empty, skip drafting once so the target can resample the terminating token without a replay loop.
Additional information
The regression test covers the
ngram-simple48-EOG draft case and verifies zero accepted drafts and no stale slot tail.Fixes #28049
Requirements