Skip to content

Flux lora#148

Merged
entrpn merged 33 commits intomainfrom
flux_lora
Feb 14, 2025
Merged

Flux lora#148
entrpn merged 33 commits intomainfrom
flux_lora

Conversation

@entrpn
Copy link
Copy Markdown
Collaborator

@entrpn entrpn commented Feb 13, 2025

  • Adds support for loading Flux LoRAs for inference.

@entrpn
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
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