Skip to content

Conversation

@Jintao-Huang
Copy link
Collaborator

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • GPTQ_V2 Method Recognition: The 'gptq_v2' quantization method is now explicitly recognized in the QuantizeArguments class, ensuring it's handled correctly when determining if a specific quantization configuration is needed.
  • Dataset Preparation for GPTQ_V2: The _get_quant_dataset method in quant.py has been updated to include 'gptq_v2' in its valid quantization methods, and to apply the same multimodal data and input ID processing logic as 'gptq'.
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 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'}:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@Jintao-Huang
Copy link
Collaborator Author

/gemini review

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 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
pip install "transformers<4.52"
pip install "transformers<4.52" # Pinned to avoid compatibility issues with AWQ in newer versions.

Comment on lines 47 to 49
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']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@Jintao-Huang Jintao-Huang merged commit d09ae00 into modelscope:main Oct 14, 2025
1 of 2 checks passed
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.

3 participants