-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[LoRA] feat: support loading regular Flux LoRAs into Flux Control, and Fill #10259
base: main
Are you sure you want to change the base?
Conversation
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. |
Co-authored-by: a-r-r-o-w <[email protected]>
Requesting for a review from @BenjaminBossan for initial stuff. Then will request reviews from others. |
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.
Thanks for extending the functionality of loading LoRA adapters when shapes need to be expanded. The PR LGTM, I only have a nit.
One question that came up (maybe it was already discussed and I just missed it or forgot): Right now, this type of expansion is permanent, right? I.e. even after unloading the LoRA that made the expansion necessary in the first place, the expansion is not undone. Probably that would be quite hard to add and not worth the effort, I'm just curious.
The LoRA state dict expansion is permanent. But model-level state dict expansion can be undone is being added in #10206 |
components, _, _ = self.get_dummy_components(FlowMatchEulerDiscreteScheduler) | ||
pipe = self.pipeline_class(**components) | ||
pipe = pipe.to(torch_device) | ||
pipe.set_progress_bar_config(disable=None) | ||
dummy_lora_A = torch.nn.Linear(1, rank, bias=False) | ||
dummy_lora_B = torch.nn.Linear(rank, out_features, bias=False) | ||
lora_state_dict = { | ||
"transformer.x_embedder.lora_A.weight": dummy_lora_A.weight, | ||
"transformer.x_embedder.lora_B.weight": dummy_lora_B.weight, | ||
} | ||
# We should error out because lora input features is less than original. We only | ||
# support expanding the module, not shrinking it | ||
with self.assertRaises(NotImplementedError): | ||
pipe.load_lora_weights(lora_state_dict, "adapter-1") |
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.
Removing this part of the test because in case LoRA input feature dimensions are less than the original, we expand it.
This is tested below with test_lora_expanding_shape_with_normal_lora()
and test_load_regular_lora()
.
Yes, something similar for LoRA would be nice, but it's not as important, as the overhead for LoRA should be relatively small. |
What does this PR do?
Fixes #10180, #10227, #10184
In short, this PR enables few-steps inference for Flux Control, Fill, Redux, etc.
Fill + Turbo LoRA
Flux Control LoRA + Turbo LoRA (different from the previous one)
Todods