refactor(awq): restructure AWQModifier to be similar to SmoothQuantCl…#2402
refactor(awq): restructure AWQModifier to be similar to SmoothQuantCl…#2402vishnuprasanth-j wants to merge 2 commits intovllm-project:mainfrom
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 @vishnuprasanth-j, 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 refactors the AWQModifier by separating its smoothing functionality from the actual quantization process. This change enhances modularity and clarity, positioning AWQModifier as a dedicated smoothing component that must be combined with a distinct quantization modifier to produce a fully quantized model. The update includes robust recipe validation and user warnings to guide proper implementation, along with comprehensive updates to all relevant examples. 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 refactors the AWQModifier to be a smoothing-only modifier, separating it from the quantization process. This is a significant architectural change that aligns it more closely with SmoothQuant and requires it to be stacked with a dedicated quantization modifier. The changes are well-reflected across the updated examples and the core modifier logic. I've identified a couple of areas for improvement: one concerning the accuracy of the grid search simulation for TENSOR_GROUP quantization, and another regarding the robustness of the new recipe validation logic when multiple configuration groups are used.
60c0624 to
1b55a0d
Compare
1b55a0d to
5c0b5cd
Compare
brian-dellabetta
left a comment
There was a problem hiding this comment.
Hi @vishnuprasanth-j , thanks for the contribution. I think this implementation is preferable to my draft PR #2206 to add a disable_quantization option to AWQModifier
We originally wanted AWQ to also quantize due to user feedback, but I think it complicates things more than it's worth, and we can always dynamically append a QuantizationModifier during recipe.validate if AWQ is found without an accompanying QuantizationModifier.
I will discuss with the team
brian-dellabetta
left a comment
There was a problem hiding this comment.
Hi @vishnuprasanth-j , thanks for taking a stab at this. Ultimately we want to move to this, but your diff has a lot of unnecessary changes and I don't think it will work. But we can iterate over this if you'd like. I've left some comments for now
| # For non-MoE models, convert sentinel to None | ||
| # (no offloading by default) |
There was a problem hiding this comment.
it's hard to read through the changes to your diff because you're making a lot of changes that are unrelated to the restructure. please revert so the diff is clean and scoped to your PR changes
|
|
||
| # Allow arbitrary types because AWQMapping has fields of type torch.nn.Module | ||
| model_config: ConfigDict = ConfigDict(arbitrary_types_allowed=True) | ||
| model_config: ConfigDict = ConfigDict(arbitrary_types_allowed=True, extra="allow") |
There was a problem hiding this comment.
why is extra="allow" needed?
|
|
||
| # apply config to model and prepare calibration hooks | ||
| if QuantizationMixin.has_config(self): | ||
| QuantizationMixin.initialize_quantization(self, state.model) |
There was a problem hiding this comment.
removing this logic means apply_quantization_config is never run on the model, so no quantization_scheme is ever set on the targeted modules. I don't think your current implementation will work. Have you run this?
SUMMARY:
This PR restructures and simplifies AWQModifier to be similar to SmoothQuant. This is PR for: #2327
Solution:
This refactoring removes the quantization code from AWQModifier, making it perform smoothing only. AWQModifier now inherits from Modifier and HooksMixin (instead of QuantizationMixin), and must be stacked with a separate quantization modifier (QuantizationModifier, GPTQModifier, or QuIPModifier) to produce a quantized model. The changes include: (1) Removing QuantizationMixin inheritance and related code, (2) Adding recipe validation to ensure AWQ comes before quantization modifiers in the recipe, (3) Adding a warning when AWQ is used standalone without a subsequent quantization modifier, (4) All existing AWQ examples updated to use the new stacked pattern.
All existing AWQ examples updated and tested with new stacked pattern.