Conversation
|
👋 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. |
Summary of ChangesHello @dsikka, 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 extends the LLM compressor's capabilities by integrating support for the Qwen3.5 MoE model. It provides a new example for quantizing this model using FP8 dynamic quantization and implements the necessary calibration logic for its sparse mixture-of-experts architecture. Additionally, a core utility file was adjusted to manage PyTorch initialization functions more robustly. 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
Activity
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 support for Qwen3.5 MoE models, including a new example script for quantization and corresponding calibration logic. The changes involve adding a new calibration module for Qwen3.5 MoE and updating the __init__.py to include it. Additionally, the src/llmcompressor/utils/dev.py file has been modified to redefine TORCH_INIT_FUNCTIONS locally. While the core functionality seems to be in place, there are a couple of areas that could be improved for better maintainability and portability.
| from llmcompressor import oneshot | ||
| from llmcompressor.modifiers.quantization import QuantizationModifier | ||
|
|
||
| MODEL_ID = "/raid/engine/dsikka/models--Qwen--Qwen3.5-397B-A17B/snapshots/7cad2bae11cb49ca79f7d6a0954de2e2756f4e27" |
There was a problem hiding this comment.
The MODEL_ID is currently hardcoded to a specific local path. This reduces the portability and reusability of the example script. Consider making this path configurable, perhaps through command-line arguments or environment variables, to allow users to easily specify their model location.
| MODEL_ID = "/raid/engine/dsikka/models--Qwen--Qwen3.5-397B-A17B/snapshots/7cad2bae11cb49ca79f7d6a0954de2e2756f4e27" | |
| MODEL_ID = "/path/to/your/model" # TODO: Make this configurable, e.g., via argparse |
| oneshot(model=model, recipe=recipe) | ||
|
|
||
| # Save to disk in compressed-tensors format. | ||
| SAVE_DIR = "/raid/engine/dsikka/" + "Qwen3.5-397B-A17B" + "-FP8-DYNAMIC" |
There was a problem hiding this comment.
Similar to MODEL_ID, the SAVE_DIR is hardcoded to a local path. This can lead to issues if the script is run in a different environment or by another user. It would be beneficial to make this directory configurable, allowing users to specify where they want to save the quantized model.
| SAVE_DIR = "/raid/engine/dsikka/" + "Qwen3.5-397B-A17B" + "-FP8-DYNAMIC" | |
| SAVE_DIR = "/path/to/save/quantized_model" # TODO: Make this configurable |
| from torch import nn | ||
|
|
||
| TORCH_INIT_FUNCTIONS = { | ||
| "uniform_": nn.init.uniform_, | ||
| "normal_": nn.init.normal_, | ||
| "trunc_normal_": nn.init.trunc_normal_, | ||
| "constant_": nn.init.constant_, | ||
| "xavier_uniform_": nn.init.xavier_uniform_, | ||
| "xavier_normal_": nn.init.xavier_normal_, | ||
| "kaiming_uniform_": nn.init.kaiming_uniform_, | ||
| "kaiming_normal_": nn.init.kaiming_normal_, | ||
| "uniform": nn.init.uniform, | ||
| "normal": nn.init.normal, | ||
| "xavier_uniform": nn.init.xavier_uniform, | ||
| "xavier_normal": nn.init.xavier_normal, | ||
| "kaiming_uniform": nn.init.kaiming_uniform, | ||
| "kaiming_normal": nn.init.kaiming_normal, | ||
| } |
There was a problem hiding this comment.
The TORCH_INIT_FUNCTIONS dictionary is redefined locally after commenting out the import from transformers.modeling_utils. This introduces a potential maintenance burden, as any future updates or changes in transformers regarding these initialization functions might not be reflected here, leading to subtle bugs or unexpected behavior. Please add a comment explaining the specific reason for this local redefinition and why the upstream version could not be used. This will help future developers understand the context and potential implications.
|
The quality checks have failed. Please run |
|
The quality checks have failed. Please run |
| super().__init__( | ||
| [ | ||
| Qwen3_5MoeMLP( | ||
| config, intermediate_size=config.shared_expert_intermediate_size |
There was a problem hiding this comment.
Should be config.moe_intermediate_size , this will create incorrectly sized linear layers.
| self, | ||
| original: "Qwen3_5MoeSparseMoeBlock", | ||
| config: "Qwen3_5MoeConfig", | ||
| calibrate_all_experts: bool, |
There was a problem hiding this comment.
calibrate_all_experts as there is no forward() function implemented, calibration module will not work at runtime.
| from transformers import AutoModelForCausalLM, PreTrainedModel | ||
| from transformers.modeling_utils import TORCH_INIT_FUNCTIONS | ||
|
|
||
| # from transformers.modeling_utils import TORCH_INIT_FUNCTIONS |
There was a problem hiding this comment.
Unrelated to Qwen 3.5 as this is a transformers compatibility workaround
SUMMARY:
"please provide a brief summary"
TEST PLAN:
"please outline how the changes were tested"