fix: skip missing expert params in PP mode for Qwen3.5 MoE#21220
fix: skip missing expert params in PP mode for Qwen3.5 MoE#21220yang1002378395-cmyk wants to merge 1 commit intosgl-project:mainfrom
Conversation
KeyError occurred when loading weights with PP>1 because the code tried to access params_dict[name_mapped] without checking if the parameter exists on this rank. In PP mode, different ranks have different layers, so some parameters may not exist. Fixes sgl-project#21184
Summary of ChangesHello, 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 issue where Qwen3.5 MoE models failed to load weights in pipeline parallel mode, specifically when certain expert parameters were not available on a given rank. The fix introduces conditional checks during weight loading, ensuring that only relevant parameters are accessed, thereby enabling the stable operation of these models in distributed environments. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds an explicit check within the load_fused_expert_weights function to skip parameters that are not present on the current processing rank (PP mode). This prevents potential KeyError issues when accessing params_dict if a parameter is not mapped to the current rank. This change is applied in two locations within the file. I have no feedback to provide on the review comments as there were none.
|
Closing in favor of #21217 by @he-yufeng which was submitted earlier and addresses the same issue. The fix is identical. Good collaboration! |
Summary
Fixes #21184
Problem: When running Qwen3.5 MoE with PP>1 (e.g.,
pp=8 tp=1), the model fails to load weights with:Root Cause: In
load_weights(), the code accessesparams_dict[name_mapped]without checking if the parameter exists. In PP mode, different ranks have different layers, so some expert parameters may not exist on this rank.Fix: Add explicit checks before accessing
params_dict[name_mapped]in two locations (lines 1251 and 1592) to skip parameters that don't exist on this rank.Test Plan
User reported this fixes the issue when running:
Checklist