Conversation
Summary of ChangesHello @gushiqiao, 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 significantly enhances the 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 support for LoRA to the Z-Image runner. It introduces a new helper function build_z_image_model_with_lora to handle both dynamic application and merging of LoRA weights. The load_transformer method is updated to use this new functionality.
My review focuses on improving the robustness and clarity of the new LoRA handling logic. I've suggested changes to handle LoRA configurations more safely and to provide clearer error messages to the user. Specifically, I've pointed out that the dynamic LoRA application path only uses the first LoRA configuration and should warn the user if more are provided, and that an assertion message could be more explicit about why LoRA merging is not supported in certain cases.
| lora_path = lora_configs[0]["path"] | ||
| lora_strength = lora_configs[0]["strength"] | ||
| model_kwargs["lora_path"] = lora_path | ||
| model_kwargs["lora_strength"] = lora_strength |
There was a problem hiding this comment.
The current implementation for dynamic LoRA application has a couple of issues:
- It only considers the first LoRA configuration and silently ignores others if multiple are provided.
- It accesses
lora_configs[0]['strength']directly, which can cause aKeyErrorif the key is missing.
The suggested change addresses these by using .get() for safe access to 'strength' and adding a warning when more than one LoRA is configured for dynamic application, as this path appears to support only one.
| lora_path = lora_configs[0]["path"] | |
| lora_strength = lora_configs[0]["strength"] | |
| model_kwargs["lora_path"] = lora_path | |
| model_kwargs["lora_strength"] = lora_strength | |
| lora_config = lora_configs[0] | |
| if len(lora_configs) > 1: | |
| logger.warning("Dynamic LoRA apply only supports one LoRA configuration, using the first one.") | |
| model_kwargs["lora_path"] = lora_config["path"] | |
| model_kwargs["lora_strength"] = lora_config.get("strength", 1.0) |
| model_kwargs["lora_strength"] = lora_strength | ||
| model = z_image_module(**model_kwargs) | ||
| else: | ||
| assert not config.get("dit_quantized", False), "Online LoRA only for quantized models; merging LoRA is unsupported." |
There was a problem hiding this comment.
The assertion message is a bit confusing. It correctly prevents LoRA merging for quantized models, but the message 'Online LoRA only for quantized models; merging LoRA is unsupported.' could be clearer. A more direct message explaining that merging is not supported for quantized models and suggesting the alternative would be more helpful for the user.
| assert not config.get("dit_quantized", False), "Online LoRA only for quantized models; merging LoRA is unsupported." | |
| assert not config.get("dit_quantized", False), "Merging LoRA is not supported for quantized models. Use `lora_dynamic_apply=True` instead." |
No description provided.