perf: avoid full-vocab all-gather for draft greedy sampling - #1517
Open
sufubao wants to merge 1 commit into
Open
perf: avoid full-vocab all-gather for draft greedy sampling#1517sufubao wants to merge 1 commit into
sufubao wants to merge 1 commit into
Conversation
sufubao
force-pushed
the
exact-vocab-parallel-greedy
branch
from
August 27, 2026 02:28
5d5e7a5 to
74841a4
Compare
sufubao
force-pushed
the
exact-vocab-parallel-greedy
branch
from
August 27, 2026 04:20
74841a4 to
8d4eaf2
Compare
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.
Motivation
Draft/MTP proposal generation only consumes greedy argmax tokens, so gathering every vocabulary logit onto every TP rank wastes communication and memory. #1512 addresses the same bottleneck with gathered top-K candidates; this version keeps both token selection and selected-token probability exact over the complete vocabulary.
This is the first half of the previously broader PR. It deliberately covers draft models only. The target-model opt-in, sampling eligibility checks, dense fallback, Gemma4 handling, and generic backend integration are isolated in a follow-up branch.
Design
is_mtp_draft_modelmodel invariant and use the sparse path automatically.ModelOutput.logitsremains a real logit tensor. Global IDs and full-vocabulary normalization are carried explicitly aslogits_token_idsandlogits_logsumexp.exp(selected_logit - full_vocab_logsumexp).Verification
git diff --checkpass.Follow-up
The isolated target-model extension is available as a stacked comparison. It will be proposed to upstream after this draft-only contract lands, so reviewers do not need to review the shared kernel and output plumbing twice.
Related: #1511, #1512.