Skip to content

fix dsv3 load err in mtp case#9056

Merged
ShangmingCai merged 1 commit intosgl-project:fixing_pd_ppfrom
ssssnow:pd_pp/load_dsv3
Aug 11, 2025
Merged

fix dsv3 load err in mtp case#9056
ShangmingCai merged 1 commit intosgl-project:fixing_pd_ppfrom
ssssnow:pd_pp/load_dsv3

Conversation

@ssssnow
Copy link
Copy Markdown
Contributor

@ssssnow ssssnow commented Aug 11, 2025

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Summary of Changes

Hello @ssssnow, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've addressed a critical issue preventing the DeepseekV3 model from loading correctly, specifically in multi-tensor parallel (MTP) configurations. The fix involves ensuring the pipeline parallel group is properly initialized and passed during model construction, which resolves a dependency for the load_weights() method.

Highlights

  • DeepseekV3 Model Initialization: I've updated sglang/srt/models/deepseek_nextn.py to explicitly initialize self.pp_group using get_pp_group() within the DeepseekV3ForCausalLMNextN constructor. This ensures the pipeline parallel group is available, preventing model loading failures.
  • Prefix Handling in DeepseekV2 Layers: In sglang/srt/models/deepseek_v2.py, I've modified how the prefix argument is passed to DeepseekV2DecoderLayer during its initialization. Instead of dynamically adding a layer index prefix, it now directly uses the provided prefix, which likely streamlines weight loading in distributed setups.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

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

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 addresses two initialization bugs for DeepSeek V3 models. The first change correctly initializes the pipeline parallelism group in DeepseekV3ForCausalLMNextN, which is crucial for weight loading. The second change fixes an incorrect layer prefix construction in DeepseekV2Model. The changes appear correct. I've added one comment regarding code duplication to improve long-term maintainability.

Comment on lines 134 to 139
self.config = config
self.tp_size = get_tensor_model_parallel_world_size()
self.quant_config = quant_config
# if not set, model load will be broken in DeepseekV3ForCausalLM load_weights()
self.pp_group = get_pp_group()
self.determine_num_fused_shared_experts("DeepseekV3ForCausalLMNextN")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There is significant code duplication between this __init__ method and DeepseekV2ForCausalLM.__init__. Both methods initialize config, tp_size, quant_config, pp_group, and call determine_num_fused_shared_experts.

This duplication likely exists because super().__init__ cannot be called due to differences in self.model initialization.

To improve maintainability and reduce redundancy, consider refactoring the common initialization logic into a shared helper method within the base class DeepseekV2ForCausalLM. This would make the code cleaner and less prone to errors when one of the initializations is updated but not the other.

@ShangmingCai ShangmingCai merged commit f436908 into sgl-project:fixing_pd_pp Aug 11, 2025
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.

2 participants