Skip to content

Conversation

@qzzz95
Copy link
Contributor

@qzzz95 qzzz95 commented Nov 4, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @qzzz95, 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 QwenImagePipeline by introducing an optional mechanism to skip the loading and initialization of the encoder component. This provides users with greater control over resource allocation, allowing for potential memory savings and faster startup times in scenarios where the encoder is not required for a specific task. The default behavior remains unchanged, ensuring existing workflows are not disrupted.

Highlights

  • Configuration Option: Introduced a new boolean field, load_encoder, in the QwenImagePipelineConfig class, defaulting to True, to control whether the encoder component should be loaded.
  • Conditional Encoder Loading: Modified the from_pretrained method in qwen_image.py to conditionally load the encoder's state dictionary only if config.load_encoder is True.
  • Conditional Component Initialization: Updated the _from_state_dict method to conditionally initialize the tokenizer, processor, and the encoder model itself, based on the config.load_encoder flag.
  • Pipeline Construction: Ensured that the QwenImagePipeline constructor passes None for the tokenizer, processor, and encoder if config.load_encoder is False, preventing unnecessary object creation.
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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @qzzz95, 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 Qwen image pipeline by introducing an optional loading mechanism for its text encoder, tokenizer, and processor components. By adding a load_encoder flag to the pipeline configuration, users can now choose to bypass the loading and initialization of these elements, leading to more efficient resource utilization and potentially faster startup times for scenarios where the encoder is not essential.

Highlights

  • Optional Encoder Loading: A new configuration option, load_encoder, has been introduced to control whether the text encoder, tokenizer, and processor components of the Qwen image pipeline are loaded during initialization.
  • Conditional Component Initialization: The logic for loading the encoder's state dictionary and initializing the tokenizer, processor, and encoder models has been made conditional, executing only if load_encoder is set to True.
  • Resource Optimization: This change allows for more flexible resource management, enabling users to skip loading potentially large encoder-related models when they are not required, which can reduce memory footprint and speed up pipeline setup.
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 introduces a load_encoder flag to QwenImagePipelineConfig to make loading the text encoder optional. The changes correctly wrap the encoder loading logic in conditional blocks based on this flag.

However, I've found a high-severity issue that will cause a NameError if the pipeline is initialized with load_encoder=False. I've left a comment with a suggested fix.

Additionally, for improved robustness and maintainability, I recommend adding checks in methods that require the encoder (like __call__) to raise an informative error if it's not loaded. The type hints for tokenizer, processor, and encoder in QwenImagePipeline.__init__ should also be updated to Optional to reflect that they can be None. These changes are outside the current diff but are important for the overall quality of this feature.

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 the ability to optionally load the encoder in the QwenImagePipeline by adding a load_encoder flag to the configuration. The implementation correctly gates the loading of the encoder's state dictionary and its initialization based on this flag. However, there is a critical issue in _from_state_dict that will lead to an UnboundLocalError when the encoder is not loaded. I've provided a detailed comment on how to fix this.

qzzz95 and others added 2 commits November 4, 2025 13:52
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@akaitsuki-ii akaitsuki-ii merged commit 5e86c87 into main Nov 4, 2025
@akaitsuki-ii akaitsuki-ii deleted the dev/qz/load_encoder_optional branch November 4, 2025 06:03
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