-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
[V1][Speculative Decoding] Fix DeepSeek MTP #20022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d8a6af7
add missing token embedding in `DeepSeekMultiTokenPredictor`
cjackal e54a85a
fix `EagleProposer` for deepseek MTP single kv cache group case
cjackal 07e68f4
mv vocab embedding from MTP layers to MTP module
cjackal ba01c4a
refactor MTP weight loading logic
cjackal 949f1bc
make ruff happy
cjackal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
self.embed_tokens
here seems redundant, as it's already defined in theDeepSeekMultiTokenPredictorLayer
class. Consider if this is truly necessary or if it can be removed to avoid duplication.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to the bug? Does the MTP module have a separate vocab embedding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lack of vocab embedding module raises the
'DeepSeekMultiTokenPredictor' object has no attribute 'embed_tokens'
attribute error, the first traceback in the linked issue.Architecture-wise all the vocab embeddings are of the same shape as the target model, but we do need to keep vocab embeddings for each mtp layers if the target model has been trained with multiple mtp layers (not the case for official deepseek R1/V3 families though) and the user launches server with PP > 1. There is a similar condition check in EAGLE weight loading step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjackal Thanks for the explanation! Can we use the target model's embedding when PP=1 and only allocate the weights when PP > 1?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WoosukKwon Another thought after the discussion: the sole purpose of speculative decoding is leveraging the small draft model to get faster generation speed, so allowing pipeline parallelism on draft model weights is rare and kind of contradictory.
We may simply assume that all the MTP layers are on the same (last) pipeline component and always share the vocab embedding of the MTP layers with that of the target model.NVM, even if MTP module is not split, there is no guarantee that target model's embedding is on the same component. Let me just move the vocab embeddings fromDeepSeekMultiTokenPredictorLayer
toDeepSeekMultiTokenPredictor
to share them among MTP layers and leave the sharing between target and draft embedding to the EAGLE draft model loading stage that I linked before.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjackal Got it. Thanks! Could you please re-run the test locally again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need more refactor on draft weight loading part; let me ping again when ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjackal Got it. Thanks!