Skip to content

[WIP][LoRA] support sd3.5 non-diffusers loras. #10167

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

sayakpaul
Copy link
Member

@sayakpaul sayakpaul commented Dec 10, 2024

What does this PR do?

Fixes #9950.

Currently, it only supports LoRAs having the MMDiT blocks.

@vladmandic possible to test this? We can improve support for the LoRAs involving non-MMDiT blocks as we go.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@vladmandic
Copy link
Contributor

i'll give it a test.

fyi, we just did a complete lora processing refactoring in sdnext and changed load/apply methods from forward to pre-processing.
we're getting quite a better results and its compatible with offloading and quantization.
and yes, we do have sd35 support as well.
if you want to take a look, code is now fully modularized and avoids silly monkey-patching that was previously present.

image

@sayakpaul
Copy link
Member Author

Thanks, Vlad!

is_correct_format = all("lora" in key for key in state_dict.keys())
if not is_correct_format:
raise ValueError("Invalid LoRA checkpoint.")

transformer_state_dict = {k: v for k, v in state_dict.items() if "transformer." in k}
transformer_state_dict = {k: v for k, v in state_dict.items() if k.startswith(f"{self.transformer_name}.")}
Copy link
Member Author

Choose a reason for hiding this comment

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

To inform the user about it when load_lora_weights() effectively becomes a no-op.

Copy link
Contributor

github-actions bot commented Jan 9, 2025

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot added the stale Issues that haven't received updates label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues that haven't received updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve SD35 LoRA support to cover most popular LoRA formats
3 participants