Skip to content
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

Merged
merged 33 commits into from
Feb 14, 2025
Merged

Flux lora #148

merged 33 commits into from
Feb 14, 2025

Conversation

entrpn
Copy link
Collaborator

@entrpn entrpn commented Feb 13, 2025

  • Adds support for loading Flux LoRAs for inference.

@entrpn
Copy link
Collaborator Author

entrpn commented Feb 13, 2025

@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?

Copy link
Collaborator

@bvandermoon bvandermoon left a 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

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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@entrpn entrpn merged commit 41e901c into main Feb 14, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants