-
Notifications
You must be signed in to change notification settings - Fork 1k
[bugfix] fix gptq_v2 #6126
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
[bugfix] fix gptq_v2 #6126
Conversation
Summary of ChangesHello @Jintao-Huang, 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 by extending support for the 'gptq_v2' quantization method across key components of the quantization pipeline. It ensures that 'gptq_v2' is properly recognized and processed during argument parsing and dataset preparation, aligning its behavior with the existing 'gptq' method. 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.
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 introduces support for the gptq_v2 quantization method. The changes correctly integrate gptq_v2 into the existing quantization logic, treating it similarly to the gptq method, particularly for dataset preparation. The implementation is straightforward and appears correct. I have one suggestion regarding code duplication to enhance maintainability.
| except MaxLengthError: | ||
| continue | ||
| if is_multimodal and args.quant_method == 'gptq': | ||
| if is_multimodal and args.quant_method in {'gptq', 'gptq_v2'}: |
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.
The condition args.quant_method in {'gptq', 'gptq_v2'} is repeated multiple times within this function (here, and on lines 110 and 118). To improve code clarity and future maintainability, consider defining a boolean variable at the beginning of the function and reusing it. For example:
is_gptq_family = args.quant_method in {'gptq', 'gptq_v2'}You could then use if is_multimodal and is_gptq_family: in the conditional checks.
|
/gemini review |
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 introduces a fix for gptq_v2 quantization and adds compatibility for newer versions of the transformers library. The changes include updating documentation to warn users about the effects of packing, adding gptq_v2 to relevant logic paths, and implementing a patch for transformers>=4.54. Additionally, the transformers version is pinned in AWQ example scripts. My review focuses on improving the clarity and maintainability of these changes.
| @@ -1,3 +1,5 @@ | |||
| pip install "transformers<4.52" | |||
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.
To improve maintainability and help other developers, it would be beneficial to add a comment explaining why transformers<4.52 is required. This provides context for the version pinning.
| pip install "transformers<4.52" | |
| pip install "transformers<4.52" # Pinned to avoid compatibility issues with AWQ in newer versions. |
| @@ -1,3 +1,5 @@ | |||
| pip install "transformers<4.52" | |||
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.
Similar to the other awq.sh script, please add a comment explaining the reason for pinning the transformers version. This helps with future maintenance and understanding.
| pip install "transformers<4.52" | |
| pip install "transformers<4.52" # Pinned to avoid compatibility issues with AWQ in newer versions. |
swift/llm/export/quant.py
Outdated
| if not getattr(self.model, '_dynamic_tied_weights_keys'): | ||
| self.model._dynamic_tied_weights_keys = [] | ||
| self.model._dynamic_tied_weights_keys += ['wf_unsqueeze_zero', 'wf_unsqueeze_neg_one'] |
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.
The keys wf_unsqueeze_zero and wf_unsqueeze_neg_one are not self-descriptive. To improve code clarity and maintainability, please add a comment explaining what these keys are for and why they are necessary for gptq_v2 quantization. This context is crucial for anyone working on this code in the future.
#6102