Skip to content

Conversation

@ishrith-gowda
Copy link

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:

  • Added 5 new model mappings to MAPPINGS_REGISTRY
  • Alphabetically sorted registry for maintainability
  • Registry growth: 9 models → 14 models (55% increase)

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: 2

Code quality checks passed:

  • ruff format - no changes needed
  • ruff check - all checks passed

Addresses issue #1442

@github-actions
Copy link

👋 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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 Model Support: Added SmoothQuant support for five new large language model architectures: Gemma2, Gemma3, Llama4, Mistral3, and Qwen3.
  • Mapping Reusability: All newly supported models utilize the DEFAULT_SMOOTHQUANT_MAPPINGS due to their shared transformer architecture with existing models.
  • Registry Update: The MAPPINGS_REGISTRY in src/llmcompressor/modifiers/smoothquant/utils.py has been updated to include these new models and was alphabetically sorted for maintainability.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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]>
@ishrith-gowda ishrith-gowda force-pushed the add-smoothquant-mappings-gemma-llama4-mistral3-qwen3 branch from 707cd8c to 931ee59 Compare December 28, 2025 21:46
@ishrith-gowda
Copy link
Author

Good catch! I've added Gemma3ForConditionalGeneration to match the AWQ mappings pattern and support the multimodal examples in the repo. Updated from 5 to 6 model architectures.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Ishrith Gowda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant