-
Notifications
You must be signed in to change notification settings - Fork 31
fix svd init memory #208
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
fix svd init memory #208
Conversation
Summary of ChangesHello @Glaceon-Hyy, 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 addresses an initialization issue within the 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 aims to fix a memory issue during model initialization. The proposed change correctly propagates device and dtype to the parent constructor, which is a valid bug fix. However, my review identifies a more fundamental issue with double initialization of modules, which causes significant memory overhead. I've suggested a change to call the grandparent's constructor directly. This would more effectively resolve the memory issue mentioned in the PR title by avoiding the creation of modules that are immediately replaced, and it would also make the code's intent clearer.
| nunchaku_rank: int = 32, | ||
| ): | ||
| super().__init__() | ||
| super().__init__(num_layers, device=device, dtype=dtype) |
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 current change correctly passes device and dtype to the superclass __init__, which fixes a bug where modules in the parent class could be allocated on the wrong device (e.g., when initializing with device='meta').
However, this doesn't solve the more significant underlying issue: modules are being initialized twice. First in QwenImageDiT.__init__, and then they are immediately overwritten in QwenImageDiTNunchaku.__init__. This causes a significant and unnecessary memory spike during model initialization.
Since the __init__ of QwenImageDiTNunchaku re-implements all the module initializations, the intention appears to be to replace, not extend, the parent's __init__ logic. To achieve this correctly and avoid the double initialization, you should call the grandparent's (PreTrainedModel) __init__ method directly. This will skip QwenImageDiT.__init__ and prevent the creation of modules that are immediately discarded.
| super().__init__(num_layers, device=device, dtype=dtype) | |
| super(QwenImageDiT, self).__init__() |
No description provided.