-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix disable_shared_experts_fusion does not work #6911
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
Fix disable_shared_experts_fusion does not work #6911
Conversation
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.
Hello @fzyzcjy, 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!
Summary of Changes
Hello! Gemini here, providing a summary of this pull request to help everyone quickly understand the changes.
This PR aims to fix an issue where the disable_shared_experts_fusion
flag was not being correctly respected in the DeepSeek V2 model implementation. Previously, the logic for determining whether to fuse shared experts didn't check this flag, potentially leading to fusion happening even when it was explicitly disabled. The author notes some confusion about the overall logic but provides a minimal fix to address this specific flag's behavior.
Highlights
- Bug Fix: Corrects the logic for the
disable_shared_experts_fusion
flag in the DeepSeek V2 model, ensuring that shared experts fusion is disabled when the flag is set. - Configuration Handling: Adds a check for the
disable_shared_experts_fusion
setting fromglobal_server_args_dict
before enabling shared experts fusion.
Changelog
- python/sglang/srt/models/deepseek_v2.py
- Added a condition to the shared experts fusion logic to check if
disable_shared_experts_fusion
is set, preventing fusion when it is.
- Added a condition to the shared experts fusion logic to check if
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 is currently in preview and 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 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
-
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. ↩
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.
Code Review
This pull request introduces a fix for the disable_shared_experts_fusion
flag in the DeepSeek V2 model, ensuring that the user's preference to disable fusion is correctly respected. The change itself appears to be a minimal and correct way to address the issue.
Given your comment in the PR description about being "a bit confused about the logic," it would be beneficial to confirm if this fix resolves your confusion or if there are any lingering uncertainties about the surrounding code. Ensuring clarity here is important for maintainability.
The most significant area for improvement would be the addition of unit tests. For a bug fix like this, unit tests are crucial to verify the corrected behavior and prevent regressions. Specifically, tests covering scenarios where disable_shared_experts_fusion
is True
and False
would be valuable.
Regarding coding style, no specific style guide was provided. The submitted code change adheres to general Python best practices (PEP 8).
Overall, the fix is good, but adding tests and clarifying any remaining confusion would greatly enhance the PR's quality.
Summary of Findings
- Missing Unit Tests for Bug Fix: The PR fixes a bug related to a feature flag but does not include unit tests to verify the corrected behavior or prevent regressions. Adding tests for the
disable_shared_experts_fusion
flag is recommended. - Author's Stated Confusion: The PR author mentioned being confused about the logic. It's important to ensure this confusion is resolved to maintain code clarity and correctness.
Merge Readiness
The code change itself is a good and direct fix for the issue. However, due to the author's stated confusion about the surrounding logic and the absence of unit tests to verify this fix, I recommend addressing these points before merging. Adding unit tests would significantly increase confidence in the change and help prevent future regressions. I am not authorized to approve pull requests, so please ensure further review and approval from authorized maintainers after addressing these points.
@@ -1709,6 +1709,7 @@ def determine_num_fused_shared_experts( | |||
and self.config.architectures[0] == architecture | |||
and self.config.n_routed_experts == 256 | |||
and (not global_server_args_dict["enable_deepep_moe"]) | |||
and (not global_server_args_dict["disable_shared_experts_fusion"]) |
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.
This added condition correctly ensures that the disable_shared_experts_fusion
flag from global_server_args_dict
is respected, preventing the fusion logic from running if the user has explicitly disabled it. This directly addresses the issue described in the PR title.
To ensure the long-term stability of this fix and to prevent regressions, could you consider adding unit tests? Specifically, tests that verify:
- When
disable_shared_experts_fusion
isTrue
,self.num_fused_shared_experts
remains0
(or its default) and shared expert fusion is effectively off for this path. - When
disable_shared_experts_fusion
isFalse
(and other conditions are met), shared expert fusion is enabled as intended.
This would provide confidence that the flag works as expected across different scenarios.
pls refer to this commit. #6767 |
|
see #7180 |
Motivation
I am a bit confused about the logic, but anyway here is a minimal fix
Modifications
Checklist