Skip to content

Conversation

@byjiang1996
Copy link
Collaborator

@byjiang1996 byjiang1996 commented Nov 13, 2025

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 transformer 5.x. The changes primarily involve minor but critical adjustments to utility functions, specifically how tqdm progress bars are handled and how Jinja templates are processed, to maintain functionality and compatibility with the new major version of the transformers library.

Highlights

  • Dependency Update Preparation: This pull request introduces necessary code adjustments to ensure compatibility with the upcoming transformer 5.x library version.
  • Tqdm Initialization Fix: The DisabledTqdm class initialization has been modified to explicitly set disable=True via kwargs, ensuring that progress bars are consistently disabled when intended.
  • Jinja Template Output Control: The _apply_jinja_template function now includes return_dict=False when rendering templates, likely to standardize the output format to a string rather than a dictionary, aligning with potential changes in transformer 5.x's templating behavior.
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 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
Copy link
Collaborator Author

@byjiang1996 byjiang1996 Nov 13, 2025

Choose a reason for hiding this comment

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

Default value changed from False to True in 5.x transfomer. We have to explicitly set it to False in all places...
image

image

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Nov 13, 2025

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs, disable=True)
kwargs["disable"] = True
Copy link
Collaborator

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?

Copy link
Contributor

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.

@byjiang1996 byjiang1996 changed the title Required changes for bumping up to transformer 5.x [GLM4.6v] Required changes for bumping up to transformer 5.x Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants