Skip to content

fix mtp_num_layer >= 2 multimodal#40

Merged
Jintao-Huang merged 5 commits into
modelscope:mainfrom
Jintao-Huang:fix_mtp_ge_2
Apr 19, 2026
Merged

fix mtp_num_layer >= 2 multimodal#40
Jintao-Huang merged 5 commits into
modelscope:mainfrom
Jintao-Huang:fix_mtp_ge_2

Conversation

@Jintao-Huang

Copy link
Copy Markdown
Collaborator

#29

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the shifts parameter in the roll_tensor function from a hardcoded -1 to -self.layer_number within the mtp_layer.py module. This adjustment ensures that Multi-Token Prediction (MTP) layers correctly align hidden states with the appropriate future token embeddings based on the layer's position. I have no further feedback to provide.

@Jintao-Huang

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Multi-Token Prediction (MTP) implementation by explicitly passing decoder_input through the MTP layers and blocks, replacing the previous method of bundling it with embeddings in a tuple. It also introduces a patch for MultiTokenPredictionBlock.forward to manage hidden state chunking and concatenation across MTP stages. I have no feedback to provide as there were no review comments to evaluate.

@Jintao-Huang

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Multi-Token Prediction (MTP) implementation by passing decoder_input and embedding as separate arguments instead of a tuple, updating gpt_model.py and mtp_layer.py accordingly. It also adds a patch for MultiTokenPredictionBlock.forward in patcher.py to manage multi-stage hidden states. Feedback was provided regarding a potential TypeError in the patched forward method caused by mixing keyword arguments with positional *args, suggesting a more robust positional argument approach.

Comment thread src/mcore_bridge/patcher.py
@Jintao-Huang Jintao-Huang changed the title fix mtp_num_layer >= 2 fix mtp_num_layer >= 2 multimodal Apr 19, 2026
@Jintao-Huang Jintao-Huang merged commit 2d2f9d7 into modelscope:main Apr 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant