feat: add prefill_data_parallel_rank for external dp dispatch in P/D disaggregation#16059
feat: add prefill_data_parallel_rank for external dp dispatch in P/D disaggregation#16059qy-seu wants to merge 2 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello @qianyang01, 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 significantly improves the flexibility of data parallel dispatch in Prefill/Decode (P/D) disaggregation mode. Previously, the 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. 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 introduces the prefill_data_parallel_rank field to decouple the Prefill and Decode data parallelism ranks, allowing for more flexible scheduling in P/D disaggregation mode. The changes correctly propagate this new parameter through the request lifecycle, from the API entrypoints down to the core logic in the decode server. The implementation is straightforward and addresses the motivation well. I have one minor suggestion to improve code readability.
I am having trouble creating individual review comments. Click here to see my feedback.
python/sglang/srt/managers/io_struct.py (644-648)
The conditional assignment here is redundant. Since self.prefill_data_parallel_rank is already of type Optional[int], it will be either an integer or None. The expression x if x is not None else None is equivalent to just x. This can be simplified for better readability. A similar pattern is also present for data_parallel_rank above.
prefill_data_parallel_rank=self.prefill_data_parallel_rank,|
Can you check this PR: #14726? There are some similar efforts. |
Motivation
Currently, the
data_parallel_rankfield in the request body sent to the Decode instance is overloaded with a dual purpose:This coupling forces the Prefill and Decode instances to share the exact same DP rank. It makes it impossible to schedule a request to a Decode instance in DP group
iwhile fetching KV cache from a Prefill instance in DP groupj(wherei != j), limiting the flexibility of external schedulers.Modifications
Interface Protocol:
prefill_data_parallel_rankto the request interface.Logic in P/D disaggregation:
data_parallel_rank.prefill_data_parallel_rankto explicitly identify and connect to the target Prefill DP group.Accuracy Tests
Benchmarking and Profiling
Checklist