-
Notifications
You must be signed in to change notification settings - Fork 23
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
Flux lora #148
Conversation
entrpn
commented
Feb 13, 2025
- Adds support for loading Flux LoRAs for inference.
… Start creating generation code for flux.
@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? |
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.
LGTM outside of the PyTest failure
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 |
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.
Nit: Why not use maybe_load_lora() from maxdiffusion_utils?
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.
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.