-
Notifications
You must be signed in to change notification settings - Fork 346
Add Gemma2/3, Llama4, Mistral3, and Qwen3 SmoothQuant mappings #2174
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
base: main
Are you sure you want to change the base?
Add Gemma2/3, Llama4, Mistral3, and Qwen3 SmoothQuant mappings #2174
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 @ishrith-gowda, 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 significantly expands the SmoothQuant integration by adding support for several cutting-edge large language models, including Gemma2, Gemma3, Llama4, Mistral3, and Qwen3. By leveraging existing default mappings, the change efficiently enables these models to benefit from quantization, enhancing their performance and efficiency without requiring new custom configurations. The update ensures broader compatibility and maintainability within the SmoothQuant framework. 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. 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.
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 adds SmoothQuant support for five new model architectures: Gemma2, Gemma3, Llama4, Mistral3, and Qwen3. The changes involve adding new entries to the MAPPINGS_REGISTRY and sorting the registry alphabetically for better maintainability. The changes are straightforward and well-described. I've identified a minor discrepancy with the Gemma3 model mapping where the example usage seems to differ from the registered model class name. I've suggested adding an explicit mapping to improve robustness.
Adds support for 6 new model architectures: - Gemma2ForCausalLM - Gemma3ForCausalLM - Gemma3ForConditionalGeneration - Llama4ForConditionalGeneration - Mistral3ForConditionalGeneration - Qwen3ForCausalLM All models use DEFAULT_SMOOTHQUANT_MAPPINGS as they share transformer architecture with their predecessors (Gemma, Llama, Mistral, Qwen2). Both Gemma3 class names included to match AWQ mappings pattern and support multimodal variants. Registry alphabetically sorted for maintainability. Registry growth: 9 models → 15 models (66% increase). ### Test ``` $ python3 -m py_compile src/llmcompressor/modifiers/smoothquant/utils.py ✓ Syntax validation passed ``` Signed-off-by: Ishrith Gowda <[email protected]>
707cd8c to
931ee59
Compare
|
Good catch! I've added |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Ishrith Gowda <[email protected]>
SUMMARY:
This PR adds SmoothQuant support for 5 new model architectures: Gemma2ForCausalLM, Gemma3ForCausalLM, Llama4ForConditionalGeneration, Mistral3ForConditionalGeneration, and Qwen3ForCausalLM.
All models use DEFAULT_SMOOTHQUANT_MAPPINGS as they share the same transformer architecture with their predecessors (Gemma, Llama, Mistral, Qwen2) that already use these mappings.
Changes:
TEST PLAN:
Validated all 5 models successfully load their mappings:
$ python3 -c "from src.llmcompressor.modifiers.smoothquant.utils import get_layer_mappings_from_architecture; print('Gemma2:', len(get_layer_mappings_from_architecture('Gemma2ForCausalLM'))); print('Gemma3:', len(get_layer_mappings_from_architecture('Gemma3ForCausalLM'))); print('Llama4:', len(get_layer_mappings_from_architecture('Llama4ForConditionalGeneration'))); print('Mistral3:', len(get_layer_mappings_from_architecture('Mistral3ForConditionalGeneration'))); print('Qwen3:', len(get_layer_mappings_from_architecture('Qwen3ForCausalLM')))" Gemma2: 2 Gemma3: 2 Llama4: 2 Mistral3: 2 Qwen3: 2Code quality checks passed:
ruff format- no changes neededruff check- all checks passedAddresses issue #1442