[bugfix] fix qwen3_5 fp8 gpt-bridge#8076
Conversation
Summary of ChangesHello @Jintao-Huang, 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 addresses a bug related to 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. Changelog
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 the GPT bridge for Qwen 3.5 FP8 models by improving the detection of grouped experts and gate-up projections through state dictionary inspection. It also unifies the revision argument naming in get_model_processor across the codebase, ensuring that model revisions are correctly passed to the underlying loaders. The changes are well-structured and improve the robustness of weight conversion between HuggingFace and Megatron formats.
| hf_mlp = hf_mlp.experts | ||
| if to_mcore: | ||
| pattern = r'experts\.\d+\.down_proj' | ||
| hf_grouped = not any(re.match(pattern, k) is not None for k in hf_state_dict.keys()) |
There was a problem hiding this comment.
Using regex to detect separate experts in the state dict is a robust way to determine hf_grouped when loading weights. This is more reliable than relying on hardcoded model lists. You can simplify the generator expression slightly for better readability.
References
- Iterating directly over a dictionary iterates over its keys, and match objects are truthy in Python.
| num_local_experts = config.num_moe_experts // self.ep_size | ||
| is_gate_up = hasattr(hf_mlp, 'gate_up_proj') | ||
| if to_mcore: | ||
| is_gate_up = any('gate_up_proj' in k for k in hf_state_dict.keys()) |
There was a problem hiding this comment.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several bug fixes and improvements, primarily for the qwen3_5 model's fp8 and gpt-bridge functionality. The changes include renaming model_revision to revision for better consistency with Hugging Face Transformers, renaming fp8_param_gather to fp8_param, and significantly refactoring the MoE handling logic in gpt_bridge.py. The updated logic for MoE models is more robust as it now inspects the state dictionary directly to determine expert grouping and layer structure, which is a solid improvement. Overall, the changes are well-implemented and enhance the codebase's correctness and consistency. I have no further comments.
No description provided.