Patch before compile?#3995
Conversation
Summary of ChangesHello @Datta0, 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 resolves a critical timing issue in the model compilation workflow. By explicitly applying temporary patches before initiating the main compilation loop, it guarantees that any class replacements or modifications introduced by these patches are correctly registered and active. This prevents the compiler from inadvertently caching references to outdated class definitions, ensuring the integrity and correct behavior of the compiled models. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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.
Code Review
This pull request adds an extra application of temporary patches right before the model compilation loop. The goal, as stated in the comment, is to ensure class replacements are in place before the compiler caches them. The change is simple and seems to be a targeted fix for a timing issue. My only feedback is a minor concern about the redundancy of applying these patches multiple times (at module load, before compilation, and after compilation), which could be a point for future refactoring to improve maintainability. Overall, the change looks good and addresses a specific need.
| for temporary_patch in TEMPORARY_PATCHES: | ||
| temporary_patch() |
There was a problem hiding this comment.
This loop applies temporary patches, which is also done at the module level (lines 217-218). While the comment explains the need for patching right before compilation, this introduces a second application of the patches before the compilation loop. If these patches are idempotent, this is safe, but it could be slightly inefficient. For long-term maintainability, it would be ideal to have a single, clear point of application or a mechanism to prevent redundant patching. Since this change seems to be a targeted fix, it's acceptable, but it might be worth considering a small refactor to consolidate the patching logic in the future to avoid confusion.
|
This seems unnecessary. Closing it |

unslothai/unsloth-zoo#471