Skip to content

Conversation

@Glaceon-Hyy
Copy link
Member

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 QwenImageDiTNunchaku model. By explicitly passing critical parameters (num_layers, device, dtype) to the superclass constructor, it resolves potential memory or configuration problems that could arise from incomplete initialization. This ensures the model components are set up correctly from the start, contributing to more stable and reliable operation.

Highlights

  • Superclass Initialization: The __init__ method of QwenImageDiTNunchaku now correctly passes num_layers, device, and dtype to its superclass constructor, ensuring proper memory allocation and device/dtype configuration during initialization.
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 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)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
super().__init__(num_layers, device=device, dtype=dtype)
super(QwenImageDiT, self).__init__()

@qzzz95 qzzz95 merged commit d82861c into main Nov 18, 2025
@qzzz95 qzzz95 deleted the feature/fix_svd_init branch November 18, 2025 09:34
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