-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[GLM4.6v] Required changes for bumping up to transformer 5.x #13229
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?
Conversation
Summary of ChangesHello @byjiang1996, 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 prepares the codebase for an upgrade to 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 necessary changes to support transformers version 5.x. The modifications primarily involve updating calls to apply_chat_template by adding return_dict=False to maintain the expected return type, and adjusting the DisabledTqdm class to handle keyword arguments more robustly. The changes are correct and address the compatibility requirements. I've left one comment regarding code duplication for the DisabledTqdm class, which could be moved to a shared utility module to improve maintainability.
| **( | ||
| request.chat_template_kwargs if request.chat_template_kwargs else {} | ||
| ), | ||
| return_dict=False |
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.
1b13b56 to
518a4ca
Compare
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs, disable=True) | ||
| kwargs["disable"] = True |
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.
/gemini what's the difference here?
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 difference is in how the disable=True argument is passed to the tqdm constructor.
Before:
super().__init__(*args, **kwargs, disable=True)This directly passes disable=True as a keyword argument. If kwargs already contained a disable key, this would result in a TypeError because the argument would be duplicated.
After:
kwargs["disable"] = True
super().__init__(*args, **kwargs)This approach first explicitly sets or overrides the "disable" key in the kwargs dictionary to True. Then, **kwargs (which now definitively includes "disable": True) is passed to the super().__init__ method.
Functional Difference:
This change makes the DisabledTqdm class more robust. It ensures that disable is always True when the tqdm constructor is called, regardless of whether disable was already present in the kwargs passed to DisabledTqdm.__init__. It prevents potential TypeError exceptions and guarantees the intended behavior of disabling the progress bar.


Motivation
Required changes for bumping up to transformer 5.x. It is required to support new GLM-v model: huggingface/transformers#42122.
Verified with GLM team. This change works for transformer 5.x.
Their new GLM model is included in transformer 5.x which hasn't been officially released so we cannot directly upgrade to trans 5.x in this PR. However, this PR should be safe to merge b/c it is compatible with both trans 4.x and trans 5.x
Modification
Can be found in the opened PR comments. Only two changes.
Checklist