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

Unloading multiple loras: norms do not return to their original values #10745

Open
christopher5106 opened this issue Feb 7, 2025 · 5 comments

Comments

@christopher5106
Copy link

When unloading from multiple loras on flux pipeline, I believe that the norm layers are not restored here.

Shouldn't we have:

        if len(transformer_norm_state_dict) > 0:
            original_norm_layers_state_dict = self._load_norm_into_transformer(
                transformer_norm_state_dict,
                transformer=transformer,
                discard_original_layers=False,
            )
            if not hasattr(transformer, "_transformer_norm_layers"):
                 transformer._transformer_norm_layers = original_norm_layers_state_dict
@christopher5106 christopher5106 changed the title Loading multiple loras: norms do not return to their original values Unloading multiple loras: norms do not return to their original values Feb 7, 2025
@sayakpaul
Copy link
Member

Should it not already take care of it?

transformer.load_state_dict(transformer._transformer_norm_layers, strict=False)

What am I missing?

Additionally, the following test does ensure its effectivity:

def test_lora_unload_with_parameter_expanded_shapes(self):

@christopher5106
Copy link
Author

Ah, is it possible to call load_lora_weights() multiple times on a pipeline to load multiple weights ? does it unload in between to restore original weights ?

@sayakpaul
Copy link
Member

If you don’t call unload_lora_weights() it won’t be called automatically.

@christopher5106
Copy link
Author

so in that case of multiple calls to load_lora_weights(), the attribute _transformer_norm_layers become overwritten by the norms of the previously loaded lora ?

@sayakpaul
Copy link
Member

If you're loading Control LoRA and want to keep it with others, the norm layer values that came with the Control LoRA will remain like so. Otherwise, the effectiveness of Control LoRA won't fully be there.

Or am I misinterpreting the core use case here?

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

No branches or pull requests

2 participants