-
Notifications
You must be signed in to change notification settings - Fork 183
Add logging to tiled mlp and fix target chunk size calculation #361
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
Conversation
Summary of ChangesHello @mmathew23, 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 enhances the TiledMLP functionality by resolving a critical shard size calculation error that could occur under specific configurations. Additionally, it integrates a new logging mechanism to provide clear indications when TiledMLP is actively being used, improving debugging and operational transparency. 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 logging to the tiled MLP functionality and corrects an issue with shard size calculation. The logic for the fix appears sound and is well-integrated with the existing tiling strategies. The new logging will be helpful for users to know when Tiled MLP is active. I've included a couple of suggestions to align the new logging code with the existing logging utilities in the project, which will improve consistency and maintainability.
| UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1" | ||
| UNSLOTH_ENABLE_TILED_LOGGING = UNSLOTH_ENABLE_LOGGING and os.environ.get("UNSLOTH_ENABLE_TILED_LOGGING", "0") == "1" |
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 avoid code duplication and potential inconsistencies, you should import UNSLOTH_ENABLE_LOGGING from unsloth_zoo.log instead of redefining it here. The version in unsloth_zoo.log is also more robust as it checks for "1", "True", and "true".
Please add from unsloth_zoo.log import UNSLOTH_ENABLE_LOGGING to your imports. You can then replace these two lines with just the definition for UNSLOTH_ENABLE_TILED_LOGGING.
| UNSLOTH_ENABLE_LOGGING = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1" | |
| UNSLOTH_ENABLE_TILED_LOGGING = UNSLOTH_ENABLE_LOGGING and os.environ.get("UNSLOTH_ENABLE_TILED_LOGGING", "0") == "1" | |
| UNSLOTH_ENABLE_TILED_LOGGING = UNSLOTH_ENABLE_LOGGING and os.environ.get("UNSLOTH_ENABLE_TILED_LOGGING", "0") == "1" |
| ctx.split_sizes = split_sizes | ||
| global FIRST_PASS | ||
| if (FIRST_PASS and UNSLOTH_ENABLE_LOGGING) or UNSLOTH_ENABLE_TILED_LOGGING: | ||
| print(f"Unsloth: Enabling TiledMLP to reduce VRAM usage! chunk size: {split_sizes[0]}") |
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.
It's better to use a proper logger for logging instead of print(). This allows for better control over log levels, formatting, and output streams. The unsloth_zoo.log module provides a configured logger instance that you can import and use.
After importing logger from unsloth_zoo.log, you can make the following change:
| print(f"Unsloth: Enabling TiledMLP to reduce VRAM usage! chunk size: {split_sizes[0]}") | |
| logger.info(f"Unsloth: Enabling TiledMLP to reduce VRAM usage! chunk size: {split_sizes[0]}") |
Fix a shard size calculation issue when tiled mlp is set to target. Also add logging so we know Tiled MLP is enabled.