[DSv32] Fix MTP and CP compatability#19062
Conversation
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Summary of ChangesHello @vladnosiv, 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! This pull request resolves a critical compatibility issue within the deepseek_nextn.py model by correctly integrating the attention context parallel (CP) group size and rank calculations. This ensures that the model, particularly when operating in MTP mode, properly utilizes CP logic, preventing tensor shape mismatches and associated runtime errors, thereby enhancing the stability and correctness of the DeepSeekV3.2 implementation. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request addresses a bug in deepseek_nextn.py that caused a runtime crash due to incorrect API usage for tensor parallelism after a recent refactoring. The changes correctly replace get_attention_tp_rank/get_attention_tp_size with get_attention_cp_rank/get_attention_cp_size. This ensures compatibility with context parallelism (CP) and multi-path transformers (MTP), aligning the implementation with deepseek_v2.py. The fix is accurate and directly resolves the issue described.
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>
Motivation
PR #17213 introduced separate
get_attention_cp_size()/get_attention_cp_rank()APIs and migrated the main model indeepseek_v2.pyto use them, but misseddeepseek_nextn.py.Here is the assigns:
sglang/python/sglang/srt/models/deepseek_nextn.py
Lines 208 to 210 in 0d20cf5
Before the refactor this returned 8 (the combined TP+CP group size). After the refactor it returns 1 (pure attention TP size), so the MTP model operates with cp_size=1, skips CP logic, and produces tensors with wrong shapes. Any request crashes with:
Accuracy Tests
Run config
Bench
Results