Skip to content

Conversation

@danielhanchen
Copy link
Contributor

No description provided.

danielhanchen and others added 28 commits December 9, 2025 01:02
* Fix get_input_embeds call for VLMs

* patch input_require_grads instead

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleanup old patch

* cleanup old patch

* cleanup

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestion from @danielhanchen

* use logger instead of prints

* Move unsloth present set

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @danielhanchen, 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 primarily focuses on maintenance, compatibility improvements, and internal refactoring. It updates a core dependency, introduces new patches to enhance compatibility with vision models and TRL's OpenEnv module, and streamlines the logging infrastructure. Additionally, it includes a version bump and a minor adjustment to the trainer's padding-free collator logic under specific conditions.

Highlights

  • Dependency Updates: The unsloth_zoo dependency has been updated to version 2025.12.4 in pyproject.toml, ensuring compatibility with the latest features and fixes.
  • New Compatibility Patches: Two new patches have been introduced: one to transformers.PreTrainedModel.enable_input_require_grads for better vision model compatibility, and another to trl.experimental.openenv to resolve NameError when vllm is not installed.
  • Improved Logging: The logging mechanism has been refactored to use unsloth_zoo.log.logger instead of direct print statements, providing more structured and controllable logging output across various patching functions.
  • Trainer Logic Enhancement: Padding-free collators are now explicitly disabled in the trainer when the UNSLOTH_RETURN_LOGITS environment variable is set, preventing potential conflicts.
  • Version Bump: The internal version of Unsloth has been incremented to 2025.12.5.
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

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

# Check for unsloth_zoo
try:
unsloth_zoo_version = importlib_version("unsloth_zoo")
if Version(unsloth_zoo_version) < Version("2025.12.3"):
print(

P1 Badge Raise runtime unsloth_zoo floor to match new dependency

The runtime version gate still allows unsloth_zoo 2025.12.3, but this commit both bumps the packaging requirement to unsloth_zoo>=2025.12.4 and starts importing new symbols such as unsloth_zoo.utils.Version (e.g., in trainer.py). In environments where an older 2025.12.3 install is already present or installed with --no-deps, the check here will pass even though the new imports will raise ImportError, preventing unsloth from loading. The minimum version enforced at import should be raised to the new floor.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen danielhanchen merged commit 8490f6e into main Dec 12, 2025
3 of 4 checks passed
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 several updates and fixes, including a version bump for unsloth_zoo, refactoring of initialization code, and new patches for transformers and trl compatibility. The logging has been improved by replacing print statements with a proper logger.

My review focuses on improving code style and robustness. I've pointed out a few places where bare except blocks are used, which can be risky. I've also suggested a minor cleanup of redundant parentheses.

Overall, the changes are positive and improve the library's stability and maintainability.

import inspect
from transformers import PreTrainedModel

# Check if the original function iterates over self.modules() instead of just returning the enable_input_require_grads
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using a bare except: is generally discouraged as it can catch unexpected exceptions like SystemExit or KeyboardInterrupt, making it harder to debug and interrupt the program. It's better to catch specific exceptions, or Exception at the very least.

Suggested change
# Check if the original function iterates over self.modules() instead of just returning the enable_input_require_grads
except Exception:

if importlib.util.find_spec("trl") is None:
return
trl_location = importlib.util.find_spec("trl").origin
trl_location = os.path.split(trl_location)[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's a minor style issue here. According to PEP 8, there should be no spaces around the = sign for keyword arguments. It should be encoding="utf-8".

Suggested change
trl_location = os.path.split(trl_location)[0]
with open(openenv, "r+", encoding="utf-8") as f:


diffusers_logger.addFilter(HideLoggingMessage("are deprecated"))
del diffusers_logger
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using a bare except: is generally discouraged as it can catch unexpected exceptions like SystemExit or KeyboardInterrupt, making it harder to debug and interrupt the program. It's better to catch specific exceptions, or Exception at the very least.

Suggested change
except:
except Exception:

# We also disable vision language models for padding free collators
blocked = (
data_collator is not None
(data_collator is not None)
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 extra parentheses around data_collator is not None are redundant since the entire boolean expression is already enclosed in parentheses. Removing them would make the code slightly cleaner.

Suggested change
(data_collator is not None)
data_collator is not None

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