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

[LoRA] Add LoRA support to AuraFlow #10216

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

hameerabbasi
Copy link

What does this PR do?

This PR is a simple rebase of #9017

cc @sayakpaul for review.

Fixes # (issue)

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hameerabbasi
Copy link
Author

Thanks for the helping hand, @hlky!

@hlky
Copy link
Collaborator

hlky commented Dec 13, 2024

See https://github.com/huggingface/diffusers/blob/main/tests/lora/test_lora_layers_flux.py https://github.com/huggingface/diffusers/blob/main/tests/lora/test_lora_layers_mochi.py etc as an example for tests. Seems to be missing transformer_cls, get_dummy_inputs and probably others, ping @sayakpaul if you need help with lora tests.

@hameerabbasi
Copy link
Author

hameerabbasi commented Dec 15, 2024

@sayakpaul Okay; I'm at a point where I've got actual, valid test failures but have no idea where to look.
pytest.log

@hameerabbasi
Copy link
Author

Here's the log after the latest commit: pytest.log

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I have left some comments to fix a couple of things. LMK if they're unclear.

src/diffusers/loaders/lora_pipeline.py Show resolved Hide resolved
@classmethod
@validate_hf_hub_args
# Copied from diffusers.loaders.lora_pipeline.StableDiffusionLoraLoaderMixin.lora_state_dict
def lora_state_dict(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't think we need to copy-paste it from StableDiffusionLoraLoaderMixin.

It should be copy-pasted from

def lora_state_dict(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads to the following test failure:

FAILED tests/lora/test_lora_layers_af.py::AuraFlowLoRATests::test_unexpected_keys_warning - ValueError: too many values to unpack (expected 2)

src/diffusers/loaders/lora_pipeline.py Show resolved Hide resolved
src/diffusers/loaders/lora_pipeline.py Show resolved Hide resolved
safe_serialization=safe_serialization,
)

def fuse_lora(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be accompanied with a # Copied from ... statement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in the previous PR; do you know where it was copied from?

components=components, lora_scale=lora_scale, safe_fusing=safe_fusing, adapter_names=adapter_names
)

def unfuse_lora(self, components: List[str] = ["transformer"], **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@hameerabbasi
Copy link
Author

Latest test log.

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.

5 participants