Conversation
Collaborator
entrpn
commented
Feb 13, 2025
- Adds support for loading Flux LoRAs for inference.
… Start creating generation code for flux.
Collaborator
Author
|
@jcaraban @ksikiric this is the PR for loading LoRA with Flux. Is it possible to rebase the Flux training PR and continue working from there? |
This was referenced Feb 13, 2025
bvandermoon
approved these changes
Feb 14, 2025
Comment on lines
+47
to
+65
| def maybe_load_flux_lora(config, lora_loader, params): | ||
| def _noop_interceptor(next_fn, args, kwargs, context): | ||
| return next_fn(*args, **kwargs) | ||
|
|
||
| lora_config = config.lora_config | ||
| interceptors = [_noop_interceptor] | ||
| if len(lora_config["lora_model_name_or_path"]) > 0: | ||
| interceptors = [] | ||
| for i in range(len(lora_config["lora_model_name_or_path"])): | ||
| params, rank, network_alphas = lora_loader.load_lora_weights( | ||
| config, | ||
| lora_config["lora_model_name_or_path"][i], | ||
| weight_name=lora_config["weight_name"][i], | ||
| params=params, | ||
| adapter_name=lora_config["adapter_name"][i], | ||
| ) | ||
| interceptor = lora_loader.make_lora_interceptor(params, rank, network_alphas, lora_config["adapter_name"][i]) | ||
| interceptors.append(interceptor) | ||
| return params, interceptors |
Collaborator
There was a problem hiding this comment.
Nit: Why not use maybe_load_lora() from maxdiffusion_utils?
Collaborator
Author
There was a problem hiding this comment.
maybe_use_lora() in maxdiffusion_utils is specific to sdxl and won't work with flux. I should rename that method to maybe_load_sdxl_lora. I will create an issue to track this and add it on a different commit. Thanks for the review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.