Conversation
Summary of ChangesHello @Wangzheee, 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 within the Highlights
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 Qwen3VLMoe calibration. The changes primarily refactor the initialization of SequentialQwen3VLMoeTextExperts to be more memory-efficient by avoiding the creation of intermediate tensor copies, which aligns with the goal of preventing CPU memory issues. The API for Qwen3VLMoeTextMLP is also correctly updated. The changes are logical and well-motivated. I have one suggestion to improve code style and readability for better long-term maintenance.
| num_exp = original.gate_up_proj.shape[0] | ||
| inter = original.down_proj.shape[1] | ||
| for i in range(num_exp): | ||
| gate_up = original.gate_up_proj[i] | ||
| down = original.down_proj[i] | ||
|
|
||
| mlp = Qwen3VLMoeTextMLP(config, config.moe_intermediate_size) | ||
| mlp.gate_proj.weight = torch.nn.Parameter( | ||
| gate_up[:, :inter].t(), requires_grad=False) | ||
| mlp.up_proj.weight = torch.nn.Parameter( | ||
| gate_up[:, inter:].t(), requires_grad=False) | ||
| mlp.down_proj.weight = torch.nn.Parameter( | ||
| down.t(), requires_grad=False) |
There was a problem hiding this comment.
For better readability and adherence to Python style conventions (PEP 8), it's recommended to use more descriptive variable names and standard spacing.
num_expandinterare a bit cryptic. Usingnum_expertsandintermediate_size(as was used in the previous version of the code) makes the code easier to understand.- The extra spacing used for aligning
=operators is not standard and can make code harder to maintain. A single space around operators is preferred.
The suggested change applies these improvements.
| num_exp = original.gate_up_proj.shape[0] | |
| inter = original.down_proj.shape[1] | |
| for i in range(num_exp): | |
| gate_up = original.gate_up_proj[i] | |
| down = original.down_proj[i] | |
| mlp = Qwen3VLMoeTextMLP(config, config.moe_intermediate_size) | |
| mlp.gate_proj.weight = torch.nn.Parameter( | |
| gate_up[:, :inter].t(), requires_grad=False) | |
| mlp.up_proj.weight = torch.nn.Parameter( | |
| gate_up[:, inter:].t(), requires_grad=False) | |
| mlp.down_proj.weight = torch.nn.Parameter( | |
| down.t(), requires_grad=False) | |
| num_experts = original.gate_up_proj.shape[0] | |
| intermediate_size = original.down_proj.shape[1] | |
| for i in range(num_experts): | |
| gate_up = original.gate_up_proj[i] | |
| down = original.down_proj[i] | |
| mlp = Qwen3VLMoeTextMLP(config, config.moe_intermediate_size) | |
| mlp.gate_proj.weight = torch.nn.Parameter( | |
| gate_up[:, :intermediate_size].t(), requires_grad=False) | |
| mlp.up_proj.weight = torch.nn.Parameter( | |
| gate_up[:, intermediate_size:].t(), requires_grad=False) | |
| mlp.down_proj.weight = torch.nn.Parameter( | |
| down.t(), requires_grad=False) |
|
👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review. Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed. |
|
Hi @Wangzheee we recently updated this definition, do you mind rebasing? |
66f9e6d to
b619cc5
Compare
Thanks~ |
There was a problem hiding this comment.
These changes make sense to me, though deferring to the VL expert -- @kylesayrs WDYT?
Thanks~ |
SUMMARY:
"please provide a brief summary"
Fix insufficient CPU memory: Do not create a new object to prevent insufficient CPU memory